From: Krzysztof Jackiewicz Date: Tue, 3 Jun 2025 13:18:55 +0000 (+0200) Subject: Remove smack dependency X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen;p=platform%2Fcore%2Fsecurity%2Faskuser.git Remove smack dependency Change-Id: Id5e87f11efa440a41e1d5a74c2ed9a7472f296ed --- diff --git a/packaging/askuser-notification.spec b/packaging/askuser-notification.spec index fe6e7e6..f84cf9b 100644 --- a/packaging/askuser-notification.spec +++ b/packaging/askuser-notification.spec @@ -21,6 +21,7 @@ BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(libsystemd) %endif BuildRequires: pkgconfig(cynara-plugin) +BuildRequires: pkgconfig(cynara-creds-socket) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(security-privilege-manager) BuildRequires: pkgconfig(security-manager) @@ -28,7 +29,6 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(capi-appfw-component-manager) BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(aul) BuildRequires: boost-devel %if "%{build_type}" == "COVERAGE" diff --git a/src/common/policy/Policy.cpp b/src/common/policy/Policy.cpp index adbac14..fe98877 100644 --- a/src/common/policy/Policy.cpp +++ b/src/common/policy/Policy.cpp @@ -162,9 +162,9 @@ std::string getOwnAppId(PkgInfo &pkgInfo) char *appName = nullptr; int ret = security_manager_identify_app_from_pid(getpid(), &pkgName, &appName); + throwOnSMError("security_manager_identify_app_from_pid", ret); std::unique_ptr pkg_name_p(pkgName, free); std::unique_ptr app_name_p(appName, free); - throwOnSMError("security_manager_identify_app_from_pid", ret); if (!appName) return pkgInfo.mainAppId(pkgName, geteuid()); diff --git a/src/ipc/CMakeLists.txt b/src/ipc/CMakeLists.txt index 0558dc0..cd2005c 100644 --- a/src/ipc/CMakeLists.txt +++ b/src/ipc/CMakeLists.txt @@ -21,8 +21,8 @@ SET(ASKUSER_NOTIFICATION_LIB_PATH ${ASKUSER_PATH}/ipc) PKG_CHECK_MODULES(ASKUSER_NOTIFICATION_LIB_DEP REQUIRED libsystemd - libsmack glib-2.0 + cynara-creds-socket ) INCLUDE_DIRECTORIES(SYSTEM ${ASKUSER_NOTIFICATION_LIB_DEP_INCLUDE_DIRS}) diff --git a/src/ipc/credentials.cpp b/src/ipc/credentials.cpp index 337bf08..78b2e27 100644 --- a/src/ipc/credentials.cpp +++ b/src/ipc/credentials.cpp @@ -21,8 +21,8 @@ #include #include -#include #include +#include #include "credentials-exception.h" #include "credentials.h" @@ -53,15 +53,16 @@ pid_t getPIDFromSocket(int sockFd) return cr.pid; } -std::string getSmackLabelFromSocket(int sockFd) +std::string getCynaraClientFromSocket(int sockFd) { - char *label; - ssize_t labelLen = smack_new_label_from_socket(sockFd, &label); - if (labelLen <= 0) { - throw AskUser::Protocol::CredentialsException("Couldn't fetch a smack label from a socket"); + char *label = nullptr; + int ret = cynara_creds_socket_get_client(sockFd, CLIENT_METHOD_DEFAULT, &label); + if (ret != CYNARA_API_SUCCESS || label == nullptr) { + throw AskUser::Protocol::CredentialsException( + "cynara_creds_socket_get_client() failed: " + std::to_string(ret)); } - std::unique_ptr labelPtr(label, free); - return std::string(labelPtr.get(), labelLen); + std::unique_ptr, decltype(&free)> labelPtr(label, free); + return std::string(label); } } // namespace @@ -71,7 +72,7 @@ namespace AskUser { namespace Protocol { Credentials::Credentials(int sockFd) -: label(getSmackLabelFromSocket(sockFd)) +: label(getCynaraClientFromSocket(sockFd)) , uid(getUIDFromSocket(sockFd)) , pid(getPIDFromSocket(sockFd)) {