Remove smack dependency 13/325113/1 tizen
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 3 Jun 2025 13:18:55 +0000 (15:18 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 3 Jun 2025 13:18:55 +0000 (15:18 +0200)
Change-Id: Id5e87f11efa440a41e1d5a74c2ed9a7472f296ed

packaging/askuser-notification.spec
src/common/policy/Policy.cpp
src/ipc/CMakeLists.txt
src/ipc/credentials.cpp

index fe6e7e63ca677439ac0e50e06341a74b2494ca46..f84cf9b0e391ab3903d76247033bb183b58b72ed 100644 (file)
@@ -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"
index adbac146461e01d30e1913caf12a8e1591b8b8a2..fe988778c659f997e04aa27b67196cd1bb5a7602 100644 (file)
@@ -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<char, decltype(free)*> pkg_name_p(pkgName, free);
     std::unique_ptr<char, decltype(free)*> app_name_p(appName, free);
-    throwOnSMError("security_manager_identify_app_from_pid", ret);
 
     if (!appName)
         return pkgInfo.mainAppId(pkgName, geteuid());
index 0558dc04c89f7a484bbd2b718bc151568bf82dee..cd2005ced26679b747f6c9e64cefd2ec7b9abce1 100644 (file)
@@ -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})
index 337bf08c57e92531c92afeac44dc7f053b577117..78b2e27701c6d5b8f07a65f45350a8da5e54ba4b 100644 (file)
@@ -21,8 +21,8 @@
 
 #include <memory>
 #include <stdlib.h>
-#include <sys/smack.h>
 #include <sys/socket.h>
+#include <cynara-creds-socket.h>
 
 #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<char, decltype(free)*> labelPtr(label, free);
-    return std::string(labelPtr.get(), labelLen);
+    std::unique_ptr<std::remove_pointer_t<decltype(label)>, 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))
 {