Change package name: systemd-user-helper ==> dbus-activation-stop-test 35/243135/1
authorINSUN PYO <insun.pyo@samsung.com>
Thu, 3 Sep 2020 08:39:12 +0000 (17:39 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Thu, 3 Sep 2020 08:39:12 +0000 (17:39 +0900)
Change-Id: I3762fb80c94121f553d1af637ab5f1a7e6a140b0

CMakeLists.txt
packaging/session-utils.spec
src/dbus-activation-stop-test/CMakeLists.txt [new file with mode: 0644]
src/dbus-activation-stop-test/dbus-activation-stop-test.c [new file with mode: 0644]
src/systemd-user-helper/CMakeLists.txt [deleted file]
src/systemd-user-helper/systemd-user-helper.c [deleted file]
systemd-user-helper.service [deleted file]
units/dbus-activation-stop-test.conf [new file with mode: 0644]
units/dbus-activation-stop-test.service [new file with mode: 0644]

index 2f27d51d392995e6503a7ecd7df57251fddebdb6..36312fba8c793072caad0cdc196b45f298869688 100644 (file)
@@ -3,4 +3,4 @@ PROJECT(session-utils C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
-ADD_SUBDIRECTORY(src/systemd-user-helper)
+ADD_SUBDIRECTORY(src/dbus-activation-stop-test)
index 2f002bc6c1a467a53de511ac0ee2aeed25b15368..5fdd3963695e54e5efc223973021d89f2a25b2f5 100644 (file)
@@ -23,6 +23,15 @@ BuildArch: noarch
 %description -n g_debug_fatal_warnings
 This package provices the configuration file that enable glib debugging.
 
+
+###############################################################################
+%package -n dbus-activation-stop-test
+Summary: dbus activation stop test.
+
+%description -n dbus-activation-stop-test
+This package provices the test code of dbus activation stopping.
+
+
 ###############################################################################
 %prep
 %setup -q
@@ -44,15 +53,24 @@ install -m 644 units/g_debug_fatal_warnings.conf %{buildroot}/etc/systemd/user.c
 install -m 644 units/g_debug_fatal_warnings.conf %{buildroot}/etc/systemd/system.conf.d/
 
 mkdir -p %{buildroot}%{_unitdir}
-cp systemd-user-helper.service %{buildroot}%{_unitdir}/
+mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
+install -m 644 units/dbus-activation-stop-test.service %{buildroot}%{_unitdir}/
+install -m 644 units/dbus-activation-stop-test.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/
 
 
 ###############################################################################
 %files
 %license LICENSE.Apache-2.0
 %manifest session-utils.manifest
-%{_bindir}/systemd-user-helper
-%{_unitdir}/systemd-user-helper.service
+
+
+###############################################################################
+%files -n dbus-activation-stop-test
+%license LICENSE.Apache-2.0
+%manifest session-utils.manifest
+%config %{_sysconfdir}/dbus-1/system.d/dbus-activation-stop-test.conf
+%{_bindir}/dbus-activation-stop-test
+%{_unitdir}/dbus-activation-stop-test.service
 
 
 ###############################################################################
diff --git a/src/dbus-activation-stop-test/CMakeLists.txt b/src/dbus-activation-stop-test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..857dad3
--- /dev/null
@@ -0,0 +1,22 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(dbus-activation-stop-test C)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+  glib-2.0
+  gio-2.0
+  libsystemd
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+
+ADD_EXECUTABLE(${PROJECT_NAME} dbus-activation-stop-test.c)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -pie)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin
+               PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+               GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
diff --git a/src/dbus-activation-stop-test/dbus-activation-stop-test.c b/src/dbus-activation-stop-test/dbus-activation-stop-test.c
new file mode 100644 (file)
index 0000000..fe0036f
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <glib-unix.h>
+
+#include <systemd/sd-daemon.h>
+
+int owner_id;
+static GMainLoop *mainloop;
+
+static void sig_term(int signo)
+{
+       fprintf (stderr, "sig term\n");
+}
+
+static void sig_abort(int signo)
+{
+       fprintf (stderr, "sig abort\n");
+
+       sd_notify(0, "STOPPING=1");
+       g_bus_unown_name (owner_id);
+}
+
+static void sig_quit(int signo)
+{
+       fprintf (stderr, "sig quit\n");
+
+       g_main_loop_quit(mainloop);
+}
+
+static void name_acquire(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+       fprintf (stderr, "name acquire : %s\n", name);
+}
+
+static void name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+       fprintf (stderr, "name lost : %s\n", name);
+}
+
+int main(int argc, char *argv[])
+{
+       GError *err = NULL;
+       GDBusConnection *conn = NULL;
+
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (!conn || err) {
+               fprintf (stderr, "failed to get system bus\n");
+               return -1;
+       }
+
+       owner_id = g_bus_own_name_on_connection(conn, "org.tizen.dbus-activation-stop-test", G_BUS_NAME_OWNER_FLAGS_NONE,
+                                                                                       name_acquire, name_lost, NULL, NULL);
+
+       if (owner_id == 0) {
+               fprintf (stderr, "g_bus_own_name_on_connection fails\n");
+               return -1;
+       }
+
+       signal(SIGQUIT, sig_quit);
+       signal(SIGABRT, sig_abort);
+       signal(SIGTERM, sig_term);
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(mainloop);
+
+       return 0;
+}
diff --git a/src/systemd-user-helper/CMakeLists.txt b/src/systemd-user-helper/CMakeLists.txt
deleted file mode 100644 (file)
index 3be879b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(systemd-user-helper C)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED
-  glib-2.0
-  gio-2.0
-  libsystemd
-)
-
-FOREACH(flag ${pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
-
-ADD_EXECUTABLE(${PROJECT_NAME} systemd-user-helper.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -pie)
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin
-               PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
-               GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
diff --git a/src/systemd-user-helper/systemd-user-helper.c b/src/systemd-user-helper/systemd-user-helper.c
deleted file mode 100644 (file)
index 9bca4b4..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <signal.h>
-#include <unistd.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-#include <glib-unix.h>
-
-#include <systemd/sd-daemon.h>
-
-int id;
-static GMainLoop *mainloop;
-
-static void sig_term(int signo)
-{
-       fprintf (stderr, "sig term\n");
-}
-
-static void sig_abort(int signo)
-{
-       fprintf (stderr, "sig abort\n");
-
-       sd_notify(0, "STOPPING=1");
-       g_bus_unown_name (id);
-}
-
-static void sig_quit(int signo)
-{
-       fprintf (stderr, "sig quit\n");
-
-       g_main_loop_quit(mainloop);
-}
-
-static void name_acquire(GDBusConnection *connection, const gchar *name, gpointer user_data)
-{
-       fprintf (stderr, "name acquire : %s\n", name);
-}
-
-static void name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
-{
-       fprintf (stderr, "name lost : %s\n", name);
-}
-
-int main(int argc, char *argv[])
-{
-       GError *err = NULL;
-       GDBusConnection *conn = NULL;
-
-       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (!conn || err) {
-               fprintf (stderr, "failed to get system bus\n");
-               return -1;
-       }
-
-       id = g_bus_own_name_on_connection(conn, "org.tizen.myname", G_BUS_NAME_OWNER_FLAGS_NONE,
-                                                                         name_acquire, name_lost, NULL, NULL);
-
-       if (id == 0) {
-               fprintf (stderr, "g_bus_own_name_on_connection fails\n");
-               return -1;
-       }
-
-       signal(SIGQUIT, sig_quit);
-       signal(SIGABRT, sig_abort);
-       signal(SIGTERM, sig_term);
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-       g_main_loop_run(mainloop);
-
-       return 0;
-}
diff --git a/systemd-user-helper.service b/systemd-user-helper.service
deleted file mode 100644 (file)
index a587f45..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[Unit]
-Description=systemd user helper
-
-[Service]
-SmackProcessLabel=System
-Type=dbus
-BusName=org.tizen.myname
-ExecStart=/usr/bin/systemd-user-helper
-NotifyAccess=main
diff --git a/units/dbus-activation-stop-test.conf b/units/dbus-activation-stop-test.conf
new file mode 100644 (file)
index 0000000..c683a05
--- /dev/null
@@ -0,0 +1,12 @@
+<!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.dbus-activation-stop-test"/>
+        <allow send_destination="org.tizen.dbus-activation-stop-test"/>
+    </policy>
+    <policy context="default">
+        <deny own="org.tizen.dbus-activation-stop-test"/>
+        <deny send_destination="org.tizen.dbus-activation-stop-test"/>
+    </policy>
+</busconfig>
diff --git a/units/dbus-activation-stop-test.service b/units/dbus-activation-stop-test.service
new file mode 100644 (file)
index 0000000..7a74f1e
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=dbus activation stop test
+
+[Service]
+Type=dbus
+BusName=org.tizen.dbus-activation-stop-test
+ExecStart=/usr/bin/dbus-activation-stop-test
+NotifyAccess=main
+SmackProcessLabel=System
\ No newline at end of file