{"data/"},
{"shared/"},
{"shared/cache/"},
- {"shared/trusted/"},
};
+const char kTrustedDir[] = "shared/trusted";
const char kSkelAppDir[] = "/etc/skel/apps_rw";
const char kPackagePattern[] = R"(^[0-9a-zA-Z_-]+(\.?[0-9a-zA-Z_-]+)*$)";
const int32_t kPWBufSize = sysconf(_SC_GETPW_R_SIZE_MAX);
}
bool CreateDirectories(const bf::path& app_dir, const std::string& pkgid,
+ bool trusted,
uid_t uid, gid_t gid, const bool set_permissions) {
bf::path base_dir = app_dir / pkgid;
if (bf::exists(base_dir)) {
bs::error_code error;
std::vector<const char*> dirs(kEntries);
+ if (trusted)
+ dirs.push_back(kTrustedDir);
for (auto& entry : dirs) {
bf::path subpath = base_dir / entry;
bf::create_directories(subpath, error);
}
bool CreateUserDirectories(uid_t user, const std::string& pkgid,
+ bool trusted,
const std::string& apps_prefix, const bool set_permissions) {
struct passwd pwd;
struct passwd *pwd_result;
return false;
}
- if (!CreateDirectories(apps_rw, pkgid, pwd.pw_uid, pwd.pw_gid,
- set_permissions)) {
+ if (!CreateDirectories(apps_rw, pkgid, trusted,
+ pwd.pw_uid, pwd.pw_gid, set_permissions)) {
return false;
}
return true;
return GetExternalCardPath().string();
}
+bool PerformInternalDirectoryCreationForUser(uid_t user,
+ const std::string& pkgid,
+ bool trusted) {
+ const char* internal_storage_prefix = tzplatform_getenv(TZ_SYS_HOME);
+ const bool set_permissions = true;
+ if (!CreateUserDirectories(user, pkgid, trusted,
+ internal_storage_prefix, set_permissions))
+ return false;
+ return true;
+}
+
bool PerformExternalDirectoryCreationForUser(uid_t user,
const std::string& pkgid) {
bf::path storage_path = GetExternalCardPath();
+
+ // TODO(t.iwanek): trusted in this context means that we have signature
+ // this argument is not longer needed as all package must be signed
+ // so that trusted directory may be labeled correctly by security-manager in
+ // all cases. This parameter and its propagation should be removed.
+ bool trusted = true;
+
const bool set_permissions = false;
if (!bf::exists(storage_path)) {
LOG(WARNING) << "External storage (SD Card) is not mounted.";
}
}
- if (CreateUserDirectories(user, pkgid,
+ if (CreateUserDirectories(user, pkgid, trusted,
storage_apps_path.c_str(), set_permissions)) {
}
return true;
GetDirectoryPathForStorage(user, storage_apps_path.string()), pkgid);
}
+bool PerformInternalDirectoryCreationForAllUsers(const std::string& pkgid,
+ bool trusted) {
+ user_list list = GetUserList();
+ for (auto l : list) {
+ if (!PerformInternalDirectoryCreationForUser(std::get<0>(l),
+ pkgid,
+ trusted))
+ LOG(ERROR) << "Could not create internal storage directories for user: "
+ << std::get<0>(l);
+ }
+ return true;
+}
+
bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid) {
user_list list = GetUserList();
for (auto l : list) {
using PkgList = std::vector<PkgInfo>;
/**
+ * \brief Performs a creation of directories for specific user in internal storage
+ *
+ * \param pkgid id of package
+ * \param trusted is package trusted
+ * \param create_skel_directories flag
+ *
+ * \return true if succeed, false otherwise
+ */
+bool PerformInternalDirectoryCreationForUser(uid_t uid,
+ const std::string& pkgid,
+ bool trusted);
+
+/**
* \brief Performs a creation of directories for specific user in external storage
*
* \param pkgid id of package
const std::string& pkgid);
/**
+ * \brief Performs a creation of directories in internal storage
+ *
+ * \param pkgid id of package
+ * \param trusted is package trusted
+ * \param create_skel_directories flag
+ *
+ * \return true if succeed, false otherwise
+ *
+ */
+bool PerformInternalDirectoryCreationForAllUsers(const std::string& pkgid,
+ bool trusted);
+
+/**
* \brief Performs a creation of directories in external storage (eg. SD card)
*
* \param pkgid id of package