}
bool PreparePathRequest(const std::string& pkg_id,
- const boost::filesystem::path& path, uid_t uid, path_req* req,
- std::string* error_message) {
+ const boost::filesystem::path& path, uid_t uid, bool is_userdir,
+ path_req* req, std::string* error_message) {
if (pkg_id.empty() || path.empty()) {
LOG(ERROR) << "Pkgid or path is empty. Both values must be set";
return false;
}
app_install_type type =
- (getuid() == 0) ? SM_APP_INSTALL_PRELOADED : SM_APP_INSTALL_GLOBAL;
+ is_userdir ? SM_APP_INSTALL_LOCAL :
+ getuid() == 0 ? SM_APP_INSTALL_PRELOADED :
+ SM_APP_INSTALL_GLOBAL;
error = security_manager_path_req_set_install_type(req, type);
if (error != SECURITY_MANAGER_SUCCESS) {
}
bool RegisterSecurityContextForPath(const std::string &pkg_id,
- const boost::filesystem::path& path, uid_t uid,
+ const boost::filesystem::path& path, uid_t uid, bool is_userdir,
std::string* error_message) {
path_req* req;
int error = security_manager_path_req_new(&req);
return false;
}
- if (!PreparePathRequest(pkg_id, path, uid, req, error_message)) {
+ if (!PreparePathRequest(pkg_id, path, uid, is_userdir, req, error_message)) {
LOG(ERROR) << "Failed while preparing security_manager_app_inst_req";
security_manager_path_req_free(req);
return false;
* \param pkg_id pkgid 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,
+ const boost::filesystem::path& path, uid_t uid, bool is_userdir,
std::string* error_message);
} // namespace common_installer
std::string error_message;
if (!RegisterSecurityContextForPath(pkgid, path,
- tzplatform_getuid(TZ_SYS_GLOBALAPP_USER), &error_message)) {
+ tzplatform_getuid(TZ_SYS_GLOBALAPP_USER), false, &error_message)) {
LOG(ERROR) << "Failed to register security context for path: " << path
<< ", error_message: " << error_message;
return false;
std::get<0>(l), std::get<1>(l)))
return false;
}
+ std::string error_message;
+ if (!RegisterSecurityContextForPath(pkgid, dst, std::get<0>(l), true,
+ &error_message)) {
+ LOG(ERROR) << "Failed to register security context for path: " << dst
+ << ", error_message: " << error_message;
+ return false;
+ }
}
return true;
}