Fix smack labeling for lib rpk
[platform/core/appfw/app-installers.git] / src / common / security_registration.h
1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMMON_SECURITY_REGISTRATION_H_
6 #define COMMON_SECURITY_REGISTRATION_H_
7
8 #include <boost/filesystem/path.hpp>
9
10 #include <sys/types.h>
11
12 #include <string>
13 #include <vector>
14
15 #include "common/installer_context.h"
16
17 namespace common_installer {
18
19 /**
20  * Adapter interface for external Security module.
21  *
22  * Adapter interface for external Security module used for registering
23  * package to security context
24  *
25  * \param context installer context contains necessary information
26  * \param error_message extra/detailed error message
27  *
28  * \return true if success
29  */
30 bool RegisterSecurityContextForManifest(
31         const common_installer::InstallerContext* context,
32         std::string* error_message);
33
34 /**
35  * Adapter interface for external Security module.
36  *
37  * Adapter interface for external Security module used for unregistering
38  * package from security context
39  *
40  * \param pkg_id pkgid of given package
41  * \param pkg_type type of given package*
42  * \param uid uid
43  * \param manifest pointer to manifest structure
44  * \param error_message extra/detailed error message
45  *
46  * \return true if success
47  */
48 bool UnregisterSecurityContextForManifest(const std::string& pkg_id,
49     const std::string& pkg_type, uid_t uid, manifest_x* manifest,
50     std::string* error_message);
51
52 /**
53  * Adapter interface for external Security module.
54  *
55  * Adapter interface for external Security module used for unregistering
56  * package from security context
57  *
58  * \param pkg_id pkgid of given package
59  * \param pkg_type type of given package
60  * \param uid uid
61  * \param error_message extra/detailed error message
62  * \param ignore_data_absence optional, default set to false, indicate if
63  *                            failure of querying appids for pkgid should return
64  *                            false or true
65  *
66  * \return true if success
67  */
68 bool UnregisterSecurityContextForPkgId(const std::string& pkg_id,
69     const std::string& pkg_type, uid_t uid, std::string* error_message,
70     bool ignore_data_absence = false);
71
72 /**
73  * Adapter interface for external Security module.
74  *
75  * Adapter interface for external Security module used for registering
76  * package path to security context
77  *
78  * \param pkg_id pkgid of given package
79  * \param pkg_type pkg type of given package
80  * \param path path for registering
81  * \param uid uid
82  * \param is_readonly_pkg RO package flag
83  * \param error_message extra/detailed error message
84  *
85  * \return true if success
86  */
87 bool RegisterSecurityContextForPath(const std::string &pkg_id,
88     const std::string& pkg_type, const boost::filesystem::path& path,
89     uid_t uid, bool is_readonly_pkg, std::string* error_message);
90
91 /**
92  * Adapter interface for external Security module.
93  *
94  * Adapter interface for external Security module used for registering
95  * package external paths to security context
96  *
97  * \param pkg_id pkgid of given package
98  * \param pkg_type pkg type of given package
99  * \param path path for registering
100  * \param uid uid
101  * \param error_message extra/detailed error message
102  *
103  * \return true if success
104  */
105 bool RegisterSecurityContextForPathExternalOnly(const std::string &pkg_id,
106     const std::string &pkg_type, const boost::filesystem::path& path,
107     uid_t uid, std::string* error_message);
108
109 bool HasOwnerRwOtherRoPaths(const boost::filesystem::path& path);
110
111 }  // namespace common_installer
112
113 #endif  // COMMON_SECURITY_REGISTRATION_H_