hotfix to create cache, data directory for skel. 65/54065/1 accepted/tizen/mobile/20151212.071149 accepted/tizen/tv/20151212.072642 accepted/tizen/wearable/20151212.073247 submit/tizen/20151211.080717
authorJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 11 Dec 2015 06:51:24 +0000 (15:51 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 11 Dec 2015 06:51:24 +0000 (15:51 +0900)
temporary fix to create cache, data directory when using pkgdir-tool.
Should find other way to apply smack label to skel folders

Change-Id: I56c165d1467340e1dc15e8e568d354c4ca340bac
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/pkgdir_tool/pkgdir_tool.cc

index 3104cc5..bec8231 100644 (file)
@@ -12,6 +12,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <tzplatform_config.h>
+#include <sys/xattr.h>
 
 #include <cassert>
 #include <cstring>
@@ -202,10 +203,36 @@ bool CreateSkelDirectories(const std::string& pkgid) {
   LOG(DEBUG) << "Creating directories in: " << path;
   bs::error_code error;
   bf::create_directories(path, error);
+  int r = -1;
+
   if (error) {
     LOG(ERROR) << "Failed to create directory: " << path;
     return false;
   }
+
+  // TODO(jungh.yeon) : this is hotfix.
+  for (auto& pair : kEntries) {
+    bf::path subpath = path / pair.first;
+    bf::create_directories(subpath, error);
+    std::string label = "User::Pkg::" + pkgid;
+    if (error) {
+      LOG(ERROR) << "Failed to create directory: " << subpath;
+      return false;
+    }
+
+    r = lsetxattr(subpath.c_str(), "security.SMACK64TRANSMUTE", "TRUE", 4, 0);
+    if (r < 0) {
+      LOG(ERROR) << "Failed to apply transmute";
+      return false;
+    }
+
+    r = lsetxattr(subpath.c_str(), "security.SMACK64", label.c_str(), label.length(), 0);
+    if (r < 0) {
+      LOG(ERROR) << "Failed to apply label";
+      return false;
+    }
+  }
+
   return true;
 }