waitpid(pid, NULL, 0);
}
}
+
+RUNNER_TEST(privilege_control16_app_setup_path){
+ const char *path1 = "/usr/share/privilege-control/app_setup_access_test";
+ const char *path2 = "/usr/share/privilege-control/app_setup_access_test/directory";
+ const char *path3 = "/usr/share/privilege-control/app_setup_access_test/one";
+ const char *path4 = "/usr/share/privilege-control/app_setup_access_test/directory/two";
+ const char *label1 = "qwert123456za";
+ const char *label2 = "trewq654123az";
+
+ std::unique_ptr<char, std::function<void(void*)>> labelPtr(NULL,free);
+
+ mkdir(path1,0);
+ mkdir(path2,0);
+
+ int fd = creat(path3, S_IRWXU);
+ if (fd >= 0)
+ close(fd);
+ fd = creat(path4, S_IRWXU);
+ if (fd >= 0)
+ close(fd);
+
+ char *label = NULL;
+
+ RUNNER_ASSERT(PC_OPERATION_SUCCESS == app_setup_path("somepackageid", path1, APP_PATH_ANY_LABEL, label1));
+ RUNNER_ASSERT(0 == smack_lgetlabel(path3, &label, SMACK_LABEL_ACCESS));
+ labelPtr.reset(label);
+ label = NULL;
+ RUNNER_ASSERT(0 == strcmp(labelPtr.get(), label1));
+
+ RUNNER_ASSERT(PC_OPERATION_SUCCESS == app_setup_path("somepackageid", path1, APP_PATH_ANY_LABEL, label2));
+ RUNNER_ASSERT(0 == smack_lgetlabel(path4, &label, SMACK_LABEL_EXEC));
+ labelPtr.reset(label);
+ label = NULL;
+ RUNNER_ASSERT(0 == strcmp(labelPtr.get(), label2));
+
+ RUNNER_ASSERT(0 == smack_lgetlabel(path1, &label, SMACK_LABEL_EXEC));
+ labelPtr.reset(label);
+ label = NULL;
+ RUNNER_ASSERT(labelPtr.get() == NULL);
+}
+