chiark / gitweb /
core: store and expose SELinuxContext field normalized as bool + string
[elogind.git] / src / core / manager.c
index b58b98c137eb655f6d4a6b20cd28cc32bcb2c549..388697cdf57e40060d12d4f55750f37483f18596 100644 (file)
@@ -1532,23 +1532,10 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
                         return -errno;
                 }
 
-                if (sfsi.ssi_pid > 0) {
-                        _cleanup_free_ char *p = NULL;
-
-                        get_process_comm(sfsi.ssi_pid, &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_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));
+                log_received_signal(sfsi.ssi_signo == SIGCHLD ||
+                                    (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
+                                    ? LOG_DEBUG : LOG_INFO,
+                                    &sfsi);
 
                 switch (sfsi.ssi_signo) {
 
@@ -1916,7 +1903,7 @@ int manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j) {
 void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
 
 #ifdef HAVE_AUDIT
-        char *p;
+        _cleanup_free_ char *p = NULL;
         int audit_fd;
 
         audit_fd = get_audit_fd();
@@ -1949,17 +1936,19 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
                 } else
                         log_warning("Failed to send audit message: %m");
         }
-
-        free(p);
 #endif
 
 }
 
 void manager_send_unit_plymouth(Manager *m, Unit *u) {
-        int fd = -1;
-        union sockaddr_union sa;
+        union sockaddr_union sa = {
+                .un.sun_family = AF_UNIX,
+                .un.sun_path = "\0/org/freedesktop/plymouthd",
+        };
+
         int n = 0;
-        char *message = NULL;
+        _cleanup_free_ char *message = NULL;
+        _cleanup_close_ int fd = -1;
 
         /* Don't generate plymouth events if the service was already
          * started and we're just deserializing */
@@ -1985,46 +1974,22 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
                 return;
         }
 
-        zero(sa);
-        sa.sa.sa_family = AF_UNIX;
-        strncpy(sa.un.sun_path+1, "/org/freedesktop/plymouthd", sizeof(sa.un.sun_path)-1);
         if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(sa.un.sun_path+1)) < 0) {
 
-                if (errno != EPIPE &&
-                    errno != EAGAIN &&
-                    errno != ENOENT &&
-                    errno != ECONNREFUSED &&
-                    errno != ECONNRESET &&
-                    errno != ECONNABORTED)
+                if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED))
                         log_error("connect() failed: %m");
-
-                goto finish;
+                return;
         }
 
         if (asprintf(&message, "U\002%c%s%n", (int) (strlen(u->id) + 1), u->id, &n) < 0) {
                 log_oom();
-                goto finish;
+                return;
         }
 
         errno = 0;
-        if (write(fd, message, n + 1) != n + 1) {
-
-                if (errno != EPIPE &&
-                    errno != EAGAIN &&
-                    errno != ENOENT &&
-                    errno != ECONNREFUSED &&
-                    errno != ECONNRESET &&
-                    errno != ECONNABORTED)
+        if (write(fd, message, n + 1) != n + 1)
+                if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED))
                         log_error("Failed to write Plymouth message: %m");
-
-                goto finish;
-        }
-
-finish:
-        if (fd >= 0)
-                close_nointr_nofail(fd);
-
-        free(message);
 }
 
 void manager_dispatch_bus_name_owner_changed(