]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bus-util: rename bus_open_transport() to bus_connect_transport()
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Sep 2015 11:30:10 +0000 (13:30 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 29 Sep 2015 19:55:52 +0000 (21:55 +0200)
In sd-bus, the sd_bus_open_xyz() family of calls allocates a new bus,
while sd_bus_default_xyz() family tries to reuse the thread's default
bus. bus_open_transport() sometimes internally uses the former,
sometimes the latter family, but suggests it only calls the former via
its name. Hence, let's avoid this confusion, and generically rename the
call to bus_connect_transport().

Similar for all related calls.

And while we are at it, also change cgls + cgtop to do direct systemd
connections where possible, since all they do is talk to systemd itself.

17 files changed:
src/analyze/analyze.c
src/cgls/cgls.c
src/cgroups-agent/cgroups-agent.c
src/cgtop/cgtop.c
src/fsck/fsck.c
src/hostname/hostnamectl.c
src/initctl/initctl.c
src/journal/journalctl.c
src/locale/localectl.c
src/login/loginctl.c
src/machine/machinectl.c
src/run/run.c
src/shared/bus-util.c
src/shared/bus-util.h
src/systemctl/systemctl.c
src/timedate/timedatectl.c
src/update-utmp/update-utmp.c

index c8ace3778ed9184dab097e715647ae616222ff22..7054deeae51ed541a457768a247f511e082b8314 100644 (file)
@@ -1432,7 +1432,7 @@ int main(int argc, char *argv[]) {
         else {
                 _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
 
-                r = bus_open_transport_systemd(arg_transport, arg_host, arg_user, &bus);
+                r = bus_connect_transport_systemd(arg_transport, arg_host, arg_user, &bus);
                 if (r < 0) {
                         log_error_errno(r, "Failed to create bus connection: %m");
                         goto finish;
index d3a5a4df28ad8c3201717202fafc10e8323ac949..41c539a1bc5055b214f00ba88e57d3eed3eee835 100644 (file)
@@ -145,7 +145,7 @@ static int get_cgroup_root(char **ret) {
         if (!path)
                 return log_oom();
 
-        r = bus_open_transport(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
+        r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
         if (r < 0)
                 return log_error_errno(r, "Failed to create bus connection: %m");
 
index 612bc8fdec7ad9f8ca7b8a32ebd27a804108a76e..b79519dd09726fd19ae1445e77b9d5003077b7cc 100644 (file)
@@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {
          * this to avoid an activation loop when we start dbus when we
          * are called when the dbus service is shut down. */
 
-        r = bus_open_system_systemd(&bus);
+        r = bus_connect_system_systemd(&bus);
         if (r < 0) {
                 /* If we couldn't connect we assume this was triggered
                  * while systemd got restarted/transitioned from
index b404c8361652308ebcb0e88466bc1dae57c8ec41..ad9cd2532f990767380d4361a5aa6f46ff009c00 100644 (file)
@@ -861,7 +861,7 @@ static int get_cgroup_root(char **ret) {
         if (!path)
                 return log_oom();
 
-        r = bus_open_transport(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
+        r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
         if (r < 0)
                 return log_error_errno(r, "Failed to create bus connection: %m");
 
index bd3051f30dcd0e9dc417b685f0063a45d832e334..8e790b85aef4e078f72b7896072a40f892d946ac 100644 (file)
@@ -67,7 +67,7 @@ static void start_target(const char *target) {
 
         assert(target);
 
-        r = bus_open_system_systemd(&bus);
+        r = bus_connect_system_systemd(&bus);
         if (r < 0) {
                 log_error_errno(r, "Failed to get D-Bus connection: %m");
                 return;
index 7974683179f927dff62d2ae8180f0c57dc3d35f1..0724fcc16dbe88036596ebddc1e090c103e6bbc2 100644 (file)
@@ -517,7 +517,7 @@ int main(int argc, char *argv[]) {
         if (r <= 0)
                 goto finish;
 
-        r = bus_open_transport(arg_transport, arg_host, false, &bus);
+        r = bus_connect_transport(arg_transport, arg_host, false, &bus);
         if (r < 0) {
                 log_error_errno(r, "Failed to create bus connection: %m");
                 goto finish;
index 6d08db74ef8fd7a1834f7dca1b08d907e9db9e82..2d5f7501e7b013e7c04fe0c1746674adcf4bb848 100644 (file)
@@ -318,7 +318,7 @@ static int server_init(Server *s, unsigned n_sockets) {
                 s->n_fifos ++;
         }
 
-        r = bus_open_system_systemd(&s->bus);
+        r = bus_connect_system_systemd(&s->bus);
         if (r < 0) {
                 log_error_errno(r, "Failed to get D-Bus connection: %m");
                 r = -EIO;
index de67a9687cc4d0df5814ce5388ba71c32454054d..75e59dbd42fa92631fe5946e624d075f4c8c1bb0 100644 (file)
@@ -1722,7 +1722,7 @@ static int flush_to_var(void) {
 
         /* OK, let's actually do the full logic, send SIGUSR1 to the
          * daemon and set up inotify to wait for the flushed file to appear */
-        r = bus_open_system_systemd(&bus);
+        r = bus_connect_system_systemd(&bus);
         if (r < 0)
                 return log_error_errno(r, "Failed to get D-Bus connection: %m");
 
index 26d7d5890e8087825e2b509555bda1efe98e98b3..880a1794aa42e5b1d05a7a908174845d758abcfb 100644 (file)
@@ -676,7 +676,7 @@ int main(int argc, char*argv[]) {
         if (r <= 0)
                 goto finish;
 
-        r = bus_open_transport(arg_transport, arg_host, false, &bus);
+        r = bus_connect_transport(arg_transport, arg_host, false, &bus);
         if (r < 0) {
                 log_error_errno(r, "Failed to create bus connection: %m");
                 goto finish;
index efd6c5f4b0cc595c3b1f7db6c70f3863fc6431bf..bfc8716009a0f55eba5df4369a38203ee9984d51 100644 (file)
@@ -1542,7 +1542,7 @@ int main(int argc, char *argv[]) {
         if (r <= 0)
                 goto finish;
 
-        r = bus_open_transport(arg_transport, arg_host, false, &bus);
+        r = bus_connect_transport(arg_transport, arg_host, false, &bus);
         if (r < 0) {
                 log_error_errno(r, "Failed to create bus connection: %m");
                 goto finish;
index b3c8ea44a3061b59b6a5cec5969f929a45dde21b..17a186eb0e29d578bc9884a35712d9666d337db7 100644 (file)
@@ -2745,7 +2745,7 @@ int main(int argc, char*argv[]) {
         if (r <= 0)
                 goto finish;
 
-        r = bus_open_transport(arg_transport, arg_host, false, &bus);
+        r = bus_connect_transport(arg_transport, arg_host, false, &bus);
         if (r < 0) {
                 log_error_errno(r, "Failed to create bus connection: %m");
                 goto finish;
index 2b51b0889bce698050b67052507167046d71c919..62687591f416d527307ee3c23e5198ec1795d516 100644 (file)
@@ -1174,7 +1174,7 @@ int main(int argc, char* argv[]) {
                 arg_description = description;
         }
 
-        r = bus_open_transport_systemd(arg_transport, arg_host, arg_user, &bus);
+        r = bus_connect_transport_systemd(arg_transport, arg_host, arg_user, &bus);
         if (r < 0) {
                 log_error_errno(r, "Failed to create bus connection: %m");
                 goto finish;
index 16b17c2c82504bca5ad91f75cb4f293c02947368..10df3fc3d66306513d8b4ccd44c229cc34ba340f 100644 (file)
@@ -574,14 +574,14 @@ int bus_check_peercred(sd_bus *c) {
         return 1;
 }
 
-int bus_open_system_systemd(sd_bus **_bus) {
+int bus_connect_system_systemd(sd_bus **_bus) {
         _cleanup_bus_unref_ sd_bus *bus = NULL;
         int r;
 
         assert(_bus);
 
         if (geteuid() != 0)
-                return sd_bus_open_system(_bus);
+                return sd_bus_default_system(_bus);
 
         /* If we are root and kdbus is not available, then let's talk
          * directly to the system instance, instead of going via the
@@ -616,7 +616,7 @@ int bus_open_system_systemd(sd_bus **_bus) {
 
         r = sd_bus_start(bus);
         if (r < 0)
-                return sd_bus_open_system(_bus);
+                return sd_bus_default_system(_bus);
 
         r = bus_check_peercred(bus);
         if (r < 0)
@@ -628,7 +628,7 @@ int bus_open_system_systemd(sd_bus **_bus) {
         return 0;
 }
 
-int bus_open_user_systemd(sd_bus **_bus) {
+int bus_connect_user_systemd(sd_bus **_bus) {
         _cleanup_bus_unref_ sd_bus *bus = NULL;
         _cleanup_free_ char *ee = NULL;
         const char *e;
@@ -658,7 +658,7 @@ int bus_open_user_systemd(sd_bus **_bus) {
 
         e = secure_getenv("XDG_RUNTIME_DIR");
         if (!e)
-                return sd_bus_open_user(_bus);
+                return sd_bus_default_user(_bus);
 
         ee = bus_address_escape(e);
         if (!ee)
@@ -674,7 +674,7 @@ int bus_open_user_systemd(sd_bus **_bus) {
 
         r = sd_bus_start(bus);
         if (r < 0)
-                return sd_bus_open_user(_bus);
+                return sd_bus_default_user(_bus);
 
         r = bus_check_peercred(bus);
         if (r < 0)
@@ -1209,7 +1209,7 @@ int bus_map_all_properties(
         return bus_message_map_all_properties(m, map, userdata);
 }
 
-int bus_open_transport(BusTransport transport, const char *host, bool user, sd_bus **bus) {
+int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus) {
         int r;
 
         assert(transport >= 0);
@@ -1244,7 +1244,7 @@ int bus_open_transport(BusTransport transport, const char *host, bool user, sd_b
         return r;
 }
 
-int bus_open_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus) {
+int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus) {
         int r;
 
         assert(transport >= 0);
@@ -1258,9 +1258,9 @@ int bus_open_transport_systemd(BusTransport transport, const char *host, bool us
 
         case BUS_TRANSPORT_LOCAL:
                 if (user)
-                        r = bus_open_user_systemd(bus);
+                        r = bus_connect_user_systemd(bus);
                 else
-                        r = bus_open_system_systemd(bus);
+                        r = bus_connect_system_systemd(bus);
 
                 break;
 
index d2b2d701cebdef377e041ce0706fd015ee26e803..f03f951dc7c1c10a819ba232997360ea52fd27c8 100644 (file)
@@ -65,11 +65,11 @@ int bus_test_polkit(sd_bus_message *call, int capability, const char *action, co
 int bus_verify_polkit_async(sd_bus_message *call, int capability, const char *action, const char **details, bool interactive, uid_t good_user, Hashmap **registry, sd_bus_error *error);
 void bus_verify_polkit_async_registry_free(Hashmap *registry);
 
-int bus_open_system_systemd(sd_bus **_bus);
-int bus_open_user_systemd(sd_bus **_bus);
+int bus_connect_system_systemd(sd_bus **_bus);
+int bus_connect_user_systemd(sd_bus **_bus);
 
-int bus_open_transport(BusTransport transport, const char *host, bool user, sd_bus **bus);
-int bus_open_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
+int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus);
+int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
 
 int bus_print_property(const char *name, sd_bus_message *property, bool all);
 int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, char **filter, bool all);
index 7ee1e8d801d9aaaeee51340c573673851f94a509..2208081c4462a1377a7c8c52d899306bf5a36234 100644 (file)
@@ -7590,7 +7590,7 @@ int main(int argc, char*argv[]) {
         }
 
         if (!avoid_bus())
-                r = bus_open_transport_systemd(arg_transport, arg_host, arg_scope != UNIT_FILE_SYSTEM, &bus);
+                r = bus_connect_transport_systemd(arg_transport, arg_host, arg_scope != UNIT_FILE_SYSTEM, &bus);
 
         if (bus)
                 sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);
index ea41227e526d2a4226dbcdbd338a20bda3174b0e..68fbe3f5b85a8323509d61b52960edfd83778581 100644 (file)
@@ -500,7 +500,7 @@ int main(int argc, char *argv[]) {
         if (r <= 0)
                 goto finish;
 
-        r = bus_open_transport(arg_transport, arg_host, false, &bus);
+        r = bus_connect_transport(arg_transport, arg_host, false, &bus);
         if (r < 0) {
                 log_error_errno(r, "Failed to create bus connection: %m");
                 goto finish;
index b2998dce43c409401b3f731443f5efc5bcce5c33..8dbce272424462e57baf3a34acbb193471aaac0f 100644 (file)
@@ -256,7 +256,7 @@ int main(int argc, char *argv[]) {
         if (c.audit_fd < 0 && errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
                 log_error_errno(errno, "Failed to connect to audit log: %m");
 #endif
-        r = bus_open_system_systemd(&c.bus);
+        r = bus_connect_system_systemd(&c.bus);
         if (r < 0) {
                 log_error_errno(r, "Failed to get D-Bus connection: %m");
                 r = -EIO;