From: Unsung Lee Date: Fri, 10 Jan 2025 01:54:10 +0000 (+0900) Subject: Revert "test: kdbus: Replace the code that accesses the attr with the cynara API" X-Git-Tag: accepted/tizen/unified/20250113.094324~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F317943%2F1;p=platform%2Fkernel%2Flinux-tizen-modules-source.git Revert "test: kdbus: Replace the code that accesses the attr with the cynara API" This reverts commit 9ec09947446627d1a511065be0bfdd46013de4c3. Change-Id: I511673fb289e4398e339a8236451b8d495bf1b81 --- diff --git a/packaging/linux-tizen-modules-source.spec b/packaging/linux-tizen-modules-source.spec index 9d573bd..b6a7d87 100644 --- a/packaging/linux-tizen-modules-source.spec +++ b/packaging/linux-tizen-modules-source.spec @@ -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. diff --git a/tests/kdbus/Makefile b/tests/kdbus/Makefile index 7887550..01e11d3 100644 --- a/tests/kdbus/Makefile +++ b/tests/kdbus/Makefile @@ -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 diff --git a/tests/kdbus/kdbus-test.c b/tests/kdbus/kdbus-test.c index 4119747..062efc6 100644 --- a/tests/kdbus/kdbus-test.c +++ b/tests/kdbus/kdbus-test.c @@ -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", diff --git a/tests/kdbus/kdbus-util.c b/tests/kdbus/kdbus-util.c index 9f6999e..d9fa167 100644 --- a/tests/kdbus/kdbus-util.c +++ b/tests/kdbus/kdbus-util.c @@ -30,8 +30,6 @@ #include #include -#include - #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; } diff --git a/tests/kdbus/kdbus-util.h b/tests/kdbus/kdbus-util.h index 1c32ad7..5775142 100644 --- a/tests/kdbus/kdbus-util.h +++ b/tests/kdbus/kdbus-util.h @@ -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