• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PERMISSION_ENTRY_H
17 #define PERMISSION_ENTRY_H
18 
19 #include "softbus_def.h"
20 #include "softbus_permission.h"
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 #define UNKNOWN_VALUE (-1)
29 
30 typedef enum {
31     UDID = 0,
32     UUID,
33     NETWORKID,
34 } DevId;
35 
36 typedef enum {
37     LEVEL_PRIVATE = 0,
38     LEVEL_PUBLIC,
39 } SecurityLevel;
40 
41 typedef struct {
42     int32_t permType;
43     int32_t uid;
44     int32_t pid;
45     char *pkgName;
46     uint32_t actions;
47 } SoftBusPermissionItem;
48 
49 typedef struct {
50     ListNode node;
51     int32_t type;
52     char pkgName[PKG_NAME_SIZE_MAX];
53     uint32_t actions;
54     int32_t uid;
55     int32_t pid;
56 } SoftBusAppInfo;
57 
58 typedef struct {
59     ListNode node;
60     char sessionName[SESSION_NAME_SIZE_MAX];
61     int32_t devId;
62     bool regexp;
63     int32_t secLevel;
64     ListNode appInfo;
65 } SoftBusPermissionEntry;
66 
67 typedef struct {
68     ListNode node;
69     char processName[PROCESS_NAME_SIZE_MAX];
70 } LnnProcessList;
71 
72 typedef struct {
73     ListNode node;
74     char interfaceName[INTERFACE_NAME_SIZE_MAX];
75     LnnProcessList processlist;
76 } LnnPermissionEntry;
77 
78 int32_t LoadPermissionJson(const char *fileName);
79 int32_t LoadLnnPermissionJson(const char *fileName);
80 void DeinitPermissionJson(void);
81 void DeinitLnnPermissionJson(void);
82 int32_t CheckLnnPermissionEntry(const char *interfaceName, const char *processName);
83 int32_t CheckPermissionEntry(const char *sessionName, const SoftBusPermissionItem *pItem);
84 int32_t IsValidPkgName(int32_t uid, const char *pkgName);
85 SoftBusPermissionItem *CreatePermissionItem(int32_t permType, int32_t uid, int32_t pid,
86     const char *pkgName, uint32_t actions);
87 bool PermIsSecLevelPublic(const char *sessionName);
88 int32_t InitDynamicPermission(void);
89 int32_t AddDynamicPermission(int32_t callingUid, int32_t callingPid, const char *sessionName);
90 int32_t DeleteDynamicPermission(const char *sessionName);
91 int32_t CompareString(const char *src, const char *dest, bool regexp);
92 bool CheckDBinder(const char *sessionName);
93 bool StrStartWith(const char *string, const char *target);
94 
95 #ifdef __cplusplus
96 #if __cplusplus
97 }
98 #endif /* __cplusplus */
99 #endif /* __cplusplus */
100 
101 #endif /* PERMISSION_ENTRY_H */
102