Remove boost dependency
[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 <sys/types.h>
9
10 #include <filesystem>
11 #include <string>
12 #include <vector>
13
14 #include "common/installer_context.h"
15
16 namespace common_installer {
17
18 /**
19  * Adapter interface for external Security module.
20  *
21  * Adapter interface for external Security module used for registering
22  * package to security context
23  *
24  * \param context installer context contains necessary information
25  * \param error_message extra/detailed error message
26  *
27  * \return true if success
28  */
29 bool RegisterSecurityContextForManifest(
30         const common_installer::InstallerContext* context,
31         std::string* error_message);
32
33 /**
34  * Adapter interface for external Security module.
35  *
36  * Adapter interface for external Security module used for unregistering
37  * package from security context
38  *
39  * \param pkg_id pkgid of given package
40  * \param pkg_type type of given package*
41  * \param uid uid
42  * \param manifest pointer to manifest structure
43  * \param error_message extra/detailed error message
44  *
45  * \return true if success
46  */
47 bool UnregisterSecurityContextForManifest(const std::string& pkg_id,
48     const std::string& pkg_type, uid_t uid, manifest_x* manifest,
49     std::string* error_message);
50
51 /**
52  * Adapter interface for external Security module.
53  *
54  * Adapter interface for external Security module used for unregistering
55  * package from security context
56  *
57  * \param pkg_id pkgid of given package
58  * \param pkg_type type of given package
59  * \param uid uid
60  * \param error_message extra/detailed error message
61  * \param ignore_data_absence optional, default set to false, indicate if
62  *                            failure of querying appids for pkgid should return
63  *                            false or true
64  *
65  * \return true if success
66  */
67 bool UnregisterSecurityContextForPkgId(const std::string& pkg_id,
68     const std::string& pkg_type, uid_t uid, std::string* error_message,
69     bool ignore_data_absence = false);
70
71 /**
72  * Adapter interface for external Security module.
73  *
74  * Adapter interface for external Security module used for registering
75  * package path to security context
76  *
77  * \param pkg_id pkgid of given package
78  * \param pkg_type pkg type 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 std::string& pkg_type, const std::filesystem::path& path,
88     uid_t uid, 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 std::filesystem::path& path,
106     uid_t uid, std::string* error_message);
107
108 bool HasOwnerRwOtherRoPaths(const std::filesystem::path& path);
109
110 }  // namespace common_installer
111
112 #endif  // COMMON_SECURITY_REGISTRATION_H_