Unify privilege representation
[platform/core/test/security-tests.git] / src / common / app_install_helper.h
index e238261..fbd943c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ struct AppInstallHelper {
                      bool isLocal,
                      uid_t uid,
                      std::string version = std::string())
-      : m_appName(appNamePrefix), m_pkgName(pkgNamePrefix), m_isLocal(isLocal), m_uidGid(uid), m_version(version),
+      : m_appName(appNamePrefix + "_app_id"), m_pkgName(pkgNamePrefix + "_pkg_id"), m_isLocal(isLocal), m_uidGid(uid), m_version(version),
         m_installType(SM_APP_INSTALL_NONE), m_isHybrid(false), m_creatorPid(getpid())
     {}
 
@@ -74,8 +74,8 @@ struct AppInstallHelper {
     AppInstallHelper(AppInstallHelper &&other);
 
     // App info getters and setters
-    std::string getAppId() const;
-    std::string getPkgId() const;
+    const std::string& getAppId() const;
+    const std::string& getPkgId() const;
     int getUID() const;
     int getGID() const;
     void setVersion(const std::string &version);
@@ -90,7 +90,9 @@ struct AppInstallHelper {
     enum RootType {
         BASE,
         SKEL,
-        EXTENDED
+        EXTENDED,
+        SHARED,
+        SHARED_TMP
     };
 
     enum PathType {
@@ -107,6 +109,7 @@ struct AppInstallHelper {
     void createPublicDir(RootType type = RootType::BASE);
     void createPrivateFile(int i = 0, RootType type = RootType::BASE);
     void createSharedRODir(int i = 0, RootType type = RootType::BASE);
+    void createSharedROFile(int i = 0, RootType type = RootType::BASE);
     void createPrivateRODir(int i = 0, RootType type = RootType::BASE);
     void removePaths();
 
@@ -121,12 +124,11 @@ struct AppInstallHelper {
     std::string getPublicDir(RootType type = RootType::BASE) const;
     std::string getPrivatePath(int i = 0, RootType type = RootType::BASE) const;
     std::string getSharedRODir(int i = 0, RootType type = RootType::BASE) const;
+    std::string getSharedROPath(int i = 0, RootType type = RootType::BASE) const;
     const TypePathsMap& getDirsMap() const;
     const TypePathsMap& getFilesMap() const;
 
     // Privileges
-    std::vector<std::string> getPrivilegesNames() const;             // deprecated
-    void addPrivileges(const std::vector<std::string> &privileges);  // deprecated
     void addPrivilege(Privilege privilege);
     void addPrivileges(const PrivilegeVector &privileges);
     const PrivilegeVector& getPrivileges() const;
@@ -155,10 +157,12 @@ protected:
 
     bool createFile(app_install_path_type smType, const std::string &path);
     bool createDir(app_install_path_type smType, const std::string &path, bool isBasePath = false);
+    void createDirLink(app_install_path_type smType, const std::string &dest, int i = 0,
+                       RootType rType = RootType::BASE);
     void createInstallDir(RootType type);
 
-    std::string m_appName;
-    std::string m_pkgName;
+    const std::string m_appName;
+    const std::string m_pkgName;
     bool m_isLocal;
     int m_uidGid;
     std::string m_version;