2 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Bartlomiej Grzelewski <b.grzelewski@samsung.com>
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
18 * Security Manager library header
21 * @file security-manager.h
22 * @author Pawel Polawski (p.polawski@samsung.com)
24 * @brief This file contains header of security-manager API
27 #ifndef SECURITY_MANAGER_H_
28 #define SECURITY_MANAGER_H_
30 #include <sys/types.h>
34 * exported by the foundation API.
35 * result codes begin with the start error code and extend into negative direction.
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
42 /*! \brief indicating the socket between client and Security Manager has been failed */
43 #define SECURITY_MANAGER_API_ERROR_BAD_REQUEST -2
45 /*! \brief indicating the response from Security Manager is malformed */
46 #define SECURITY_MANAGER_API_ERROR_BAD_RESPONSE -3
48 /*! \brief indicating the requested service does not exist */
49 #define SECURITY_MANAGER_API_ERROR_NO_SUCH_SERVICE -4
51 /*! \brief indicating requesting object is not exist */
52 #define SECURITY_MANAGER_API_ERROR_NO_SUCH_OBJECT -6
54 /*! \brief indicating the authentication between client and server has been failed */
55 #define SECURITY_MANAGER_API_ERROR_AUTHENTICATION_FAILED -7
57 /*! \brief indicating the API's input parameter is malformed */
58 #define SECURITY_MANAGER_API_ERROR_INPUT_PARAM -8
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
63 /*! \brief indicating system is running out of memory state */
64 #define SECURITY_MANAGER_API_ERROR_OUT_OF_MEMORY -10
66 /*! \brief indicating the access has been denied by Security Manager */
67 #define SECURITY_MANAGER_API_ERROR_ACCESS_DENIED -11
69 /*! \brief indicating Security Manager has been failed for some reason */
70 #define SECURITY_MANAGER_API_ERROR_SERVER_ERROR -12
72 /*! \brief indicating getting smack label from socket failed */
73 #define SECURITY_MANAGER_API_ERROR_GETTING_SOCKET_LABEL_FAILED -21
75 /*! \brief indicating getting smack label from file failed */
76 #define SECURITY_MANAGER_API_ERROR_GETTING_FILE_LABEL_FAILED -22
78 /*! \brief indicating setting smack label for file failed */
79 #define SECURITY_MANAGER_API_ERROR_SETTING_FILE_LABEL_FAILED -23
81 /*! \brief indicating file already exists */
82 #define SECURITY_MANAGER_API_ERROR_FILE_EXIST -24
84 /*! \brief indicating file does not exist */
85 #define SECURITY_MANAGER_API_ERROR_FILE_NOT_EXIST -25
87 /*! \brief indicating file open error */
88 #define SECURITY_MANAGER_API_ERROR_FILE_OPEN_FAILED -26
90 /*! \brief indicating file creation error */
91 #define SECURITY_MANAGER_API_ERROR_FILE_CREATION_FAILED -27
93 /*! \brief indicating file deletion error */
94 #define SECURITY_MANAGER_API_ERROR_FILE_DELETION_FAILED -28
96 /*! \brief indicating the error with unknown reason */
97 #define SECURITY_MANAGER_API_ERROR_UNKNOWN -255
105 /*! \brief return code of API functions */
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
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
126 /*! \brief data structure responsible for handling informations
127 * required to install / uninstall application */
129 typedef struct app_inst_req app_inst_req;
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
136 * \param[in] Address of pointer for handle app_inst_req structure
137 * \return API return code or error code
139 int security_manager_app_inst_req_new(app_inst_req **pp_req);
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
145 void security_manager_app_inst_req_free(app_inst_req *p_req);
148 * This function is used to set up application identifier in app_inst_req structure
150 * \param[in] Pointer handling app_inst_req structure
151 * \param[in] Application identifier
152 * \return API return code or error code
154 int security_manager_app_inst_req_set_app_id(app_inst_req *p_req, const char *app_id);
157 * This function is used to set up package identifier in app_inst_req structure
159 * \param[in] Pointer handling app_inst_req structure
160 * \param[in] Package identifier
161 * \return API return code or error code
163 int security_manager_app_inst_req_set_pkg_id(app_inst_req *p_req, const char *pkg_id);
166 * This function is used to add privilege to app_inst_req structure,
167 * it can be called multiple times
169 * \param[in] Pointer handling app_inst_req structure
170 * \param[in] Application privilager
171 * \return API return code or error code
173 int security_manager_app_inst_req_add_privilege(app_inst_req *p_req, const char *privilege);
176 * This function is used to add application path to app_inst_req structure,
177 * it can be called multiple times
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
184 int security_manager_app_inst_req_add_path(app_inst_req *p_req, const char *path, const int path_type);
187 * This function is used to install application based on
188 * using filled up app_inst_req data structure
190 * \param[in] Pointer handling app_inst_req structure
191 * \return API return code or error code
193 int security_manager_app_install(const app_inst_req *p_req);
196 * This function is used to uninstall application based on
197 * using filled up app_inst_req data structure
199 * \param[in] Pointer handling app_inst_req structure
200 * \return API return code or error code
202 int security_manager_app_uninstall(const app_inst_req *p_req);
209 #endif /* SECURITY_MANAGER_H_ */