Clean up author_id parameter and shared_dirs API 16/74816/4
authorTomasz Iwanek <t.iwanek@samsung.com>
Wed, 15 Jun 2016 15:13:20 +0000 (17:13 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Fri, 24 Jun 2016 07:19:45 +0000 (00:19 -0700)
Change-Id: I9bd22d902994aa618d35e48b0b9ff17724b98658

src/common/shared_dirs.cc
src/common/shared_dirs.h

index 95c1fcf..aa5b857 100644 (file)
@@ -58,9 +58,9 @@ const std::vector<const char*> kEntries = {
   {"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);
@@ -174,7 +174,6 @@ bool SetPackageDirectoryOwnerAndPermissions(const bf::path& subpath, uid_t uid,
 }
 
 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)) {
@@ -184,8 +183,6 @@ bool CreateDirectories(const bf::path& app_dir, const std::string& pkgid,
 
   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);
@@ -225,7 +222,6 @@ bf::path GetDirectoryPathForStorage(uid_t user, std::string apps_prefix) {
 }
 
 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;
@@ -253,8 +249,8 @@ bool CreateUserDirectories(uid_t user, const std::string& pkgid,
     return false;
   }
 
-  if (!CreateDirectories(apps_rw, pkgid, trusted,
-      pwd.pw_uid, pwd.pw_gid, set_permissions)) {
+  if (!CreateDirectories(apps_rw, pkgid, pwd.pw_uid, pwd.pw_gid,
+                         set_permissions)) {
     return false;
   }
   return true;
@@ -312,27 +308,9 @@ std::string GetDirectoryPathForExternalStorage() {
   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.";
@@ -350,7 +328,7 @@ bool PerformExternalDirectoryCreationForUser(uid_t user,
     }
   }
 
-  if (CreateUserDirectories(user, pkgid, trusted,
+  if (CreateUserDirectories(user, pkgid,
                             storage_apps_path.c_str(), set_permissions)) {
   }
   return true;
@@ -369,19 +347,6 @@ bool PerformExternalDirectoryDeletionForUser(uid_t user,
       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) {
index c992944..f45dbae 100644 (file)
@@ -27,19 +27,6 @@ struct PkgInfo {
 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
@@ -62,19 +49,6 @@ bool PerformExternalDirectoryDeletionForUser(uid_t user,
                                             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