[daemon-fix] Changed the way of make bus address when the address is not given
[platform/upstream/dbus.git] / bus / main.c
index 970c1de..960a9c7 100644 (file)
@@ -61,10 +61,6 @@ signal_handler (int sig)
 {
   switch (sig)
     {
-#ifdef DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX
-    case SIGIO:
-      /* explicit fall-through */
-#endif /* DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX  */
 #ifdef SIGHUP
     case SIGHUP:
       {
@@ -131,7 +127,23 @@ signal_handler (int sig)
 static void
 usage (void)
 {
-  fprintf (stderr, DBUS_DAEMON_NAME " [--version] [--session] [--system] [--config-file=FILE] [--print-address[=DESCRIPTOR]] [--print-pid[=DESCRIPTOR]] [--fork] [--nofork] [--introspect] [--address=ADDRESS] [--systemd-activation] [--nopidfile]\n");
+  fprintf (stderr,
+      DBUS_DAEMON_NAME
+      " [--version]"
+      " [--session]"
+      " [--system]"
+      " [--config-file=FILE]"
+      " [--print-address[=DESCRIPTOR]]"
+      " [--print-pid[=DESCRIPTOR]]"
+      " [--introspect]"
+      " [--address=ADDRESS]"
+      " [--nopidfile]"
+      " [--nofork]"
+#ifdef DBUS_UNIX
+      " [--fork]"
+      " [--systemd-activation]"
+#endif
+      "\n");
   exit (1);
 }
 
@@ -405,19 +417,21 @@ main (int argc, char **argv)
           flags &= ~BUS_CONTEXT_FLAG_FORK_ALWAYS;
           flags |= BUS_CONTEXT_FLAG_FORK_NEVER;
         }
+#ifdef DBUS_UNIX
       else if (strcmp (arg, "--fork") == 0)
         {
           flags &= ~BUS_CONTEXT_FLAG_FORK_NEVER;
           flags |= BUS_CONTEXT_FLAG_FORK_ALWAYS;
         }
-      else if (strcmp (arg, "--nopidfile") == 0)
-        {
-          flags &= ~BUS_CONTEXT_FLAG_WRITE_PID_FILE;
-        }
       else if (strcmp (arg, "--systemd-activation") == 0)
         {
           flags |= BUS_CONTEXT_FLAG_SYSTEMD_ACTIVATION;
         }
+#endif
+      else if (strcmp (arg, "--nopidfile") == 0)
+        {
+          flags &= ~BUS_CONTEXT_FLAG_WRITE_PID_FILE;
+        }
       else if (strcmp (arg, "--system") == 0)
         {
           check_two_config_files (&config_file, "system");
@@ -631,11 +645,20 @@ main (int argc, char **argv)
 #ifdef SIGHUP
   _dbus_set_signal_handler (SIGHUP, signal_handler);
 #endif
-#ifdef DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX
-  _dbus_set_signal_handler (SIGIO, signal_handler);
-#endif /* DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX */
 #endif /* DBUS_UNIX */
 
+#ifdef ENABLE_KDBUS_TRANSPORT
+  if (bus_context_get_systemd_activation(context) == TRUE)
+    {
+      if (strncmp(bus_context_get_address(context), "kdbus:", strlen("kdbus:")) == 0 &&
+                  !strcmp(bus_context_get_type(context), "system") &&
+                  getuid() == 0)
+        {
+          kill (1, SIGUSR1);
+        }
+    }
+#endif
+
   _dbus_verbose ("We are on D-Bus...\n");
   _dbus_loop_run (bus_context_get_loop (context));