Skip author hash in no-smack mode
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 16 Jan 2025 09:42:17 +0000 (10:42 +0100)
committerTomasz Swierczek <t.swierczek@samsung.com>
Wed, 5 Feb 2025 07:56:19 +0000 (08:56 +0100)
Change-Id: If0496a4455f06759b16c2e2156f0d8eadb6b574c

src/common/service_impl.cpp

index 208a6b244fc0bdd35bb8d3497babae88c7fd3bae..9ff3122c8e56f6eb52b54eee44e4faacee103085 100644 (file)
@@ -2418,24 +2418,26 @@ int ServiceImpl::prepareApp(const Credentials &creds, const std::string &appName
 
         LogWarning("Allowed privileges returned - number: " << allowedPrivileges.size());
 
-        std::string authorHash;
-        m_privilegeDb.GetPkgAuthorHash(pkgName, authorHash);
-
-        LogWarning("GetPkgAuthorHash returned : " << authorHash);
-
-        if (m_smackRules.isPrivilegeMappingEnabled() && smack_simple_check()) {
-            // We have to remove all possible privilege related Smack rules, because application
-            // policy might have changed from last prepareApp
-            // (e.g. application new version was installed)
-            m_smackRules.disableAllPrivilegeRules(label, pkgName, authorHash);
-
-            // TODO: Optimization is welcomed here
-            auto runningApps = MountNS::getMountNSApps();
-            if (isMultiUser({label, std::to_string(creds.uid)}, runningApps)) {
-                LogWarning("Detected multiuser instance of " << appName
-                        << ". Privilege related Smack rules are cleared and won't be reapplied.");
-            } else {
-                m_smackRules.enablePrivilegeRules(label, pkgName, authorHash, allowedPrivileges);
+        if (smack_simple_check()) {
+            std::string authorHash;
+            m_privilegeDb.GetPkgAuthorHash(pkgName, authorHash);
+
+            LogWarning("GetPkgAuthorHash returned : " << authorHash);
+
+            if (m_smackRules.isPrivilegeMappingEnabled()) {
+                // We have to remove all possible privilege related Smack rules, because application
+                // policy might have changed from last prepareApp
+                // (e.g. application new version was installed)
+                m_smackRules.disableAllPrivilegeRules(label, pkgName, authorHash);
+
+                // TODO: Optimization is welcomed here
+                auto runningApps = MountNS::getMountNSApps();
+                if (isMultiUser( { label, std::to_string(creds.uid) }, runningApps)) {
+                    LogWarning("Detected multiuser instance of " << appName <<
+                            ". Privilege related Smack rules are cleared and won't be reapplied.");
+                } else {
+                    m_smackRules.enablePrivilegeRules(label, pkgName, authorHash, allowedPrivileges);
+                }
             }
         }