Revert "test: kdbus: Replace the code that accesses the attr with the cynara API" 43/317943/1
authorUnsung Lee <unsung.lee@samsung.com>
Fri, 10 Jan 2025 01:54:10 +0000 (10:54 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Fri, 10 Jan 2025 04:50:53 +0000 (13:50 +0900)
This reverts commit 9ec09947446627d1a511065be0bfdd46013de4c3.

Change-Id: I511673fb289e4398e339a8236451b8d495bf1b81

packaging/linux-tizen-modules-source.spec
tests/kdbus/Makefile
tests/kdbus/kdbus-test.c
tests/kdbus/kdbus-util.c
tests/kdbus/kdbus-util.h

index 9d573bd0f865d8f91acd5655d126d14f9452ae02..b6a7d87cc3222d1e848b19c2851998f0213a2983 100644 (file)
@@ -1,5 +1,5 @@
 Name:           linux-tizen-modules-source
-Version:        7.5.1
+Version:        7.5.0
 Release:        0
 License:        GPL-2.0+
 Source0:        %{name}-%{version}.tar.xz
@@ -25,8 +25,6 @@ Group:          System/Kernel
 Provides:       linux-kernel-kdbus-tests
 Provides:       linux-kernel-logger-tests
 BuildRequires:  pkgconfig(libcap)
-BuildRequires:  pkgconfig(cynara-creds-self)
-Requires:       pkgconfig(cynara-creds-self)
 %description    -n linux-tizen-modules-tests
 This package contains tests for Tizen-specific kernel modules.
 
index 78875508a689a835ff700bb1cc15e514de053e6b..01e11d3c1a0a3de7feaec535b42f7048b686a541 100644 (file)
@@ -2,9 +2,7 @@ CFLAGS += -I../../include/uapi/
 CFLAGS += -I../../samples/kdbus/
 CFLAGS += -std=gnu99 -Wno-error=shadow
 CFLAGS += -DKBUILD_MODNAME=\"kdbus\" -D_GNU_SOURCE
-CFLAGS += `pkg-config --cflags cynara-creds-self`
 LDFLAGS = -pthread -lcap -lm
-LDFLAGS += `pkg-config --libs cynara-creds-self`
 
 .PHONY: all clean
 
index 4119747f5c90d93e603b9bcd9f53672903a73e06..062efc6f1e05b3fcd1f73960b82ca29baf7d4d83 100644 (file)
@@ -688,8 +688,6 @@ void print_kdbus_test_args(struct kdbus_test_args const *args)
 void print_metadata_support(void)
 {
        bool no_meta_audit, no_meta_cgroups, no_meta_seclabel;
-       bool security_enabled;
-       int ret;
 
        /*
         * KDBUS_ATTACH_CGROUP, KDBUS_ATTACH_AUDIT and
@@ -697,11 +695,7 @@ void print_metadata_support(void)
         */
        no_meta_audit = !config_auditsyscall_is_enabled();
        no_meta_cgroups = !config_cgroups_is_enabled();
-       ret = config_get_security_enabled_state(&security_enabled);
-       if (ret < 0)
-               no_meta_seclabel = true;
-       else
-               no_meta_seclabel = !security_enabled;
+       no_meta_seclabel = !config_security_is_enabled();
 
        if (no_meta_audit | no_meta_cgroups | no_meta_seclabel)
                print("# Starting tests without %s%s%s metadata support\n",
index 9f6999ef665bf7b200538c0e64bbb70c2a2727ca..d9fa167a5123363d63813cd4ed3b2b23c57e82ec 100644 (file)
@@ -30,8 +30,6 @@
 #include <sys/time.h>
 #include <linux/unistd.h>
 
-#include <cynara-creds-self.h>
-
 #ifndef __NR_memfd_create
   #ifdef __x86_64__
     #define __NR_memfd_create 319
@@ -61,8 +59,6 @@
 /* maximum number of well-known names per connection */
 #define KDBUS_CONN_MAX_NAMES                   256
 
-#define SMACK_DISABLED_DEFAULT_SMACK_LABEL     "User::Pkg::default_app_no_Smack_mode"
-
 int kdbus_util_verbose = true;
 
 wur int kdbus_sysfs_get_parameter_mask(const char *path, uint64_t *mask)
@@ -1827,28 +1823,31 @@ wur int config_cgroups_is_enabled(void)
        return (access("/proc/self/cgroup", F_OK) == 0);
 }
 
-wur int config_get_security_enabled_state(bool *security_enabled)
+wur int config_security_is_enabled(void)
 {
+       int fd;
        int ret;
-       char *label = NULL;
+       char buf[128];
 
-       ret = cynara_creds_self_get_client(CLIENT_METHOD_DEFAULT, &label);
-       if (ret != 0) {
-               print("Failed to get self smack label by cynara_creds_self_get_client()\n");
-               return ret;
-       }
+       /* CONFIG_SECURITY is disabled */
+       if (access("/proc/self/attr/current", F_OK) != 0)
+               return 0;
 
-       /**
-        * cynara_creds_self_get_client() gives SMACK_DISABLED_DEFAULT_SMACK_LABEL as label
-        * when smack is disabled.
+       /*
+        * Now only if read() fails with -EINVAL then we assume
+        * that SECLABEL and LSM are disabled
         */
-       if (strncmp(label, SMACK_DISABLED_DEFAULT_SMACK_LABEL,
-                               sizeof(SMACK_DISABLED_DEFAULT_SMACK_LABEL)) == 0)
-               *security_enabled = false;
+       fd = open("/proc/self/attr/current", O_RDONLY|O_CLOEXEC);
+       if (fd < 0)
+               return 1;
+
+       ret = read(fd, buf, sizeof(buf));
+       if (ret == -1 && errno == EINVAL)
+               ret = 0;
        else
-               *security_enabled = true;
+               ret = 1;
 
-       free(label);
+       CLOSE(fd);
 
-       return 0;
+       return ret;
 }
index 1c32ad77c230c155e6b610a07a98dcb797977c07..5775142dd13a92dd7385132e603a1459ea9d9958 100644 (file)
@@ -278,4 +278,4 @@ wur int test_is_capable(int cap, ...);
 wur int config_user_ns_is_enabled(void);
 wur int config_auditsyscall_is_enabled(void);
 wur int config_cgroups_is_enabled(void);
-wur int config_get_security_enabled_state(bool *security_enabled);
+wur int config_security_is_enabled(void);
\ No newline at end of file