2 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Rafal Krypa <r.krypa@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
20 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
22 * @brief This file contains list of all protocols suported by security-manager.
25 #ifndef _SECURITY_MANAGER_PROTOCOLS_
26 #define _SECURITY_MANAGER_PROTOCOLS_
28 #include <sys/types.h>
31 #include <dpl/serialization.h>
35 * exported by the foundation API.
36 * result codes begin with the start error code and extend into negative direction.
40 /*! \brief indicating the result of the one specific API is successful */
41 #define SECURITY_MANAGER_API_SUCCESS 0
43 /*! \brief indicating the socket between client and Security Manager has been failed */
44 #define SECURITY_MANAGER_API_ERROR_SOCKET -1
46 /*! \brief indicating the request to Security Manager is malformed */
47 #define SECURITY_MANAGER_API_ERROR_BAD_REQUEST -2
49 /*! \brief indicating the response from Security Manager is malformed */
50 #define SECURITY_MANAGER_API_ERROR_BAD_RESPONSE -3
52 /*! \brief indicating the requested service does not exist */
53 #define SECURITY_MANAGER_API_ERROR_NO_SUCH_SERVICE -4
55 /*! \brief indicating requesting object is not exist */
56 #define SECURITY_MANAGER_API_ERROR_NO_SUCH_OBJECT -6
58 /*! \brief indicating the authentication between client and server has been failed */
59 #define SECURITY_MANAGER_API_ERROR_AUTHENTICATION_FAILED -7
61 /*! \brief indicating the API's input parameter is malformed */
62 #define SECURITY_MANAGER_API_ERROR_INPUT_PARAM -8
64 /*! \brief indicating the output buffer size which is passed as parameter is too small */
65 #define SECURITY_MANAGER_API_ERROR_BUFFER_TOO_SMALL -9
67 /*! \brief indicating system is running out of memory state */
68 #define SECURITY_MANAGER_API_ERROR_OUT_OF_MEMORY -10
70 /*! \brief indicating the access has been denied by Security Manager */
71 #define SECURITY_MANAGER_API_ERROR_ACCESS_DENIED -11
73 /*! \brief indicating Security Manager has been failed for some reason */
74 #define SECURITY_MANAGER_API_ERROR_SERVER_ERROR -12
76 /*! \brief indicating getting smack label from socket failed */
77 #define SECURITY_MANAGER_API_ERROR_GETTING_SOCKET_LABEL_FAILED -21
79 /*! \brief indicating getting smack label from file failed */
80 #define SECURITY_MANAGER_API_ERROR_GETTING_FILE_LABEL_FAILED -22
82 /*! \brief indicating setting smack label for file failed */
83 #define SECURITY_MANAGER_API_ERROR_SETTING_FILE_LABEL_FAILED -23
85 /*! \brief indicating file already exists */
86 #define SECURITY_MANAGER_API_ERROR_FILE_EXIST -24
88 /*! \brief indicating file does not exist */
89 #define SECURITY_MANAGER_API_ERROR_FILE_NOT_EXIST -25
91 /*! \brief indicating file open error */
92 #define SECURITY_MANAGER_API_ERROR_FILE_OPEN_FAILED -26
94 /*! \brief indicating file creation error */
95 #define SECURITY_MANAGER_API_ERROR_FILE_CREATION_FAILED -27
97 /*! \brief indicating file deletion error */
98 #define SECURITY_MANAGER_API_ERROR_FILE_DELETION_FAILED -28
100 /*! \brief indicating the error with unknown reason */
101 #define SECURITY_MANAGER_API_ERROR_UNKNOWN -255
105 struct app_inst_req {
108 std::vector<std::string> privileges;
109 std::vector<std::pair<std::string, int>> appPaths;
118 namespace SecurityManager {
120 extern char const * const SERVICE_SOCKET;
122 enum class SecurityModuleCall
132 GET_CONF_POLICY_ADMIN,
133 GET_CONF_POLICY_SELF,
137 } // namespace SecurityManager
139 using namespace SecurityManager;
141 struct policy_entry : ISerializable {
142 std::string user; // uid converted to string
143 std::string appId; // application identifier
144 std::string privilege; // Cynara privilege
145 std::string currentLevel; // current level of privielege, or level asked to be set in privacy manager bucket
146 std::string maxLevel; // holds read maximum policy status or status to be set in admin bucket
148 policy_entry() : user(""), appId(""), privilege(""), currentLevel(""), maxLevel("")
151 policy_entry(IStream &stream) {
152 Deserialization::Deserialize(stream, user);
153 Deserialization::Deserialize(stream, appId);
154 Deserialization::Deserialize(stream, privilege);
155 Deserialization::Deserialize(stream, currentLevel);
156 Deserialization::Deserialize(stream, maxLevel);
159 virtual void Serialize(IStream &stream) const {
160 Serialization::Serialize(stream, user);
161 Serialization::Serialize(stream, appId);
162 Serialization::Serialize(stream, privilege);
163 Serialization::Serialize(stream, currentLevel);
164 Serialization::Serialize(stream, maxLevel);
168 typedef struct policy_entry policy_entry;
171 struct policy_update_req {
172 std::vector<const policy_entry *> units;
176 #endif // _SECURITY_MANAGER_PROTOCOLS_