• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * SPDX-License-Identifier: GPL-2.0
4  *
5  * Unless required by applicable law or agreed to in writing, software
6  * distributed under the License is distributed on an "AS IS" BASIS,
7  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8  * See the License for the specific language governing permissions and
9  * limitations under the License.
10  */
11 
12 #ifndef ACCESSTOKENIDCOMMON_H
13 #define ACCESSTOKENIDCOMMON_H
14 #include <cstddef>
15 #include <cstdint>
16 
17 #define FUZZ_PROJECT_NAME "accesstokenidcommon"
18 
19 namespace OHOS {
20 namespace Kernel {
21 namespace AccessToken {
22 #define ACCESS_TOKEN_ID_IOCTL_BASE    'A'
23 
24 #ifdef CMDERROR
25 #define GET_TOKEN_ID    0
26 #define SET_TOKEN_ID    0
27 #define GET_GTOKEN_ID   0
28 #define SET_GTOKEN_ID   0
29 #else
30 #define GET_TOKEN_ID    1
31 #define SET_TOKEN_ID    2
32 #define GET_GTOKEN_ID   3
33 #define SET_GTOKEN_ID   4
34 #endif
35 
36 #define ACCESS_TOKENID_GET_TOKENID \
37         _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long)
38 #define ACCESS_TOKENID_SET_TOKENID \
39         _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long)
40 #define ACCESS_TOKENID_GET_FTOKENID \
41         _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_GTOKEN_ID, unsigned long long)
42 #define ACCESS_TOKENID_SET_FTOKENID \
43         _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_GTOKEN_ID, unsigned long long)
44 
45 #define LIST_NUM_1    1
46 #define LIST_NUM_2    2
47 #define TEST_VALUE    123
48 #define CHILDREN_NUM    3
49 #define WAIT_FOR_SHELL_OP_TIME    1
50 #define FATHER_WAIT_TIME    (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1))
51 
52 #define ACCESS_TOKEN_UID    3020
53 #define ACCESS_TOKEN_GRPID  3020
54 
55 #define ACCESS_TOKEN_OTHER_UID      1234
56 #define ACCESS_TOKEN_OTHER_GRPID    1234
57 
58 #define INVAL_TOKEN    0xffffffffffffffff
59 
60 int GetTokenid(unsigned long long *token);
61 int SetTokenid(unsigned long long *token);
62 int GetfTokenid(unsigned long long *ftoken);
63 int SetfTokenid(unsigned long long *ftoken);
64 
65 void SetUidAndGrp();
66 void SetUidAndGrpOther();
67 void GetCurToken(unsigned long long *token);
68 void SetRandTokenAndCheck(const unsigned long long *dataToken);
69 void TokenTest(unsigned long long *dataToken);
70 void ThreadTest(unsigned long long *dataToken);
71 int AccessTokenidThreadTest(uint8_t *dataToken);
72 int AccessTokenidGrpTest(uint8_t *dataToken);
73 int AccessTokenidGrpTestOther(uint8_t *dataToken);
74 
75 void GetCurfToken(unsigned long long *ftoken);
76 void SetRandfTokenAndCheck(const unsigned long long *dataFtoken);
77 void FTokenTest(unsigned long long *dataFtoken);
78 void ThreadTest(unsigned long long *dataFtoken);
79 int AccessfTokenidThreadTest(uint8_t *dataFtoken);
80 int AccessfTokenidGrpTest(uint8_t *dataFtoken);
81 int AccessfTokenidGrpTestOther(uint8_t *dataFtoken);
82 bool SetfTokenidCmdFuzzTest(const uint8_t *data, size_t size);
83 bool GetfTokenidCmdFuzzTest(const uint8_t *data, size_t size);
84 bool SetTokenidCmdFuzzTest(const uint8_t *data, size_t size);
85 bool GetTokenidCmdFuzzTest(const uint8_t *data, size_t size);
86 } // namespace AccessToken
87 } // namespace Kernel
88 } // namespace OHOS
89 
90 #endif // ACCESSTOKENIDCOMMON_H
91