#ifndef COMMON_SECURITY_REGISTRATION_H_
#define COMMON_SECURITY_REGISTRATION_H_
-#include <boost/filesystem/path.hpp>
-
#include <sys/types.h>
+#include <filesystem>
#include <string>
#include <vector>
namespace common_installer {
-enum class SecurityAppInstallType { None, Local, Global, Preload };
-
/**
* Adapter interface for external Security module.
*
* Adapter interface for external Security module used for registering
- * application to security context
+ * package to security context
*
- * \param app_id id of given application
- * \param pkg_id id of given package
- * \param author_id unique author id of given package
- * \param api_version api-version of given package
- * \param path path of installed package
- * \param uid uid
- * \param privileges pointer to manifest structure
+ * \param context installer context contains necessary information
* \param error_message extra/detailed error message
*
* \return true if success
*/
-bool RegisterSecurityContext(const std::string& app_id,
- const std::string& pkg_id, const std::string& author_id,
- const std::string& api_version, SecurityAppInstallType type,
- const boost::filesystem::path& path, uid_t uid,
- const std::vector<std::string>& privileges,
- std::string* error_message);
+bool RegisterSecurityContextForManifest(
+ const common_installer::InstallerContext* context,
+ std::string* error_message);
/**
* Adapter interface for external Security module.
*
* Adapter interface for external Security module used for unregistering
- * application from security context
- *
- * \param app_id id of given application
- * \param pkg_id id of given package
- * \param uid uid
- * \param error_message extra/detailed error message
- *
- * \return true if success
- */
-bool UnregisterSecurityContext(const std::string& app_id,
- const std::string& pkg_id, uid_t uid, std::string* error_message);
-
-/**
- * Adapter interface for external Security module.
- *
- * Adapter interface for external Security module used for registering
- * package to security context
+ * package from security context
*
* \param pkg_id pkgid of given package
- * \param path path of installed package
+ * \param pkg_type type of given package*
* \param uid uid
- * \param cert_info pointer to certificate info
* \param manifest pointer to manifest structure
* \param error_message extra/detailed error message
*
* \return true if success
*/
-bool RegisterSecurityContextForManifest(const std::string& pkg_id,
- const boost::filesystem::path& path, uid_t uid,
- common_installer::CertificateInfo* cert_info, manifest_x* manifest,
+bool UnregisterSecurityContextForManifest(const std::string& pkg_id,
+ const std::string& pkg_type, uid_t uid, manifest_x* manifest,
std::string* error_message);
/**
* package from security context
*
* \param pkg_id pkgid of given package
+ * \param pkg_type type of given package
* \param uid uid
- * \param manifest pointer to manifest structure
* \param error_message extra/detailed error message
+ * \param ignore_data_absence optional, default set to false, indicate if
+ * failure of querying appids for pkgid should return
+ * false or true
*
* \return true if success
*/
-bool UnregisterSecurityContextForManifest(const std::string& pkg_id, uid_t uid,
- manifest_x* manifest, std::string* error_message);
+bool UnregisterSecurityContextForPkgId(const std::string& pkg_id,
+ const std::string& pkg_type, uid_t uid, std::string* error_message,
+ bool ignore_data_absence = false);
/**
* Adapter interface for external Security module.
*
- * Adapter interface for external Security module used for unregistering
- * package from security context
+ * Adapter interface for external Security module used for registering
+ * package path to security context
*
* \param pkg_id pkgid of given package
+ * \param pkg_type pkg type of given package
+ * \param path path for registering
* \param uid uid
+ * \param is_readonly_pkg RO package flag
* \param error_message extra/detailed error message
*
* \return true if success
*/
-bool UnregisterSecurityContextForPkgId(const std::string& pkg_id, uid_t uid,
- std::string* error_message);
+bool RegisterSecurityContextForPath(const std::string &pkg_id,
+ const std::string& pkg_type, const std::filesystem::path& path,
+ uid_t uid, bool is_readonly_pkg, std::string* error_message);
/**
* Adapter interface for external Security module.
*
* Adapter interface for external Security module used for registering
- * package path to security context
+ * package external paths to security context
*
* \param pkg_id pkgid of given package
+ * \param pkg_type pkg type of given package
* \param path path for registering
* \param uid uid
- * \param is_userdir if the path is user directory or not
* \param error_message extra/detailed error message
*
* \return true if success
*/
-bool RegisterSecurityContextForPath(const std::string &pkg_id,
- const boost::filesystem::path& path, uid_t uid, bool is_userdir,
- std::string* error_message);
+bool RegisterSecurityContextForPathExternalOnly(const std::string &pkg_id,
+ const std::string &pkg_type, const std::filesystem::path& path,
+ uid_t uid, std::string* error_message);
+
+bool HasOwnerRwOtherRoPaths(const std::filesystem::path& path);
} // namespace common_installer