Label SHARED_RO directory under symlink 25/217125/3
authorZofia Grzelewska <z.abramowska@samsung.com>
Mon, 4 Nov 2019 16:41:27 +0000 (17:41 +0100)
committerTomasz Swierczek <t.swierczek@samsung.com>
Wed, 20 Nov 2019 11:09:55 +0000 (11:09 +0000)
SharedRO directories from previous implementation
are now symlinks pointing to new SharedRO directories.
This commits assures, that all contents under this symlink
are properly labeled.

Change-Id: I672aaf38ffca3ed6608d9c0aaa2ad7253df16349

src/common/smack-labels.cpp
test/CMakeLists.txt

index abc591687dc0e6ac3da2fef4aa567f601f995f6e..a9a7a19fbfef476f741703ef9b361dd7c21552df 100644 (file)
@@ -42,6 +42,7 @@
 #include <dpl/errno_string.h>
 
 #include "security-manager.h"
+#include "service_impl_utils.h"
 #include "smack-labels.h"
 #include "utils.h"
 
@@ -138,7 +139,7 @@ void setupPath(
         const int authorId)
 {
     std::string label;
-    bool label_executables, label_transmute;
+    bool label_executables, label_transmute, follow_symlink = false;
 
     switch (pathType) {
     case SECURITY_MANAGER_PATH_RW:
@@ -160,6 +161,7 @@ void setupPath(
         label = generatePathSharedROLabel();
         label_executables = false;
         label_transmute = true;
+        follow_symlink = true;
         break;
     case SECURITY_MANAGER_PATH_TRUSTED_RW:
         if (authorId < 0)
@@ -172,6 +174,9 @@ void setupPath(
         LogError("Path type not known.");
         Throw(SmackException::InvalidPathType);
     }
+    if (follow_symlink) {
+        labelDir(realPath(path), label, label_transmute, label_executables);
+    }
     return labelDir(path, label, label_transmute, label_executables);
 }
 
index 888162f72d24f94bfffad9c38b0aa05484ea3baa..f18d33c6606acf2acbfab204e24e38880c47e052 100644 (file)
@@ -76,6 +76,7 @@ SET(SM_TESTS_SOURCES
     ${PROJECT_SOURCE_DIR}/src/common/db-config.cpp
     ${PROJECT_SOURCE_DIR}/src/common/file-lock.cpp
     ${PROJECT_SOURCE_DIR}/src/common/privilege_db.cpp
+    ${PROJECT_SOURCE_DIR}/src/common/service_impl_utils.cpp
     ${PROJECT_SOURCE_DIR}/src/common/smack-check.cpp
     ${PROJECT_SOURCE_DIR}/src/common/smack-labels.cpp
     ${PROJECT_SOURCE_DIR}/src/common/smack-rules.cpp