Add Smack template files manager 36/228536/10
authorZofia Abramowska <z.abramowska@samsung.com>
Mon, 23 Mar 2020 18:05:48 +0000 (19:05 +0100)
committerZofia Abramowska <z.abramowska@samsung.com>
Mon, 20 Apr 2020 10:01:55 +0000 (12:01 +0200)
Add Smack template rule files manager to speedup the process
of loading template files.

Change-Id: I148438dafdf355be7a77f4a8662ffa0b4e0b6ac1

src/common/CMakeLists.txt
src/common/include/config.h
src/common/include/smack-rules.h
src/common/include/template-manager.h [new file with mode: 0644]
src/common/smack-rules.cpp
src/common/template-manager.cpp [new file with mode: 0644]
test/CMakeLists.txt
test/test_smack-rules.cpp

index 4c76ac91a56038695352ac4f4119920f12547c14..257f0a96644cf3beac389c2672632728d99d8fa9 100644 (file)
@@ -65,6 +65,7 @@ SET(COMMON_SOURCES
     ${COMMON_PATH}/smack-common.cpp
     ${COMMON_PATH}/smack-rules.cpp
     ${COMMON_PATH}/smack-check.cpp
+    ${COMMON_PATH}/template-manager.cpp
     ${COMMON_PATH}/service_impl.cpp
     ${COMMON_PATH}/service_impl_utils.cpp
     ${COMMON_PATH}/tzplatform-config.cpp
index 1fef74f2b317448d8bc2ee42a5546a4370b15903..e8b53206b0f4d30d7f02a92a4fdf0131a86efd11 100644 (file)
@@ -45,7 +45,6 @@
 
 #define PRIVILEGE_GROUP_LIST_FILE  POLICY_INSTALL_DIR "/privilege-group.list"
 #define PRIVILEGE_MOUNT_LIST_FILE  POLICY_INSTALL_DIR "/privilege-mount.list"
-#define PRIVILEGE_SMACK_LIST_FILE  POLICY_INSTALL_DIR "/privilege-smack.list"
 #define PRIVILEGE_SYSTEMD_LIST_FILE  POLICY_INSTALL_DIR "/privilege-managed-by-systemd-for-daemons.list"
 
 #define SKEL_DIR                   "/etc/skel"
index 0019a3e61fcd7f54fdb8e1db570280576eddbf6d..0724ad6dd3abd5c608caf6791142a18846bfd926 100644 (file)
 #include <string>
 #include <utility>
 
+#include <config.h>
 #include <smack-accesses.h>
 #include <smack-common.h>
+#include <template-manager.h>
 
 namespace SecurityManager {
 
 class SmackRules {
 public:
+    SmackRules() : m_templateMgr(POLICY_INSTALL_DIR) {
+        m_templateMgr.init();
+    }
+
     /**
      * Install package-specific smack rules plus add rules for specified external apps.
      *
@@ -165,36 +171,22 @@ public:
 
     void addFromTemplate(
         SmackAccesses &rules,
-        const Smack::TemplateRules &templateRules,
-        const Smack::Label &appProcessLabel,
-        const std::string &pkgName,
-        const int authorId);
-
-    void addFromTemplateFile(
-        SmackAccesses &rules,
-        const std::string &templatePath,
+        TemplateManager::Type type,
         const Smack::Label &appProcessLabel,
         const std::string &pkgName,
         const int authorId);
 
     void addFromPrivTemplate(
         SmackAccesses &rules,
-        const Smack::TemplateRules &templateRules,
+        TemplateManager::Type type,
+        const std::string &privilege,
         const Smack::Label &appProcessLabel,
         const Smack::Label &privilegeLable,
         const std::string &pkgName,
         const int authorId);
 
-    void addFromPrivTemplateFile(
-        SmackAccesses &rules,
-        const std::string &templatePath,
-        const Smack::Label &appProcessLabel,
-        const Smack::Label &privilegeLabel,
-        const std::string &pkgName,
-        int AuthorId);
-
     void useTemplate(
-        const std::string &templatePath,
+        TemplateManager::Type type,
         const Smack::Label &appProcessLabel,
         const std::string &pkgName,
         const int authorId = -1);
@@ -210,6 +202,7 @@ private:
      */
     void generatePackageCrossDeps(SmackAccesses &rules, const Smack::Labels &pkgLabels);
 
+    TemplateManager m_templateMgr;
 };
 
 } // namespace SecurityManager
diff --git a/src/common/include/template-manager.h b/src/common/include/template-manager.h
new file mode 100644 (file)
index 0000000..d9f8a3f
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ *  Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ *  Contact: Rafal Krypa <r.krypa@samsung.com>
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+/**
+ * @file        templates-manager.h
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @version     1.0
+ * @brief       Header file of a smack rules template manager
+ */
+
+#include <map>
+#include <string>
+
+#include <smack-common.h>
+
+#include "config-file.h"
+
+namespace SecurityManager {
+
+class TemplateManager {
+public:
+    explicit TemplateManager(const std::string &rootDir) : m_rootDir(rootDir){}
+    enum Type {
+        APP_RULES_TEMPLATE,
+        PKG_RULES_TEMPLATE,
+        AUTHOR_RULES_TEMPLATE,
+        PRIV_DEFAULT_RULES_TEMPLATE,
+        PRIV_RULES_TEMPLATE
+    };
+    void init();
+    Smack::TemplateRules getRules(Type type, const std::string &privName = "") const;
+    Smack::Label getPrivilegeLabel(const std::string &privName) const;
+
+private:
+    void loadFiles();
+    typedef std::string PrivilegeName;
+    typedef std::string Path;
+    typedef std::string FileName;
+
+    struct PrivMapping {
+        Smack::Label label;
+        FileName fileName;
+    };
+
+    std::string getPolicyFile(enum TemplateManager::Type policyFile,
+                              const std::string &privFile = "") const ;
+    PrivMapping getPrivMapping(const std::string &privName) const;
+
+    std::string m_rootDir;
+    std::map<Path, Smack::TemplateRules> m_templateRules;
+    std::map<PrivilegeName, PrivMapping> m_privMapping;
+};
+
+} // namespace SecurityManager
index e8781a0b84850fa567274e92048db2440e0b65e6..54a41e62a6fc6c9baab47c3fc4360d51ff3e2d38 100644 (file)
@@ -30,7 +30,6 @@
 #include <config-file.h>
 #include <dpl/log/log.h>
 #include <dpl/errno_string.h>
-#include <filesystem.h>
 #include <smack-check.h>
 #include <smack-exceptions.h>
 #include <smack-labels.h>
@@ -63,32 +62,6 @@ const std::string SMACK_PATH_RO_LABEL_TEMPLATE     = "~PATH_RO~";
 const std::string SMACK_PATH_TRUSTED_LABEL_TEMPLATE  = "~PATH_TRUSTED~";
 const std::string SMACK_PRIVILEGE_LABEL_TEMPLATE   = "~PRIVILEGE~";
 
-enum POLICY_FILE {
-    APP_RULES_TEMPLATE,
-    PKG_RULES_TEMPLATE,
-    AUTHOR_RULES_TEMPLATE,
-    PRIV_DEFAULT_RULES_TEMPLATE,
-    PRIV_RULES_TEMPLATE
-};
-
-const std::string POLICY_DIR_STR = POLICY_INSTALL_DIR;
-const std::string PRIV_MAPPING_DIR_STR = POLICY_INSTALL_DIR "/" PRIV_MAPPING_INSTALL_SUBDIR;
-
-std::map<POLICY_FILE, std::string> POLICY_FILE_PATH_MAP = {
-    {POLICY_FILE::APP_RULES_TEMPLATE, POLICY_DIR_STR + "/app-rules-template.smack"},
-    {POLICY_FILE::PKG_RULES_TEMPLATE, POLICY_DIR_STR + "/pkg-rules-template.smack"},
-    {POLICY_FILE::AUTHOR_RULES_TEMPLATE, POLICY_DIR_STR + "/author-rules-template.smack"},
-    {POLICY_FILE::PRIV_DEFAULT_RULES_TEMPLATE,
-     PRIV_MAPPING_DIR_STR + "/priv-rules-default-template.smack"}
-};
-
-std::string getPolicyFile(enum POLICY_FILE policyFile, const std::string &privFile = "") {
-    if (policyFile == POLICY_FILE::PRIV_RULES_TEMPLATE) {
-        return PRIV_MAPPING_DIR_STR + "/" + privFile;
-    }
-    return POLICY_FILE_PATH_MAP[policyFile];
-}
-
 const std::string SMACK_APP_IN_PACKAGE_PERMS   = "rwxat";
 const std::string SMACK_APP_PATH_OWNER_PERMS = "rwxat";
 const std::string SMACK_APP_PATH_TARGET_PERMS = "rxl";
@@ -99,28 +72,11 @@ const std::string SMACK_SYSTEM_PRIVILEGED = "System::Privileged";
 const std::string SMACK_APP_PATH_SYSTEM_PERMS = "rwxat";
 const std::string SMACK_APP_PATH_USER_PERMS = "rwxat";
 
-const std::string PRIV_TEMPLATE_DEFAULT = "default";
-
 } // namespace anonymous
 
-void SmackRules::addFromTemplateFile(
-    SmackAccesses &rules,
-    const std::string &templatePath,
-    const Smack::Label &appProcessLabel,
-    const std::string &pkgName,
-    const int authorId)
-{
-    try {
-        addFromTemplate(rules, Smack::fromConfig(templatePath), appProcessLabel, pkgName, authorId);
-    } catch (FS::Exception::Base &) {
-        LogError("Error reading template file: " << templatePath);
-        ThrowMsg(SmackException::FileError, "Error reading template file: " << templatePath);
-    }
-}
-
 void SmackRules::addFromTemplate(
     SmackAccesses &rules,
-    const Smack::Rules &templateRules,
+    TemplateManager::Type type,
     const Smack::Label &appProcessLabel,
     const std::string &pkgName,
     const int authorId)
@@ -136,6 +92,8 @@ void SmackRules::addFromTemplate(
     if (authorId >= 0)
         pathTrustedLabel = SmackLabels::generatePathTrustedLabel(authorId);
 
+    Smack::TemplateRules templateRules = m_templateMgr.getRules(type);
+
     for (auto rule : templateRules) {
         strReplace(rule.subject, SMACK_PROCESS_LABEL_TEMPLATE, appProcessLabel);
         strReplace(rule.object,  SMACK_PROCESS_LABEL_TEMPLATE, appProcessLabel);
@@ -151,7 +109,8 @@ void SmackRules::addFromTemplate(
 
 void SmackRules::addFromPrivTemplate(
     SmackAccesses &rules,
-    const Smack::TemplateRules &templateRules,
+    TemplateManager::Type type,
+    const std::string &privilege,
     const Smack::Label &appProcessLabel,
     const Smack::Label &privilegeLabel,
     const std::string &pkgName,
@@ -168,6 +127,7 @@ void SmackRules::addFromPrivTemplate(
     if (authorId >= 0)
         pathTrustedLabel = SmackLabels::generatePathTrustedLabel(authorId);
 
+    Smack::TemplateRules templateRules = m_templateMgr.getRules(type, privilege);
     for (auto rule : templateRules) {
         if (rule.subject[0] != '~' || rule.object[0] != '~') {
             LogWarning("Unsupported rule <"
@@ -189,23 +149,6 @@ void SmackRules::addFromPrivTemplate(
     }
 }
 
-void SmackRules::addFromPrivTemplateFile(
-    SmackAccesses &rules,
-    const std::string &templatePath,
-    const Smack::Label &appProcessLabel,
-    const Smack::Label &privilegeLabel,
-    const std::string &pkgName,
-    int authorId)
-{
-    try {
-        addFromPrivTemplate(rules, Smack::fromConfig(templatePath), appProcessLabel, privilegeLabel,
-                            pkgName, authorId);
-    } catch (FS::Exception::Base &) {
-        LogError("Error reading template file: " << templatePath);
-        ThrowMsg(SmackException::FileError, "Error reading template file: " << templatePath);
-    }
-}
-
 void SmackRules::generatePackageCrossDeps(SmackAccesses &rules, const Smack::Labels &pkgLabels)
 {
     LogDebug("Generating cross-package rules");
@@ -225,13 +168,13 @@ void SmackRules::generatePackageCrossDeps(SmackAccesses &rules, const Smack::Lab
 }
 
 void SmackRules::useTemplate(
-        const std::string &templatePath,
+        TemplateManager::Type type,
         const Smack::Label &appProcessLabel,
         const std::string &pkgName,
         const int authorId)
 {
     SmackAccesses smackRules;
-    addFromTemplateFile(smackRules, templatePath, appProcessLabel, pkgName, authorId);
+    addFromTemplate(smackRules, type, appProcessLabel, pkgName, authorId);
 
     if (smack_check())
         smackRules.apply();
@@ -243,10 +186,10 @@ void SmackRules::installApplicationRules(
         const int authorId,
         const Smack::Labels &pkgLabels)
 {
-    useTemplate(getPolicyFile(POLICY_FILE::APP_RULES_TEMPLATE), appProcessLabel, pkgName, authorId);
+    useTemplate(TemplateManager::Type::APP_RULES_TEMPLATE, appProcessLabel, pkgName, authorId);
 
     if (authorId >= 0)
-        useTemplate(getPolicyFile(POLICY_FILE::AUTHOR_RULES_TEMPLATE), appProcessLabel, pkgName, authorId);
+        useTemplate(TemplateManager::Type::AUTHOR_RULES_TEMPLATE, appProcessLabel, pkgName, authorId);
 
     updatePackageRules(pkgName, pkgLabels);
 }
@@ -264,29 +207,12 @@ void SmackRules::enablePrivilegeRules(
 
     SmackAccesses smackRules;
 
-    auto privMapping = ConfigFile(PRIVILEGE_SMACK_LIST_FILE).read();
-
-    for (auto &mapping : privMapping) {
-        if (mapping.size() != 3)
+    for (auto &privilege : privileges) {
+        auto privLabel = m_templateMgr.getPrivilegeLabel(privilege);
+        if (privLabel.empty())
             continue;
-
-        auto &privName = mapping[0];
-        auto &privLabel = mapping[1];
-        auto &privTemplate = mapping[2];
-
-        if (privTemplate == PRIV_TEMPLATE_DEFAULT) {
-            privTemplate = getPolicyFile(POLICY_FILE::PRIV_DEFAULT_RULES_TEMPLATE);
-        } else {
-            privTemplate = getPolicyFile(POLICY_FILE::PRIV_RULES_TEMPLATE, privTemplate);
-        }
-
-        for (auto &privilege : privileges) {
-            if (privilege == privName) {
-                addFromPrivTemplateFile(smackRules, privTemplate, appProcessLabel, privLabel,
-                                        pkgName, authorId);
-                break;
-            }
-        }
+        addFromPrivTemplate(smackRules, TemplateManager::Type::PRIV_RULES_TEMPLATE, privilege,
+                            appProcessLabel, privLabel, pkgName, authorId);
     }
 
     if (smack_check())
@@ -298,8 +224,8 @@ void SmackRules::updatePackageRules(
         const Smack::Labels &pkgLabels)
 {
     SmackAccesses smackRules;
-    addFromTemplateFile(smackRules,
-            getPolicyFile(POLICY_FILE::PKG_RULES_TEMPLATE),
+    addFromTemplate(smackRules,
+            TemplateManager::Type::PKG_RULES_TEMPLATE,
             std::string(),
             pkgName,
             -1);
@@ -314,7 +240,8 @@ void SmackRules::uninstallPackageRules(const std::string &pkgName,
                                        const Smack::Labels &pkgLabels)
 {
     SmackAccesses smackRules;
-    addFromTemplateFile(smackRules, getPolicyFile(POLICY_FILE::PKG_RULES_TEMPLATE), {}, pkgName, -1);
+    addFromTemplate(smackRules, TemplateManager::Type::PKG_RULES_TEMPLATE,
+                    std::string(), pkgName, -1);
     generatePackageCrossDeps(smackRules, pkgLabels);
     smackRules.clear();
 }
@@ -325,7 +252,8 @@ void SmackRules::uninstallApplicationRules(
         const int authorId)
 {
     SmackAccesses smackRules;
-    addFromTemplateFile(smackRules, getPolicyFile(POLICY_FILE::APP_RULES_TEMPLATE), appLabel, pkgName, authorId);
+    addFromTemplate(smackRules, TemplateManager::Type::APP_RULES_TEMPLATE,
+                    appLabel, pkgName, authorId);
     smackRules.clear();
     SmackLabels::revokeSubject(appLabel);
 }
@@ -333,7 +261,8 @@ void SmackRules::uninstallApplicationRules(
 void SmackRules::uninstallAuthorRules(const int authorId)
 {
     SmackAccesses smackRules;
-    addFromTemplateFile(smackRules, getPolicyFile(POLICY_FILE::AUTHOR_RULES_TEMPLATE), {}, {}, authorId);
+    addFromTemplate(smackRules, TemplateManager::Type::AUTHOR_RULES_TEMPLATE,
+                    std::string(), std::string(), authorId);
     smackRules.clear();
 }
 
diff --git a/src/common/template-manager.cpp b/src/common/template-manager.cpp
new file mode 100644 (file)
index 0000000..49b8c9a
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ *  Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ *  Contact: Rafal Krypa <r.krypa@samsung.com>
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+/**
+ * @file        templates-manager.cpp
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @version     1.0
+ * @brief       Source file of a smack rules template manager
+ */
+
+#include <config.h>
+#include <config-file.h>
+#include <dpl/log/log.h>
+#include <filesystem.h>
+#include <smack-exceptions.h>
+
+#include "template-manager.h"
+
+namespace SecurityManager {
+
+namespace {
+
+const std::string PRIV_MAPPING_SUBDIR = PRIV_MAPPING_INSTALL_SUBDIR;
+
+const std::string PRIV_TEMPLATE_DEFAULT_FILE = PRIV_MAPPING_SUBDIR + "/"
+    + "priv-rules-default-template.smack";
+
+const std::map<TemplateManager::Type, std::string> TEMPLATE_PATH_MAP = {
+    {TemplateManager::Type::APP_RULES_TEMPLATE, "app-rules-template.smack"},
+    {TemplateManager::Type::PKG_RULES_TEMPLATE, "pkg-rules-template.smack"},
+    {TemplateManager::Type::AUTHOR_RULES_TEMPLATE, "author-rules-template.smack"},
+    {TemplateManager::Type::PRIV_DEFAULT_RULES_TEMPLATE, PRIV_TEMPLATE_DEFAULT_FILE}
+};
+
+const std::string PRIV_TEMPLATE_DEFAULT = "default";
+const std::string PRIVILEGE_SMACK_LIST_FILE = "privilege-smack.list";
+
+} // namespace anonymous
+
+void TemplateManager::init()
+{
+    try {
+        loadFiles();
+    } catch (FS::Exception::Base &e) {
+        LogError("Error loading config files: " << e.DumpToString());
+    } catch (SmackException::FileError &e) {
+        LogError("Error parsing config files: " << e.DumpToString());
+    }
+}
+
+std::string TemplateManager::getPolicyFile(enum TemplateManager::Type policyFile,
+                                           const std::string &privFile) const
+{
+    if (policyFile == TemplateManager::Type::PRIV_RULES_TEMPLATE) {
+        return m_rootDir + "/" + privFile;
+    }
+    return m_rootDir + "/" + TEMPLATE_PATH_MAP.at(policyFile);
+}
+
+void TemplateManager::loadFiles()
+{
+    std::string path = m_rootDir + "/" + PRIVILEGE_SMACK_LIST_FILE;
+    auto raw = ConfigFile(path).read();
+    for(auto &privMapping : raw) {
+
+        if (privMapping.size() != 3) {
+            std::string errorMsg = "Invalid mapping template: " + std::to_string(privMapping.size())
+                + " tokens in file " + path + ". Expected 3.";
+            LogError(errorMsg);
+            ThrowMsg(SmackException::FileError, errorMsg);
+        }
+
+        auto &privName = privMapping[0];
+        auto &privLabel = privMapping[1];
+        auto &privFile = privMapping[2];
+
+        if (privFile == PRIV_TEMPLATE_DEFAULT) {
+            privFile = PRIV_TEMPLATE_DEFAULT_FILE;
+        } else {
+            privFile = PRIV_MAPPING_SUBDIR + "/" + privFile;
+        }
+        m_privMapping[privName] = {privLabel, privFile};
+    }
+
+    std::vector<Type> types = {Type::APP_RULES_TEMPLATE, Type::PKG_RULES_TEMPLATE,
+                               Type::AUTHOR_RULES_TEMPLATE, Type::PRIV_DEFAULT_RULES_TEMPLATE};
+    for (auto &type : types) {
+        auto path = getPolicyFile(type);
+        m_templateRules[path] = Smack::fromConfig(path);
+    }
+
+    for (auto &privMapping : m_privMapping) {
+        auto path = getPolicyFile(PRIV_RULES_TEMPLATE, privMapping.second.fileName);
+        m_templateRules[path] = Smack::fromConfig(path);
+    }
+}
+
+TemplateManager::PrivMapping
+TemplateManager::getPrivMapping(const std::string &privName) const
+{
+    auto it = m_privMapping.find(privName);
+    if (it == m_privMapping.end())
+        return {"", ""};
+    return it->second;
+}
+
+Smack::Label TemplateManager::getPrivilegeLabel(const std::string &privName) const
+{
+    auto privMapping = getPrivMapping(privName);
+    return privMapping.label;
+}
+
+Smack::TemplateRules
+TemplateManager::getRules(TemplateManager::Type type, const std::string &privName) const
+{
+    std::string privTemplateFile;
+    if (!privName.empty()) {
+        privTemplateFile = getPrivMapping(privName).fileName;
+    }
+
+    std::string filePath = getPolicyFile(type, privTemplateFile);
+    auto it = m_templateRules.find(filePath);
+    if (it == m_templateRules.end()) {
+        return {};
+    }
+    return it->second;
+}
+
+} // namespace SecurityManager
index 84e4417b1867b6a2cd8236febf78dc0292b355f7..e73f0e055edcd9f0cf8791d6d3d7d08ec2369232 100644 (file)
@@ -84,6 +84,7 @@ SET(SM_TESTS_SOURCES
     ${PROJECT_SOURCE_DIR}/src/common/smack-check.cpp
     ${PROJECT_SOURCE_DIR}/src/common/smack-labels.cpp
     ${PROJECT_SOURCE_DIR}/src/common/smack-rules.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/template-manager.cpp
     ${PROJECT_SOURCE_DIR}/src/common/filesystem.cpp
     ${PROJECT_SOURCE_DIR}/src/common/tzplatform-config.cpp
     ${PROJECT_SOURCE_DIR}/src/common/utils.cpp
index a54433dc7bfa8106d3fccddb043d43ea6bb290ae..a6284a43c1449c49ed673d6fafac905b354c7f82 100644 (file)
@@ -74,51 +74,4 @@ BOOST_AUTO_TEST_CASE(T1120_smack_rules_exception)
                         SmackException::LibsmackError);
 }
 
-BOOST_FIXTURE_TEST_CASE(T1130_smack_rules_templates, RulesFixture)
-{
-    Smack::TemplateRules templateRules = {{"System", "~PROCESS~", "rwxat"},
-                                          {"~PROCESS~", "System", "wx"},
-                                          {"~PROCESS~", "~PATH_RW~", "rwxat"},
-                                          {"~PROCESS~", "~PATH_RO~", "rxl"},
-                                          {"~PROCESS~", "~PATH_TRUSTED~", "rwxat"}};
-
-    std::ofstream templateRulesFile;
-    templateRulesFile.open(templateRulesFilePath);
-    for (auto &templateRule : templateRules) {
-        templateRulesFile << templateRule.subject << ' ' << templateRule.object << ' '
-                          << templateRule.permissions << std::endl;
-    }
-    templateRulesFile.close();
-
-    const std::string appName = "appNameT1130";
-    const std::string pkgName = "pkgNameT1130";
-    const std::string appProcessLabel = generateProcessLabel(appName, pkgName, false);
-    const int authorId = 5000;
-    SmackAccesses smackAccessesFromTemplate, smackAccessesFromFileTemplate;
-    SmackRules smackRules;
-
-    BOOST_REQUIRE_NO_THROW(smackRules.addFromTemplate(
-                               smackAccessesFromTemplate,
-                               templateRules,
-                               appProcessLabel,
-                               pkgName,
-                               authorId));
-
-    const std::string noExistingFilePath = "/tmp/SecurityManagerUTNoExistingFile";
-    BOOST_REQUIRE_THROW(smackRules.addFromTemplateFile(
-                            smackAccessesFromFileTemplate,
-                            noExistingFilePath,
-                            appProcessLabel,
-                            pkgName,
-                            authorId),
-                        SmackException::FileError);
-
-    BOOST_REQUIRE_NO_THROW(smackRules.addFromTemplateFile(
-                               smackAccessesFromFileTemplate,
-                               templateRulesFilePath,
-                               appProcessLabel,
-                               pkgName,
-                               authorId));
-}
-
 BOOST_AUTO_TEST_SUITE_END()