]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/dbus.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / core / dbus.c
index 0493e5786c5de22624e2f6665667d8c955727b2d..b7d8af9396a6a8be1d87318b216dc01836fabff7 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -92,7 +93,7 @@ int bus_forward_agent_released(Manager *m, const char *path) {
                                "Released",
                                "s", path);
         if (r < 0)
-                return log_warning_errno(r, "Failed to propagate agent release message: %m");
+                return log_debug_errno(r, "Failed to propagate agent release message: %m");
 
         return 1;
 }
@@ -211,7 +212,7 @@ failed:
         return 0;
 }
 
-#ifdef HAVE_SELINUX
+#if HAVE_SELINUX
 static int mac_selinux_filter(sd_bus_message *message, void *userdata, sd_bus_error *error) {
         Manager *m = userdata;
         const char *verb, *path;
@@ -298,7 +299,7 @@ static int bus_job_find(sd_bus *bus, const char *path, const char *interface, vo
 }
 
 static int find_unit(Manager *m, sd_bus *bus, const char *path, Unit **unit, sd_bus_error *error) {
-        Unit *u;
+        Unit *u = NULL;  /* just to appease gcc, initialization is not really necessary */
         int r;
 
         assert(m);
@@ -323,15 +324,15 @@ static int find_unit(Manager *m, sd_bus *bus, const char *path, Unit **unit, sd_
                         return r;
 
                 u = manager_get_unit_by_pid(m, pid);
+                if (!u)
+                        return 0;
         } else {
                 r = manager_load_unit_from_dbus_path(m, path, error, &u);
                 if (r < 0)
                         return 0;
+                assert(u);
         }
 
-        if (!u)
-                return 0;
-
         *unit = u;
         return 1;
 }
@@ -535,7 +536,7 @@ static int bus_setup_api_vtables(Manager *m, sd_bus *bus) {
         assert(m);
         assert(bus);
 
-#ifdef HAVE_SELINUX
+#if HAVE_SELINUX
         r = sd_bus_add_filter(bus, NULL, mac_selinux_filter, m);
         if (r < 0)
                 return log_error_errno(r, "Failed to add SELinux access filter: %m");
@@ -753,13 +754,13 @@ int manager_sync_bus_names(Manager *m, sd_bus *bus) {
                         /* If it is, determine its current owner */
                         r = sd_bus_get_name_creds(bus, name, SD_BUS_CREDS_UNIQUE_NAME, &creds);
                         if (r < 0) {
-                                log_error_errno(r, "Failed to get bus name owner %s: %m", name);
+                                log_full_errno(r == -ENXIO ? LOG_DEBUG : LOG_ERR, r, "Failed to get bus name owner %s: %m", name);
                                 continue;
                         }
 
                         r = sd_bus_creds_get_unique_name(creds, &unique);
                         if (r < 0) {
-                                log_error_errno(r, "Failed to get unique name for %s: %m", name);
+                                log_full_errno(r == -ENXIO ? LOG_DEBUG : LOG_ERR, r, "Failed to get unique name for %s: %m", name);
                                 continue;
                         }
 
@@ -967,7 +968,7 @@ static int bus_init_private(Manager *m) {
         if (MANAGER_IS_SYSTEM(m)) {
 
                 /* We want the private bus only when running as init */
-                if (getpid() != 1)
+                if (getpid_cached() != 1)
                         return 0;
 
                 strcpy(sa.un.sun_path, "/run/systemd/private");