security-manager: drop testing of obsolete TIZENEXEC label on symlinks 60/27460/5
authorRafal Krypa <r.krypa@samsung.com>
Fri, 12 Sep 2014 15:14:25 +0000 (17:14 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Mon, 22 Sep 2014 17:16:32 +0000 (10:16 -0700)
This feature is just being removed from security-manager. No labels
will be set on symlinks.

Change-Id: I9f19cb0b4f2d273407654f9e04f15d6d4823ed05
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
tests/security-manager-tests/security_manager_tests.cpp

index 476acef..0632cd1 100644 (file)
@@ -5,11 +5,6 @@
 #include <summary_collector.h>
 #include <string>
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/xattr.h>
-#include <linux/xattr.h>
-
 #include <libprivilege-control_test_common.h>
 #include <tests_common.h>
 
@@ -43,8 +38,6 @@ static const privileges_t SM_DENIED_PRIVILEGES  = {
 static const privileges_t SM_NO_PRIVILEGES  = {
 };
 
-static const char *const XATTR_NAME_TIZENEXEC =  XATTR_SECURITY_PREFIX "TIZEN_EXEC_LABEL";
-
 static const char *const SM_PRIVATE_PATH = "/etc/smack/test_DIR/app_dir";
 static const char *const SM_PUBLIC_PATH = "/etc/smack/test_DIR/app_dir_public";
 static const char *const SM_PUBLIC_RO_PATH = "/etc/smack/test_DIR/app_dir_public_ro";
@@ -58,31 +51,6 @@ static void generateAppLabel(const std::string &pkgId, std::string &label)
     label = "User";
 }
 
-
-static bool isLinkToExec(const char *fpath, const struct stat *sb)
-{
-
-    struct stat buf;
-    char *target;
-    int ret;
-
-    // check if it's a link
-    if ( !S_ISLNK(sb->st_mode))
-        return false;
-
-    target = realpath(fpath, nullptr);
-    RUNNER_ASSERT_ERRNO_MSG(target != 0, "Could not obtain real path from link");
-
-    ret = stat(target, &buf);
-    RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Could not obtain real path's stat from link");
-
-    if (buf.st_mode != (buf.st_mode | S_IXUSR | S_IFREG))
-        return false;
-
-
-    return true;
-}
-
 static int nftw_check_sm_labels_app_dir(const char *fpath, const struct stat *sb,
                               const char* correctLabel, bool transmute_test, bool exec_test)
 {
@@ -113,19 +81,6 @@ static int nftw_check_sm_labels_app_dir(const char *fpath, const struct stat *sb
         RUNNER_ASSERT_MSG(label == nullptr, "EXEC label on " << fpath << " is set");
 
 
-    /* LINK TO EXEC */
-    if (isLinkToExec(fpath, sb) && exec_test) {
-        char buf[SMACK_LABEL_LEN+1];
-        result = lgetxattr(fpath, XATTR_NAME_TIZENEXEC, buf, sizeof(buf));
-        RUNNER_ASSERT_ERRNO_MSG(result != -1, "Could not get label for the path " << fpath);
-        buf[result]='\0';
-        result = strcmp(correctLabel, buf);
-        RUNNER_ASSERT_MSG(result == 0, "Incorrect TIZEN_EXEC_LABEL attribute"
-                " on link to executable " << fpath);
-    }
-
-
-
     /* TRANSMUTE */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE);
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");