chiark / gitweb /
Prep 229.9: Make all supportable API functions visible.
[elogind.git] / src / libelogind / sd-bus / sd-bus.c
index a4f20ca1eabf4c02c384460872b60f720a9a785b..fda12a38486e53b58442f630604d449068e4898d 100644 (file)
@@ -234,7 +234,6 @@ _public_ int sd_bus_set_fd(sd_bus *bus, int input_fd, int output_fd) {
         return 0;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]) {
         char *p, **a;
 
@@ -262,7 +261,6 @@ _public_ int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[])
 
         return 0;
 }
-#endif // 0
 
 _public_ int sd_bus_set_bus_client(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
@@ -273,7 +271,6 @@ _public_ int sd_bus_set_bus_client(sd_bus *bus, int b) {
         return 0;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_set_monitor(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
         assert_return(bus->state == BUS_UNSET, -EPERM);
@@ -282,7 +279,6 @@ _public_ int sd_bus_set_monitor(sd_bus *bus, int b) {
         SET_FLAG(bus->hello_flags, KDBUS_HELLO_MONITOR, b);
         return 0;
 }
-#endif // 0
 
 _public_ int sd_bus_negotiate_fds(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
@@ -293,7 +289,6 @@ _public_ int sd_bus_negotiate_fds(sd_bus *bus, int b) {
         return 0;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_negotiate_timestamp(sd_bus *bus, int b) {
         uint64_t new_flags;
         assert_return(bus, -EINVAL);
@@ -337,7 +332,6 @@ _public_ int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t mask) {
 
         return 0;
 }
-#endif // 0
 
 _public_ int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id) {
         assert_return(bus, -EINVAL);
@@ -359,7 +353,6 @@ _public_ int sd_bus_set_anonymous(sd_bus *bus, int b) {
         return 0;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_set_trusted(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
         assert_return(bus->state == BUS_UNSET, -EPERM);
@@ -376,7 +369,6 @@ _public_ int sd_bus_set_description(sd_bus *bus, const char *description) {
 
         return free_and_strdup(&bus->description, description);
 }
-#endif // 0
 
 _public_ int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
@@ -386,14 +378,12 @@ _public_ int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b) {
         return 0;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_get_allow_interactive_authorization(sd_bus *bus) {
         assert_return(bus, -EINVAL);
         assert_return(!bus_pid_changed(bus), -ECHILD);
 
         return bus->allow_interactive_authorization;
 }
-#endif // 0
 
 static int hello_callback(sd_bus_message *reply, void *userdata, sd_bus_error *error) {
         const char *s;
@@ -600,6 +590,8 @@ static int parse_unix_address(sd_bus *b, const char **p, char **guid) {
                 b->sockaddr_size = offsetof(struct sockaddr_un, sun_path) + 1 + l;
         }
 
+        b->is_local = true;
+
         return 0;
 }
 
@@ -667,6 +659,8 @@ static int parse_tcp_address(sd_bus *b, const char **p, char **guid) {
 
         freeaddrinfo(result);
 
+        b->is_local = false;
+
         return 0;
 }
 
@@ -749,6 +743,9 @@ static int parse_exec_address(sd_bus *b, const char **p, char **guid) {
 
         b->exec_path = path;
         b->exec_argv = argv;
+
+        b->is_local = false;
+
         return 0;
 
 fail:
@@ -792,6 +789,8 @@ static int parse_kernel_address(sd_bus *b, const char **p, char **guid) {
         b->kernel = path;
         path = NULL;
 
+        b->is_local = true;
+
         return 0;
 }
 
@@ -850,6 +849,7 @@ static int parse_container_unix_address(sd_bus *b, const char **p, char **guid)
         b->sockaddr.un.sun_family = AF_UNIX;
         strncpy(b->sockaddr.un.sun_path, "/var/run/dbus/system_bus_socket", sizeof(b->sockaddr.un.sun_path));
         b->sockaddr_size = SOCKADDR_UN_LEN(b->sockaddr.un);
+        b->is_local = false;
 
         return 0;
 }
@@ -910,6 +910,8 @@ static int parse_container_kernel_address(sd_bus *b, const char **p, char **guid
         if (r < 0)
                 return r;
 
+        b->is_local = false;
+
         return 0;
 }
 
@@ -1195,6 +1197,7 @@ _public_ int sd_bus_open(sd_bus **ret) {
         /* We don't know whether the bus is trusted or not, so better
          * be safe, and authenticate everything */
         b->trusted = false;
+        b->is_local = false;
         b->attach_flags |= KDBUS_ATTACH_CAPS | KDBUS_ATTACH_CREDS;
         b->creds_mask |= SD_BUS_CREDS_UID | SD_BUS_CREDS_EUID | SD_BUS_CREDS_EFFECTIVE_CAPS;
 
@@ -1243,6 +1246,7 @@ _public_ int sd_bus_open_system(sd_bus **ret) {
         b->trusted = false;
         b->attach_flags |= KDBUS_ATTACH_CAPS | KDBUS_ATTACH_CREDS;
         b->creds_mask |= SD_BUS_CREDS_UID | SD_BUS_CREDS_EUID | SD_BUS_CREDS_EFFECTIVE_CAPS;
+        b->is_local = true;
 
         r = sd_bus_start(b);
         if (r < 0)
@@ -1312,6 +1316,7 @@ _public_ int sd_bus_open_user(sd_bus **ret) {
         /* We don't do any per-method access control on the user
          * bus. */
         b->trusted = true;
+        b->is_local = true;
 
         r = sd_bus_start(b);
         if (r < 0)
@@ -1386,6 +1391,7 @@ _public_ int sd_bus_open_system_remote(sd_bus **ret, const char *host) {
         bus->bus_client = true;
         bus->trusted = false;
         bus->is_system = true;
+        bus->is_local = false;
 
         r = sd_bus_start(bus);
         if (r < 0)
@@ -1435,6 +1441,7 @@ _public_ int sd_bus_open_system_machine(sd_bus **ret, const char *machine) {
         bus->bus_client = true;
         bus->trusted = false;
         bus->is_system = true;
+        bus->is_local = false;
 
         r = sd_bus_start(bus);
         if (r < 0)
@@ -1521,7 +1528,6 @@ _public_ sd_bus *sd_bus_unref(sd_bus *bus) {
         return NULL;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_is_open(sd_bus *bus) {
 
         assert_return(bus, -EINVAL);
@@ -1529,7 +1535,6 @@ _public_ int sd_bus_is_open(sd_bus *bus) {
 
         return BUS_IS_OPEN(bus->state);
 }
-#endif // 0
 
 _public_ int sd_bus_can_send(sd_bus *bus, char type) {
         int r;
@@ -1555,7 +1560,6 @@ _public_ int sd_bus_can_send(sd_bus *bus, char type) {
         return bus_type_is_valid(type);
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id) {
         int r;
 
@@ -1570,7 +1574,6 @@ _public_ int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id) {
         *id = bus->server_id;
         return 0;
 }
-#endif // 0
 
 static int bus_seal_message(sd_bus *b, sd_bus_message *m, usec_t timeout) {
         assert(b);
@@ -1847,7 +1850,6 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *cookie) {
         return bus_send_internal(bus, m, cookie, false);
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destination, uint64_t *cookie) {
         int r;
 
@@ -1873,7 +1875,6 @@ _public_ int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destinat
 
         return sd_bus_send(bus, m, cookie);
 }
-#endif // 0
 
 static usec_t calc_elapse(uint64_t usec) {
         if (usec == (uint64_t) -1)
@@ -2158,7 +2159,6 @@ fail:
         return sd_bus_error_set_errno(error, r);
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_get_fd(sd_bus *bus) {
 
         assert_return(bus, -EINVAL);
@@ -2167,7 +2167,6 @@ _public_ int sd_bus_get_fd(sd_bus *bus) {
 
         return bus->input_fd;
 }
-#endif // 0
 
 _public_ int sd_bus_get_events(sd_bus *bus) {
         int flags = 0;
@@ -2886,11 +2885,9 @@ _public_ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
         return bus_process_internal(bus, false, 0, ret);
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_process_priority(sd_bus *bus, int64_t priority, sd_bus_message **ret) {
         return bus_process_internal(bus, true, priority, ret);
 }
-#endif // 0
 
 static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
         struct pollfd p[2] = {};
@@ -3007,7 +3004,6 @@ _public_ int sd_bus_flush(sd_bus *bus) {
         }
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_add_filter(
                 sd_bus *bus,
                 sd_bus_slot **slot,
@@ -3034,7 +3030,6 @@ _public_ int sd_bus_add_filter(
 
         return 0;
 }
-#endif // 0
 
 _public_ int sd_bus_add_match(
                 sd_bus *bus,
@@ -3388,13 +3383,11 @@ _public_ sd_bus_message* sd_bus_get_current_message(sd_bus *bus) {
         return bus->current_message;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ sd_bus_slot* sd_bus_get_current_slot(sd_bus *bus) {
         assert_return(bus, NULL);
 
         return bus->current_slot;
 }
-#endif // 0
 
 _public_ sd_bus_message_handler_t sd_bus_get_current_handler(sd_bus *bus) {
         assert_return(bus, NULL);
@@ -3488,7 +3481,6 @@ _public_ int sd_bus_default(sd_bus **ret) {
                 return sd_bus_default_system(ret);
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_get_tid(sd_bus *b, pid_t *tid) {
         assert_return(b, -EINVAL);
         assert_return(tid, -EINVAL);
@@ -3747,7 +3739,6 @@ _public_ int sd_bus_get_description(sd_bus *bus, const char **description) {
         *description = bus->description;
         return 0;
 }
-#endif // 0
 
 int bus_get_root_path(sd_bus *bus) {
         int r;
@@ -3767,7 +3758,6 @@ int bus_get_root_path(sd_bus *bus) {
         return r;
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_get_scope(sd_bus *bus, const char **scope) {
         int r;
 
@@ -3879,10 +3869,11 @@ static void flush_close(sd_bus *bus) {
 
 _public_ void sd_bus_default_flush_close(void) {
         flush_close(default_starter_bus);
+#if 0 /// There is no user bus with elogind
         flush_close(default_user_bus);
+#endif // 0
         flush_close(default_system_bus);
 }
-#endif // 0
 
 _public_ int sd_bus_set_exit_on_disconnect(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
@@ -3896,10 +3887,8 @@ _public_ int sd_bus_set_exit_on_disconnect(sd_bus *bus, int b) {
         return bus_exit_now(bus);
 }
 
-#if 0 /// UNNEEDED by elogind
 _public_ int sd_bus_get_exit_on_disconnect(sd_bus *bus) {
         assert_return(bus, -EINVAL);
 
         return bus->exit_on_disconnect;
 }
-#endif // 0