9eb1227cb5e133bf1b1eb36c4af632babd55f028
[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 path path for registering
80  * \param uid uid
81  * \param is_readonly_pkg RO package flag
82  * \param error_message extra/detailed error message
83  *
84  * \return true if success
85  */
86 bool RegisterSecurityContextForPath(const std::string &pkg_id,
87     const boost::filesystem::path& path, uid_t uid,
88     bool is_readonly_pkg, std::string* error_message);
89
90 /**
91  * Adapter interface for external Security module.
92  *
93  * Adapter interface for external Security module used for registering
94  * package external paths to security context
95  *
96  * \param pkg_id pkgid of given package
97  * \param pkg_type pkg type of given package
98  * \param path path for registering
99  * \param uid uid
100  * \param error_message extra/detailed error message
101  *
102  * \return true if success
103  */
104 bool RegisterSecurityContextForPathExternalOnly(const std::string &pkg_id,
105     const std::string &pkg_type, const boost::filesystem::path& path,
106     uid_t uid, std::string* error_message);
107
108 bool HasOwnerRwOtherRoPaths(const boost::filesystem::path& path);
109
110 }  // namespace common_installer
111
112 #endif  // COMMON_SECURITY_REGISTRATION_H_