Fix TIVI-2638 Enable SmackExecLabel=User for messageport 79/15579/2
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Thu, 23 Jan 2014 12:37:19 +0000 (14:37 +0200)
committerAmarnath Valluri <amarnath.valluri@linux.intel.com>
Fri, 24 Jan 2014 07:59:57 +0000 (09:59 +0200)
Support for invoking messageport daemon by systemd with correct smack label.

This commit is also having the supported changes :
 - Stop using session bus for invoking, and fix tests in non-session-bus case.
 - change in daemon socket location : /run/user/@usern_name@ -> /tmp.
   As user specific folder is not created at the time of daemon startup

Change-Id: Ibd885e522970aa63241792258e4a32a0bf32cfbb

configure.ac
messageportd.service.in [new file with mode: 0644]
packaging/message-port.spec
tests/test-app.c
tests/test-app.cpp

index 8c449e5..6d3b9d7 100644 (file)
@@ -44,7 +44,7 @@ AC_SUBST(DLOG_CFLAGS)
 AC_SUBST(DLOG_LIBS)
 
 AC_DEFINE(MESSAGEPORT_BUS_ADDRESS, 
-         ["unix:path=%s/.message-port", g_get_user_runtime_dir()],
+         ["unix:path=%s/.message-port", "/tmp"],
          [messageport daemon server socket address])
 
 # Use Session bus for daemon activation
@@ -91,6 +91,7 @@ common/Makefile
 daemon/Makefile
 lib/Makefile
 lib/message-port.pc
+messageportd.service
 ])
 
 if test "x$enable_sessionbus" = "xyes"; then
diff --git a/messageportd.service.in b/messageportd.service.in
new file mode 100644 (file)
index 0000000..bb2aef1
--- /dev/null
@@ -0,0 +1,13 @@
+[Unit]
+Description=Messageport Daemon
+
+[Service]
+Type=simple
+User=app
+SmackExecLabel=User
+KillSignal=SIGTERM
+Restart=always
+ExecStart=@prefix@/bin/messageportd
+
+[Install]
+WantedBy=multi-user.target
index d776515..c373668 100644 (file)
@@ -1,6 +1,8 @@
 
 %define build_tests 1
-%define use_session_bus 1
+%define use_session_bus 0
+%define systemddir /lib/systemd
+
 Name: message-port
 Summary: Message port daemon
 Version: 1.0.0
@@ -78,6 +80,14 @@ make %{?_smp_mflags}
 %install
 %make_install
 
+mkdir -p ${RPM_BUILD_ROOT}%{systemddir}/system
+cp messageportd.service $RPM_BUILD_ROOT%{systemddir}/system
+
+%post
+/bin/systemctl enable messageportd.service
+
+%postun
+/bin/systemctl disable messageportd.service
 
 %post -n lib%{name}
 /sbin/ldconfig
@@ -94,7 +104,7 @@ make %{?_smp_mflags}
 %{_datadir}/dbus-1/services/org.tizen.messageport.service
 %manifest %{name}.manifest
 %endif
-
+%{systemddir}/system/messageportd.service
 
 # libmessage-port
 %files -n lib%{name}
index 9376974..c5584c5 100644 (file)
@@ -400,6 +400,7 @@ _on_term (gpointer userdata)
 static gboolean
 test_setup ()
 {
+#ifdef USE_SESSION_BUS
     GIOChannel *channel = NULL;
     gchar *bus_address = NULL;
     gint tmp_fd = 0;
@@ -445,6 +446,7 @@ test_setup ()
     g_print ("Dbus daemon start at : %s\n", bus_address);
 
     g_free (bus_address);
+#endif /* USE_SESSION_BUS */
 
     return TRUE;
 }
@@ -452,7 +454,9 @@ test_setup ()
 static void
 test_cleanup ()
 {
+#ifdef USE_SESSION_BUS
    if (__daemon_pid) kill (__daemon_pid, SIGTERM);
+#endif /* USE_SESSION_BUS */
 }
 
 
index e6a9053..d1746d0 100644 (file)
@@ -478,6 +478,7 @@ _on_term (gpointer userdata)
 static bool
 test_setup ()
 {
+#ifdef USE_SESSION_BUS
     GIOChannel *channel = NULL;
     gchar *bus_address = NULL;
     gint tmp_fd = 0;
@@ -524,6 +525,7 @@ test_setup ()
     setenv("DBUS_SESSION_BUS_ADDRESS", bus_address, TRUE);
 
     g_free (bus_address);
+#endif /* USE_SESSION_BUS */
 
     return true;
 }
@@ -531,7 +533,9 @@ test_setup ()
 static void
 test_cleanup ()
 {
+#ifdef USE_SESSION_BUS
     if (__daemon_pid) kill (__daemon_pid, SIGTERM);
+#endif /* USE_SESSION_BUS */
 }
 
 int main (int argc, const char *argv[])