Rewrite and fix CynaraAdmin::SetPolicies
[platform/core/security/security-manager.git] / src / common / include / master-req.h
1 /*
2  *  Copyright (c) 2015 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 /*
20  * @file        master-req.h
21  * @author      Lukasz Kostyra <l.kostyra@samsung.com>
22  * @brief       Master request calls declaration
23  */
24
25 #ifndef _SECURITY_MANAGER_MASTER_REQ_
26 #define _SECURITY_MANAGER_MASTER_REQ_
27
28 #include <string>
29 #include <vector>
30
31 #include "protocols.h"
32
33
34 namespace SecurityManager {
35 namespace MasterReq {
36
37 /**
38  * Forwards Cynara Policy Update request to Master Service.
39  *
40  * @param[in]  appID            Application ID
41  * @param[in]  uidstr           String containing user identifier
42  * @param[in]  privileges       Currently enabled privileges for the application
43  *
44  * @see CynaraAdmin::UpdateAppPolicy
45  */
46 int CynaraPolicyUpdate(const std::string &appId, const std::string &uidstr,
47                        const std::vector<std::string> &privileges);
48
49 /**
50  * Forwards Cynara user initialization to Master service.
51  *
52  * @param[in]  uidAdded New user UID
53  * @param[in]  userType Type of user, enumerated in security-manager.h
54  * @return API return code, as defined in protocols.h
55  *
56  * @see CynaraAdmin::UserInit
57  */
58 int CynaraUserInit(const uid_t uidAdded, int userType);
59
60 /**
61  * Forwards Cynara user removal to Master service.
62  *
63  * @param[in] uidDeleted Removed user UID
64  * @return API return code, as defined in protocols.h
65  *
66  * @see CynaraAdmin::UserRemove
67  */
68 int CynaraUserRemove(const uid_t uidDeleted);
69
70 /**
71  * Forwards SMACK rule installation to Master service.
72  *
73  * @param[in]  appId       ID of application being removed
74  * @param[in]  pkgId       ID of package being removed
75  * @param[in]  pkgContents A list of all applications in the package
76  * @return API return code, as defined in protocols.h
77  *
78  * @see SmackRules::installApplicationRules
79  */
80 int SmackInstallRules(const std::string &appId, const std::string &pkgId,
81                       const std::vector<std::string> &pkgContents);
82
83 /**
84  * Forwards SMACK rule removal to Master service.
85  *
86  * @param[in]  appId       ID of application being removed
87  * @param[in]  pkgId       ID of package being removed
88  * @param[in]  pkgContents A list of all applications in the package
89  * @param[in]  removePkg   Flag stating if entire package should be removed
90  * @return API return code, as defined in protocols.h
91  *
92  * @see SmackRules::uninstallPackageRules, SmackRules::uninstallApplicationRules
93  */
94 int SmackUninstallRules(const std::string &appId, const std::string &pkgId,
95                         const std::vector<std::string> &pkgContents, const bool removePkg);
96
97 /**
98  * Forwards policyUpdate API to Master. Arguments are the same as policyUpdate.
99  *
100  * @return API return code, as defined in protocols.h
101  *
102  * @see ServiceImpl::policyUpdate
103  */
104 int PolicyUpdate(const std::vector<policy_entry> &policyEntries, uid_t uid, pid_t pid,
105                  const std::string &smackLabel);
106
107 /**
108  * Forwards getConfiguredPolicy API to Master. Arguments are the same as getConfiguredPolicy.
109  *
110  * @return API return code, as defined in protocols.h
111  *
112  * @see ServiceImpl::getConfiguredPolicy
113  */
114 int GetConfiguredPolicy(bool forAdmin, const policy_entry &filter, uid_t uid, pid_t pid,
115                         const std::string &smackLabel, std::vector<policy_entry> &policyEntries);
116
117 /**
118  * Forwards getPolicy API to Master. Arguments are the same as getPolicy.
119  *
120  * @return API return code, as defined in protocols.h
121  *
122  * @see ServiceImpl::getPolicy
123  */
124 int GetPolicy(const policy_entry &filter, uid_t uid, pid_t pid, const std::string &smackLabel,
125               std::vector<policy_entry> &policyEntries);
126
127 /**
128  * Forwards policyGetDesc API to Master. Arguments are the same as policyGetDesc.
129  *
130  * @return API return code, as defined in protocols.h
131  *
132  * @see ServiceImpl::policyGetDesc
133  */
134 int PolicyGetDesc(std::vector<std::string> &descriptions);
135
136 } // namespace MasterReq
137 } // namespace SecurityManager
138
139 #endif // _SECURITY_MANAGER_MASTER_REQ_