Remove smack dependency 12/325112/2 tizen
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 3 Jun 2025 11:57:53 +0000 (13:57 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 3 Jun 2025 13:59:43 +0000 (15:59 +0200)
Change-Id: I3c6b9d006abbc63ff65e8371e3d68efce3cc6306

packaging/webauthn.spec
srcs/server/service.cpp
srcs/server/service.h
srcs/server/socket-manager.h
tests/CMakeLists.txt
tests/client-request-test.cpp
tests/socket-manager-test.cpp

index 322a9725cc42d98a58cbe0444f8515cdee950169..1d96ff666f588a2a4c64dddfc46116bb13a27a25 100644 (file)
@@ -73,7 +73,9 @@ License:    Apache-2.0
 Group:      Security/Development
 BuildRequires: pkgconfig(gtest)
 BuildRequires: pkgconfig(cynara-admin)
+%if "%{?dev_wos}" != "1"
 BuildRequires: pkgconfig(libsmack)
+%endif
 Requires:      %{name} = %{version}-%{release}
 
 %description unittests
@@ -173,6 +175,9 @@ Base utils gcov objects
 %endif
 %if 0%{?no_feature_check:1} || "%_repository" == "emulator"
          -DNO_FEATURE_CHECK= \
+%endif
+%if "%{?dev_wos}" != "1"
+         -DSMACK_ENABLED=ON \
 %endif
          -DHYBRID_PLUGIN_SO_PATH=%{hybrid_plugin_so_path} \
 
index c836d8ed6bd654630e1181acc6cfc361b9cd3cc2..97699fe993f9d69579c58a3b66a858c4a007d33c 100644 (file)
@@ -28,9 +28,9 @@
 #include <utils.h>
 #include <array>
 
+#include "cynara.h"
 #include "request-mc.h"
 #include "request-ga.h"
-#define SMACK_LABEL_LEN 255
 
 namespace WA {
 
@@ -230,7 +230,8 @@ int GenericService::CheckBusyAndCred(SocketManager::ConnectionID connectionID)
             LogError("Error on get credentials");
             return -1;
         }
-        if (m_credentials.smack == nowCreds.smack && m_credentials.cred.pid == nowCreds.cred.pid)
+        if (m_credentials.cynaraClient == nowCreds.cynaraClient &&
+            m_credentials.cred.pid == nowCreds.cred.pid)
         {
             return 1;
         }
@@ -279,15 +280,10 @@ int GenericService::GetCredentials(SocketManager::ConnectionID connectionID, Cre
     }
     LogDebug("Client PID: " << creds->cred.pid);
 
-    std::vector<char> result(SMACK_LABEL_LEN + 1);
-    length = SMACK_LABEL_LEN;
-    if (0 != (ret = getsockopt(connectionID.sock, SOL_SOCKET, SO_PEERSEC, result.data(), &length)))
-    {
-        LogError("getsockopt for get smack label failed" << get_error_message(ret));
+    if (!Cynara::GetClientFromSocket(connectionID.sock, creds->cynaraClient))
         return -1;
-    }
-    creds->smack.assign(result.data(), length);
-    LogDebug("Client Smack: " << creds->smack);
+
+    LogDebug("Cynara client: " << creds->cynaraClient);
     return 0;
 }
 
index 6c0555745bb9b217522f66e57ea49644b2b80267..a439e3ec6eeb4f646dde34ecd9f3da8c73615dd2 100644 (file)
@@ -43,7 +43,7 @@ struct Event {
     MessageBuffer buffer;
 };
 struct Cred {
-    std::string smack;
+    std::string cynaraClient;
     ucred cred;
 };
 
@@ -115,7 +115,7 @@ private:
     int SetCredentials(SocketManager::ConnectionID connectionID);
 
     /**
-     * Get credentials for the connection. The smack label and process ID used to the credentials.
+     * Get credentials for the connection. The cynara client and process ID used to the credentials.
      * @param[in] connectionID Socket information for the connection
      * @param[out] creds Credentials for the connection
      * @return @c 0 on success,
@@ -142,7 +142,6 @@ public:
     SocketManager::ServiceDescription GetServiceDescription() override {
         return SocketManager::ServiceDescription {
             SERVICE_SOCKET,  /* path */
-            "*"              /* smackLabel label (not used, we rely on systemd) */
         };
     }
 };
index 1e51a6875213d88a9bcbddb140e615531dcc8838..6c76ec9abe452d6d1f3fef75df9041a1458c4a13 100644 (file)
@@ -39,7 +39,6 @@ class SocketManager final {
 public:
     struct ServiceDescription {
         std::string serviceHandlerPath; // Path to file
-        std::string smackLabel;         // Smack label for socket
     };
 
     struct ConnectionID {
index b1157f6b92b29ef4a3fced7fef378c08223d4386..7e03141af8bd4b1a051ceb6a37a72e1ef7c133b3 100644 (file)
 # @file        CMakeLists.txt
 #
 
-PKG_CHECK_MODULES(UNIT_TESTS_DEPS
-    REQUIRED
+SET(UNIT_TESTS_DEP_LIST
     dlog
     gtest
     libsystemd
-    libsmack
     cynara-client
     cynara-creds-socket
     cynara-admin
     )
 
+IF (SMACK_ENABLED)
+    SET(UNIT_TESTS_DEP_LIST ${UNIT_TESTS_DEP_LIST} libsmack)
+ENDIF (SMACK_ENABLED)
+
+PKG_CHECK_MODULES(UNIT_TESTS_DEPS
+    REQUIRED
+    ${UNIT_TESTS_DEP_LIST}
+    )
+
 IF(GCOV_BUILD)
     # coverage data
     SET(COVERAGE_BUILD_DIR
@@ -58,7 +65,6 @@ SET(UNIT_TESTS_SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/socket-manager-test.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/utils-tests.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/cynara-adm.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/privilege-tests.cpp
 
     ${PRJ_SRC_SERVER_PATH}/dl-loader.cpp
     ${PRJ_SRC_SERVER_PATH}/service.cpp
@@ -66,6 +72,10 @@ SET(UNIT_TESTS_SOURCES
     ${PRJ_SRC_SERVER_PATH}/cynara.cpp
 )
 
+IF (SMACK_ENABLED)
+    SET(UNIT_TESTS_SOURCES ${UNIT_TESTS_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/privilege-tests.cpp)
+ENDIF (SMACK_ENABLED)
+
 SET_SOURCE_FILES_PROPERTIES(
     ${UNIT_TESTS_SOURCES}
     PROPERTIES
index 593f489d5abfd40ee982f1c38b4e0ed4f91440c1..3cd7a4fbb4ed9dcd319ac1f7ffec659678882acb 100644 (file)
@@ -177,7 +177,6 @@ public:
     SocketManager::ServiceDescription GetServiceDescription() override {
         return SocketManager::ServiceDescription {
             TEST_SERVICE_SOCKET,  /* path */
-            "*"              /* smackLabel label (not used, we rely on systemd) */
     };
     }
     TestService(std::shared_ptr<DLLoader> pluginHybrid) :
index 59c77d1bb15ed87985a77bde6d572e56e343e5fc..296f3e896a7f74bdda981c78eb2617f5efe00e2f 100644 (file)
@@ -34,7 +34,6 @@ public:
     SocketManager::ServiceDescription GetServiceDescription() override {
         return SocketManager::ServiceDescription {
             TEST_SERVICE_SOCKET,  /* path */
-            "*"              /* smackLabel label (not used, we rely on systemd) */
     };
     }
     TestService(std::shared_ptr<DLLoader> pluginHybrid) :