Add unified-system-service-storaged plugin for unified system service support 23/324123/2
authorSangYoun Kwak <sy.kwak@samsung.com>
Tue, 13 May 2025 07:20:40 +0000 (16:20 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Tue, 13 May 2025 07:51:19 +0000 (16:51 +0900)
To support unified system service, plugin package is added.

storaged-unified-system-plugin rpm is newly added to install
libunified-system-service-storaged.so.
Service execution will be replaced as a library init/exit() way.
With this, unified-system-service can run system services as a thread
simultaneously.

To avoid dbus rule conflict, a part of dbus conf rule is removed as
different config file 'org.tizen.system.storage-unified-system-service.conf'.
This file will replace org.tizen.system.storage.conf by the postscript
of plugin rpm when it is installed.

Change-Id: If8339b900bd6b7aef2004a382e6a6b10eb846297
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
CMakeLists.txt
conf/org.tizen.system.storage-unified-system-service.conf [new file with mode: 0644]
packaging/storaged.spec
src/core/main.c

index 0ec484f7ef32a50d7eb3620b98b445e52d233c83..ef46f2ceb17a7ddf749eabbc368cec1898b72a64 100644 (file)
@@ -3,6 +3,7 @@ PROJECT(storaged C)
 
 SET(CMAKE_VERBOSE_MAKEFILE OFF)
 SET(STORAGED_APPS ${CMAKE_SOURCE_DIR}/apps)
+SET(LIBRARY_NAME "unified-system-service-storaged")
 
 SET(SRCS
        src/core/main.c
@@ -51,7 +52,12 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${PROJECT_NAME}_pkgs_LDFLAGS} "-ldl" "-lm")
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
 
+ADD_LIBRARY(${LIBRARY_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${PROJECT_NAME}_pkgs_LDFLAGS} "-ldl" "-lm")
+INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/org.tizen.system.storage.conf DESTINATION /etc/dbus-1/system.d)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/org.tizen.system.storage-unified-system-service.conf DESTINATION /etc/dbus-1/system.d)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/block.conf DESTINATION /etc/storaged)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/storage.conf DESTINATION /etc/storaged)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/systemd/org.tizen.system.storage.service DESTINATION /usr/share/dbus-1/system-services)
diff --git a/conf/org.tizen.system.storage-unified-system-service.conf b/conf/org.tizen.system.storage-unified-system-service.conf
new file mode 100644 (file)
index 0000000..b95c178
--- /dev/null
@@ -0,0 +1,64 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<busconfig>
+    <policy user="root">
+        <allow own="org.tizen.system.storage"/>
+        <allow send_destination="org.tizen.system.storage"/>
+    </policy>
+
+    <policy user="security_fw">
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                send_member="GetControl"/>
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                send_member="Control"/>
+    </policy>
+
+    <policy context="default">
+        <deny own="org.tizen.system.storage"/>
+
+        <!-- /Org/Tizen/System/Storage/Storage -->
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Storage"
+                send_member="GetStatus"/>
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Storage"
+                send_member="getstorage"/>
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Storage"
+                send_member="GetStatvfs"/>
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Storage"
+                send_member="GetStorageLevel"/>
+
+        <!-- /Org/Tizen/System/Storage/Block/Manager -->
+        <check send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                privilege="http://tizen.org/privilege/externalstorage"/>
+
+        <deny send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                send_member="GetControl"/>
+        <deny send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                send_member="Control"/>
+
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                send_member="ShowDeviceList"/>
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                send_member="GetDeviceList"/>
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                send_member="GetDeviceList2"/>
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                send_member="GetDeviceInfo"/>
+        <allow send_destination="org.tizen.system.storage"
+                send_path="/Org/Tizen/System/Storage/Block/Manager"
+                send_member="GetMmcPrimary"/>
+    </policy>
+</busconfig>
index b906a92214d2b633db7537b73b1fe5610ee48bbc..308bb3fb5f785bb7dab6fbdcd6ab174e59a96ad4 100644 (file)
@@ -41,6 +41,7 @@ BuildRequires:  pkgconfig(efl-extension)
 %if %{extended_storage}
 BuildRequires:  pkgconfig(ode)
 %endif
+BuildRequires:  pkgconfig(hal-api-common)
 
 #For /usr/bin/msgfmt
 BuildRequires: gettext-tools
@@ -53,6 +54,12 @@ Requires: /usr/bin/newfs_msdos
 %description
 storage daemon.
 
+%package  unified-system-plugin
+Summary:  unified-system-service plugin
+Requires: %{name} = %{version}-%{release}
+%description unified-system-plugin
+unified-system-service plugin
+
 %package  module_block
 Summary:  block module plugin
 Requires: %{name} = %{version}-%{release}
@@ -139,6 +146,10 @@ if [ "$1" == "1" ]; then
     systemctl restart storaged.service
 fi
 
+%post unified-system-plugin
+mv %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage-unified-system-service.conf \
+       %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage.conf
+
 %postun
 systemctl daemon-reload
 
@@ -154,6 +165,15 @@ systemctl daemon-reload
 %{_unitdir}/storaged.service.d/storaged.asan.conf
 %endif
 
+%files unified-system-plugin
+%manifest %{name}.manifest
+%license LICENSE.Apache-2.0
+%config %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage-unified-system-service.conf
+%{_libdir}/libunified-system-service-storaged.so
+%if "%{asan}" == "1"
+%{_unitdir}/storaged.service.d/storaged.asan.conf
+%endif
+
 %files module_block
 %manifest %{name}.manifest
 %license LICENSE.Apache-2.0
index f36de3c2b87fdb15ab0763ffbbd103f24bd3481a..08d9e8ca93dab81bf6aa13edd94c02bc7cb28109 100644 (file)
@@ -27,6 +27,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#include <unified-system-service-common.h>
+
 #include "log.h"
 #include "modules.h"
 #include "storaged_common.h"
@@ -80,21 +82,15 @@ static void dir_init(void)
 
 }
 
-int main(int argc, char **argv)
+static int storaged_init(void *data)
 {
-       int ret;
        guint timer;
+       int ret;
        dbus_handle_h handle = NULL;
 
-       loop = g_main_loop_new(NULL, TRUE);
-       if (!loop) {
-               _E("Failed to make main loop.");
-               return -ENOMEM;
-       }
-
        handle = gdbus_get_connection(G_BUS_TYPE_SYSTEM, FALSE);
        if (!handle)
-               _E("Failed to get dbus connection.");;
+               _E("Failed to get dbus connection.");
 
        dir_init();
        modules_init(NULL);
@@ -115,9 +111,38 @@ int main(int argc, char **argv)
                        _E("Failed to aw_register.");
        }
 
-       g_main_loop_run(loop);
+       return 0;
+}
 
+static int storaged_exit(void *data)
+{
        modules_deinit(NULL);
 
        return 0;
 }
+
+int main(int argc, char **argv)
+{
+       loop = g_main_loop_new(NULL, TRUE);
+       if (!loop) {
+               _E("Failed to make main loop.");
+               return -ENOMEM;
+       }
+
+       storaged_init(NULL);
+
+       g_main_loop_run(loop);
+
+       storaged_exit(NULL);
+
+       return 0;
+}
+
+__attribute__ ((visibility("default")))
+unified_system_service unified_system_service_storaged_data = {
+       .name           = "unified-system-service-storaged",
+       .early_init     = NULL,
+       .init           = storaged_init,
+       .exit           = storaged_exit,
+       .late_exit      = NULL,
+};