Policy update: server side implementation
[platform/core/security/security-manager.git] / src / common / include / service_impl.h
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Rafal Krypa <r.krypa@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 /*
19  * @file        service_impl.h
20  * @author      Rafal Krypa <r.krypa@samsung.com>
21  * @brief       Implementation of the service methods
22  */
23
24 #ifndef _SECURITY_MANAGER_SERVICE_IMPL_
25 #define _SECURITY_MANAGER_SERVICE_IMPL_
26
27 #include <unistd.h>
28 #include <sys/types.h>
29
30 #include <unordered_set>
31
32 #include "security-manager.h"
33
34 namespace SecurityManager {
35 namespace ServiceImpl {
36
37 /**
38  * Process application installation request.
39  *
40  * @param[in] req installation request
41  * @param[in] uid id of the requesting user
42  *
43  * @return API return code, as defined in protocols.h
44  */
45 int appInstall(const app_inst_req &req, uid_t uid);
46
47 /**
48  * Process application uninstallation request.
49  *
50  * @param[in] req uninstallation request
51  * @param[in] uid id of the requesting user
52  *
53  * @return API return code, as defined in protocols.h
54  */
55 int appUninstall(const std::string &appId, uid_t uid);
56
57 /**
58  * Process package id query.
59  * Retrieves the package id associated with given application id.
60  *
61  * @param[in] appId application identifier
62  * @param[out] pkgId returned package identifier
63  *
64  * @return API return code, as defined in protocols.h
65  */
66 int getPkgId(const std::string &appId, std::string &pkgId);
67
68 /**
69  * Process query for supplementary groups allowed for the application.
70  * For given appId and uid, calculate allowed privileges that give
71  * direct access to file system resources. For each permission Cynara will be
72  * queried.
73  * Returns set of group ids that are permitted.
74  *
75  * @param[in]  appId application identifier
76  * @param[in]  uid id of the requesting user
77  * @param[in]  pid id of the requesting process (to construct Cynara session id)
78  * @param[out] gids returned set of allowed group ids
79  *
80  * @return API return code, as defined in protocols.h
81  */
82 int getAppGroups(const std::string &appId, uid_t uid, pid_t pid, std::unordered_set<gid_t> &gids);
83
84 /**
85  * Process user adding request.
86  *
87  * @param[in] uidAdded uid of newly created user
88  * @param[in] userType type of newly created user
89  * @param[in] uid uid of requesting user
90  *
91  * @return API return code, as defined in protocols.h
92  */
93 int userAdd(uid_t uidAdded, int userType, uid_t uid);
94
95 /**
96  * Process user deletion request.
97  *
98  * @param[in] uidDeleted uid of removed user
99  * @param[in] uid uid of requesting user
100  *
101  * @return API return code, as defined in protocols.h
102  */
103 int userDelete(uid_t uidDeleted, uid_t uid);
104
105 /**
106  * Update policy in Cynara - proper privilege: http://tizen.org/privilege/systemsettings.admin
107  * is needed for this to succeed
108  *
109  * @param[in] policyEntries vector of policy chunks with instructions
110  * @param[in] uid identifier of requesting user
111  * @param[in] pid PID of requesting process
112  * @param[in] smackLabel smack label of requesting app
113  *
114  * @return API return code, as defined in protocols.h
115  */
116 int policyUpdate(const std::vector<policy_entry> &policyEntries, uid_t uid, pid_t pid, const std::string &smackLabel);
117 } /* namespace ServiceImpl */
118 } /* namespace SecurityManager */
119
120 #endif /* _SECURITY_MANAGER_SERVICE_IMPL_ */