Remove API for setting allowed users for an app
[platform/core/security/security-manager.git] / src / include / security-manager.h
1 /*
2  *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Bartlomiej Grzelewski <b.grzelewski@samsung.com>
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License
17  *
18  *      Security Manager library header
19  */
20 /*
21  * @file        security-manager.h
22  * @author      Pawel Polawski (p.polawski@samsung.com)
23  * @version     1.0
24  * @brief       This file contains header of security-manager API
25  */
26
27 #ifndef SECURITY_MANAGER_H_
28 #define SECURITY_MANAGER_H_
29
30 #include <sys/types.h>
31
32 /**
33  * \name Return Codes
34  * exported by the foundation API.
35  * result codes begin with the start error code and extend into negative direction.
36  * @{
37 */
38 #define SECURITY_MANAGER_API_SUCCESS 0
39 /*! \brief   indicating the result of the one specific API is successful */
40 #define SECURITY_MANAGER_API_ERROR_SOCKET -1
41
42 /*! \brief   indicating the socket between client and Security Manager has been failed  */
43 #define SECURITY_MANAGER_API_ERROR_BAD_REQUEST -2
44
45 /*! \brief   indicating the response from Security Manager is malformed */
46 #define SECURITY_MANAGER_API_ERROR_BAD_RESPONSE -3
47
48 /*! \brief   indicating the requested service does not exist */
49 #define SECURITY_MANAGER_API_ERROR_NO_SUCH_SERVICE -4
50
51 /*! \brief   indicating requesting object is not exist */
52 #define SECURITY_MANAGER_API_ERROR_NO_SUCH_OBJECT -6
53
54 /*! \brief   indicating the authentication between client and server has been failed */
55 #define SECURITY_MANAGER_API_ERROR_AUTHENTICATION_FAILED -7
56
57 /*! \brief   indicating the API's input parameter is malformed */
58 #define SECURITY_MANAGER_API_ERROR_INPUT_PARAM -8
59
60 /*! \brief   indicating the output buffer size which is passed as parameter is too small */
61 #define SECURITY_MANAGER_API_ERROR_BUFFER_TOO_SMALL -9
62
63 /*! \brief   indicating system  is running out of memory state */
64 #define SECURITY_MANAGER_API_ERROR_OUT_OF_MEMORY -10
65
66 /*! \brief   indicating the access has been denied by Security Manager */
67 #define SECURITY_MANAGER_API_ERROR_ACCESS_DENIED -11
68
69 /*! \brief   indicating Security Manager has been failed for some reason */
70 #define SECURITY_MANAGER_API_ERROR_SERVER_ERROR -12
71
72 /*! \brief   indicating getting smack label from socket failed  */
73 #define SECURITY_MANAGER_API_ERROR_GETTING_SOCKET_LABEL_FAILED -21
74
75 /*! \brief   indicating getting smack label from file failed  */
76 #define SECURITY_MANAGER_API_ERROR_GETTING_FILE_LABEL_FAILED -22
77
78 /*! \brief   indicating setting smack label for file failed  */
79 #define SECURITY_MANAGER_API_ERROR_SETTING_FILE_LABEL_FAILED -23
80
81 /*! \brief   indicating file already exists  */
82 #define SECURITY_MANAGER_API_ERROR_FILE_EXIST -24
83
84 /*! \brief   indicating file does not exist  */
85 #define SECURITY_MANAGER_API_ERROR_FILE_NOT_EXIST -25
86
87 /*! \brief   indicating file open error  */
88 #define SECURITY_MANAGER_API_ERROR_FILE_OPEN_FAILED -26
89
90 /*! \brief   indicating file creation error  */
91 #define SECURITY_MANAGER_API_ERROR_FILE_CREATION_FAILED -27
92
93 /*! \brief   indicating file deletion error  */
94 #define SECURITY_MANAGER_API_ERROR_FILE_DELETION_FAILED -28
95
96 /*! \brief   indicating the error with unknown reason */
97 #define SECURITY_MANAGER_API_ERROR_UNKNOWN -255
98 /** @}*/
99
100
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
104
105 /*! \brief return code of API functions */
106 enum lib_retcode {
107     SECURITY_MANAGER_SUCCESS,
108     SECURITY_MANAGER_ERROR_UNKNOWN,
109     SECURITY_MANAGER_ERROR_INPUT_PARAM,
110     SECURITY_MANAGER_ERROR_MEMORY,
111     SECURITY_MANAGER_ERROR_REQ_NOT_COMPLETE
112 };
113
114 /*! \brief accesses types for application installation paths*/
115 enum app_install_path_type {
116     //accessible read-write only for applications with same package id
117     SECURITY_MANAGER_PATH_PRIVATE,
118     //read-write access for all applications
119     SECURITY_MANAGER_PATH_PUBLIC,
120     //read only access for all applications
121     SECURITY_MANAGER_PATH_PUBLIC_RO,
122     //this is only for range limit
123     SECURITY_MANAGER_ENUM_END
124 };
125
126 /*! \brief data structure responsible for handling informations
127  * required to install / uninstall application */
128 struct app_inst_req;
129 typedef struct app_inst_req app_inst_req;
130
131 /*
132  * This function is responsible for initialize app_inst_req data structure
133  * It uses dynamic allocation inside and user responsibility is to call
134  * app_inst_req_free() for freeing allocated resources
135  *
136  * \param[in] Address of pointer for handle app_inst_req structure
137  * \return API return code or error code
138  */
139 int security_manager_app_inst_req_new(app_inst_req **pp_req);
140
141 /*
142  * This function is used to free resources allocated by calling app_inst_req_new()
143  *  \param[in] Pointer handling allocated app_inst_req structure
144  */
145 void security_manager_app_inst_req_free(app_inst_req *p_req);
146
147 /*
148  * This function is used to set up application identifier in app_inst_req structure
149  *
150  * \param[in] Pointer handling app_inst_req structure
151  * \param[in] Application identifier
152  * \return API return code or error code
153  */
154 int security_manager_app_inst_req_set_app_id(app_inst_req *p_req, const char *app_id);
155
156 /*
157  * This function is used to set up package identifier in app_inst_req structure
158  *
159  * \param[in] Pointer handling app_inst_req structure
160  * \param[in] Package identifier
161  * \return API return code or error code
162  */
163 int security_manager_app_inst_req_set_pkg_id(app_inst_req *p_req, const char *pkg_id);
164
165 /*
166  * This function is used to add privilege to app_inst_req structure,
167  * it can be called multiple times
168  *
169  * \param[in] Pointer handling app_inst_req structure
170  * \param[in] Application privilager
171  * \return API return code or error code
172  */
173 int security_manager_app_inst_req_add_privilege(app_inst_req *p_req, const char *privilege);
174
175 /*
176  * This function is used to add application path to app_inst_req structure,
177  * it can be called multiple times
178  *
179  * \param[in] Pointer handling app_inst_req structure
180  * \param[in] Application path
181  * \param[in] Application path type
182  * \return API return code or error code
183  */
184 int security_manager_app_inst_req_add_path(app_inst_req *p_req, const char *path, const int path_type);
185
186 /*
187  * This function is used to install application based on
188  * using filled up app_inst_req data structure
189  *
190  * \param[in] Pointer handling app_inst_req structure
191  * \return API return code or error code
192  */
193 int security_manager_app_install(const app_inst_req *p_req);
194
195 /*
196  * This function is used to uninstall application based on
197  * using filled up app_inst_req data structure
198  *
199  * \param[in] Pointer handling app_inst_req structure
200  * \return API return code or error code
201  */
202 int security_manager_app_uninstall(const app_inst_req *p_req);
203
204
205 #ifdef __cplusplus
206 }
207 #endif
208
209 #endif /* SECURITY_MANAGER_H_ */