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 int32_t LoadPermissionJson(const char *fileName); 68 void DeinitPermissionJson(void); 69 int32_t CheckPermissionEntry(const char *sessionName, const SoftBusPermissionItem *pItem); 70 int32_t IsValidPkgName(int32_t uid, const char *pkgName); 71 SoftBusPermissionItem *CreatePermissionItem(int32_t permType, int32_t uid, int32_t pid, 72 const char *pkgName, uint32_t actions); 73 bool PermIsSecLevelPublic(const char *sessionName); 74 int32_t InitDynamicPermission(void); 75 int32_t AddDynamicPermission(int32_t callingUid, int32_t callingPid, const char *sessionName); 76 int32_t DeleteDynamicPermission(const char *sessionName); 77 int32_t CompareString(const char *src, const char *dest, bool regexp); 78 bool CheckDBinder(const char *sessionName); 79 80 #ifdef __cplusplus 81 #if __cplusplus 82 } 83 #endif /* __cplusplus */ 84 #endif /* __cplusplus */ 85 86 #endif /* PERMISSION_ENTRY_H */ 87