chiark / gitweb /
Remove unused variables
[elogind.git] / src / core / manager.c
index f69ae079df6f0e432dc2a0d4f248974f3eb35e41..bbe5efa560a4500a604f9aa37b6b44f5430d8b1e 100644 (file)
@@ -538,10 +538,6 @@ static int manager_setup_kdbus(Manager *m) {
         if (m->kdbus_fd >= 0)
                 return 0;
 
-        /* If there's already a bus address set, don't set up kdbus */
-        if (m->running_as == SYSTEMD_USER && getenv("DBUS_SESSION_BUS_ADDRESS"))
-                return 0;
-
         m->kdbus_fd = bus_kernel_create_bus(m->running_as == SYSTEMD_SYSTEM ? "system" : "user", m->running_as == SYSTEMD_SYSTEM, &p);
         if (m->kdbus_fd < 0) {
                 log_debug("Failed to set up kdbus: %s", strerror(-m->kdbus_fd));
@@ -554,7 +550,8 @@ static int manager_setup_kdbus(Manager *m) {
          * of that directory is not visible to non-root users. This is
          * necessary to ensure that users cannot get access to busses
          * of virtualized users when no UID namespacing is used. */
-        mkdir_p_label("/dev/kdbus/ns", 0700);
+        if (m->running_as == SYSTEMD_SYSTEM)
+                mkdir_p_label("/dev/kdbus/ns", 0700);
 #endif
 
         return 0;
@@ -1334,7 +1331,7 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
                 if (!u) {
                         u = manager_get_unit_by_pid(m, ucred->pid);
                         if (!u) {
-                                log_warning("Cannot find unit for notify message of PID %lu.", (unsigned long) ucred->pid);
+                                log_warning("Cannot find unit for notify message of PID "PID_FMT".", ucred->pid);
                                 continue;
                         }
                 }
@@ -1382,7 +1379,7 @@ static int manager_dispatch_sigchld(Manager *m) {
                         _cleanup_free_ char *name = NULL;
 
                         get_process_comm(si.si_pid, &name);
-                        log_debug("Got SIGCHLD for process %lu (%s)", (unsigned long) si.si_pid, strna(name));
+                        log_debug("Got SIGCHLD for process "PID_FMT" (%s)", si.si_pid, strna(name));
                 }
 
                 /* And now figure out the unit this belongs to */
@@ -1463,16 +1460,22 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
                 }
 
                 if (sfsi.ssi_pid > 0) {
-                        char *p = NULL;
+                        _cleanup_free_ char *p = NULL;
 
                         get_process_comm(sfsi.ssi_pid, &p);
 
-                        log_debug("Received SIG%s from PID %lu (%s).",
-                                  signal_to_string(sfsi.ssi_signo),
-                                  (unsigned long) sfsi.ssi_pid, strna(p));
-                        free(p);
+                        log_full(sfsi.ssi_signo == SIGCHLD ||
+                                 (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
+                                 ? LOG_DEBUG : LOG_INFO,
+                                 "Received SIG%s from PID "PID_FMT" (%s).",
+                                 signal_to_string(sfsi.ssi_signo),
+                                 sfsi.ssi_pid, strna(p));
                 } else
-                        log_debug("Received SIG%s.", signal_to_string(sfsi.ssi_signo));
+                        log_full(sfsi.ssi_signo == SIGCHLD ||
+                                 (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
+                                 ? LOG_DEBUG : LOG_INFO,
+                                 "Received SIG%s.",
+                                 signal_to_string(sfsi.ssi_signo));
 
                 switch (sfsi.ssi_signo) {
 
@@ -1968,9 +1971,9 @@ int manager_open_serialization(Manager *m, FILE **_f) {
         assert(_f);
 
         if (m->running_as == SYSTEMD_SYSTEM)
-                asprintf(&path, "/run/systemd/dump-%lu-XXXXXX", (unsigned long) getpid());
+                asprintf(&path, "/run/systemd/dump-"PID_FMT"-XXXXXX", getpid());
         else
-                asprintf(&path, "/tmp/systemd-dump-%lu-XXXXXX", (unsigned long) getpid());
+                asprintf(&path, "/tmp/systemd-dump-"PID_FMT"-XXXXXX", getpid());
 
         if (!path)
                 return -ENOMEM;
@@ -2448,9 +2451,9 @@ void manager_check_finished(Manager *m) {
                         if (!log_on_console())
                                 log_struct(LOG_INFO,
                                            MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
-                                           "KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
-                                           "INITRD_USEC=%llu", (unsigned long long) initrd_usec,
-                                           "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
+                                           "KERNEL_USEC="USEC_FMT, kernel_usec,
+                                           "INITRD_USEC="USEC_FMT, initrd_usec,
+                                           "USERSPACE_USEC="USEC_FMT, userspace_usec,
                                            "MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.",
                                            format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
                                            format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC),
@@ -2464,8 +2467,8 @@ void manager_check_finished(Manager *m) {
                         if (!log_on_console())
                                 log_struct(LOG_INFO,
                                            MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
-                                           "KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
-                                           "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
+                                           "KERNEL_USEC="USEC_FMT, kernel_usec,
+                                           "USERSPACE_USEC="USEC_FMT, userspace_usec,
                                            "MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.",
                                            format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
                                            format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
@@ -2479,7 +2482,7 @@ void manager_check_finished(Manager *m) {
                 if (!log_on_console())
                         log_struct(LOG_INFO,
                                    MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
-                                   "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
+                                   "USERSPACE_USEC="USEC_FMT, userspace_usec,
                                    "MESSAGE=Startup finished in %s.",
                                    format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
                                    NULL);