• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 SELINUX_PARAMETER_H
17 #define SELINUX_PARAMETER_H
18 
19 #pragma once
20 
21 #include <sys/socket.h>
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif
28 
29 typedef struct ParameterNode {
30     const char *paraName;
31     const char *paraContext;
32 } ParameterNode;
33 
34 typedef struct ParamContextsList {
35     struct ParameterNode info;
36     struct ParamContextsList *next;
37 } ParamContextsList;
38 
39 typedef struct SrcInfo {
40     int sockFd;
41     struct ucred uc;
42 } SrcInfo;
43 
44 /**
45  * @brief init param selinux
46  */
47 int InitParamSelinux(void);
48 
49 /**
50  * @brief get param context list, for context-named files generate
51  * free with DestroyParamList
52  *
53  * @return head of param context list
54  */
55 ParamContextsList *GetParamList(void);
56 
57 /**
58  * @brief destroy param list get from GetParamList
59  *
60  * @param list the head of contexts list
61  */
62 void DestroyParamList(ParamContextsList **list);
63 
64 /**
65  * @brief for a particular paraName, get its context
66  *
67  * @param paraName the name of param
68  *
69  * @return context for given paraName
70  */
71 const char *GetParamLabel(const char *paraName);
72 
73 #ifdef __cplusplus
74 #if __cplusplus
75 }
76 #endif /* __cplusplus */
77 #endif /* __cplusplus */
78 
79 #endif // SELINUX_PARAMETER_H
80