chiark / gitweb /
sd-bus: don't list activators as proper peers
[elogind.git] / src / libelogind / sd-bus / sd-bus.c
index 0c18296e13dad53b32e37022b6f4a40b11c16b2a..d2a96f87b0fdc43a0d63c96245f57a68a2874724 100644 (file)
@@ -73,13 +73,9 @@ static void bus_close_fds(sd_bus *b) {
 
         detach_io_events(b);
 
-        if (b->input_fd >= 0)
-                safe_close(b->input_fd);
-
-        if (b->output_fd >= 0 && b->output_fd != b->input_fd)
+        if (b->input_fd != b->output_fd)
                 safe_close(b->output_fd);
-
-        b->input_fd = b->output_fd = -1;
+        b->output_fd = b->input_fd = safe_close(b->input_fd);
 }
 
 static void bus_reset_queues(sd_bus *b) {
@@ -88,15 +84,13 @@ static void bus_reset_queues(sd_bus *b) {
         while (b->rqueue_size > 0)
                 sd_bus_message_unref(b->rqueue[--b->rqueue_size]);
 
-        free(b->rqueue);
-        b->rqueue = NULL;
+        b->rqueue = mfree(b->rqueue);
         b->rqueue_allocated = 0;
 
         while (b->wqueue_size > 0)
                 sd_bus_message_unref(b->wqueue[--b->wqueue_size]);
 
-        free(b->wqueue);
-        b->wqueue = NULL;
+        b->wqueue = mfree(b->wqueue);
         b->wqueue_allocated = 0;
 }
 
@@ -229,6 +223,8 @@ _public_ int sd_bus_set_fd(sd_bus *bus, int input_fd, int output_fd) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 _public_ int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]) {
         char *p, **a;
 
@@ -302,6 +298,7 @@ _public_ int sd_bus_negotiate_timestamp(sd_bus *bus, int b) {
 
         return 0;
 }
+#endif // 0
 
 _public_ int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t mask) {
         uint64_t new_flags;
@@ -342,6 +339,8 @@ _public_ int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 _public_ int sd_bus_set_anonymous(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
         assert_return(bus->state == BUS_UNSET, -EPERM);
@@ -367,6 +366,7 @@ _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);
@@ -376,12 +376,15 @@ _public_ int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 _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;
@@ -909,15 +912,11 @@ static void bus_reset_parsed_address(sd_bus *b) {
 
         zero(b->sockaddr);
         b->sockaddr_size = 0;
-        strv_free(b->exec_argv);
-        free(b->exec_path);
-        b->exec_path = NULL;
-        b->exec_argv = NULL;
+        b->exec_argv = strv_free(b->exec_argv);
+        b->exec_path = mfree(b->exec_path);
         b->server_id = SD_ID128_NULL;
-        free(b->kernel);
-        b->kernel = NULL;
-        free(b->machine);
-        b->machine = NULL;
+        b->kernel = mfree(b->kernel);
+        b->machine = mfree(b->machine);
         b->nspid = 0;
 }
 
@@ -1023,10 +1022,12 @@ static int bus_start_address(sd_bus *b) {
 
                 if (b->exec_path)
                         r = bus_socket_exec(b);
-                else if ((b->nspid > 0 || b->machine) && b->kernel)
+#if 0
+               else if ((b->nspid > 0 || b->machine) && b->kernel)
                         r = bus_container_connect_kernel(b);
                 else if ((b->nspid > 0 || b->machine) && b->sockaddr.sa.sa_family != AF_UNSPEC)
                         r = bus_container_connect_socket(b);
+#endif // 0
                 else if (b->kernel)
                         r = bus_kernel_connect(b);
                 else if (b->sockaddr.sa.sa_family != AF_UNSPEC)
@@ -1425,6 +1426,17 @@ _public_ void sd_bus_close(sd_bus *bus) {
          * ioctl on the fd when they are freed. */
 }
 
+_public_ sd_bus* sd_bus_flush_close_unref(sd_bus *bus) {
+
+        if (!bus)
+                return NULL;
+
+        sd_bus_flush(bus);
+        sd_bus_close(bus);
+
+        return sd_bus_unref(bus);
+}
+
 static void bus_enter_closing(sd_bus *bus) {
         assert(bus);
 
@@ -1459,6 +1471,8 @@ _public_ sd_bus *sd_bus_unref(sd_bus *bus) {
         return NULL;
 }
 
+/// UNNEEDED by elogind
+#if 0
 _public_ int sd_bus_is_open(sd_bus *bus) {
 
         assert_return(bus, -EINVAL);
@@ -1466,6 +1480,7 @@ _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;
@@ -1491,6 +1506,8 @@ _public_ int sd_bus_can_send(sd_bus *bus, char type) {
         return bus_type_is_valid(type);
 }
 
+/// UNNEEDED by elogind
+#if 0
 _public_ int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id) {
         int r;
 
@@ -1505,6 +1522,7 @@ _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);
@@ -2760,9 +2778,12 @@ _public_ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
         return bus_process_internal(bus, false, 0, ret);
 }
 
+/// UNNEEDED by elogind
+#if 0
 _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] = {};
@@ -2942,10 +2963,8 @@ _public_ int sd_bus_add_match(
 
                 /* Do not install server-side matches for matches
                  * against the local service, interface or bus
-                 * path. Also, when on kdbus don't install driver
-                 * matches server side. */
-                if (scope == BUS_MATCH_GENERIC ||
-                    (!bus->is_kernel && scope == BUS_MATCH_DRIVER)) {
+                 * path. */
+                if (scope != BUS_MATCH_LOCAL) {
 
                         if (!bus->is_kernel) {
                                 /* When this is not a kernel transport, we
@@ -2983,6 +3002,8 @@ finish:
         return r;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int bus_remove_match_by_string(
                 sd_bus *bus,
                 const char *match,
@@ -3013,6 +3034,7 @@ finish:
 
         return r;
 }
+#endif // 0
 
 bool bus_pid_changed(sd_bus *bus) {
         assert(bus);
@@ -3258,11 +3280,14 @@ _public_ sd_bus_message* sd_bus_get_current_message(sd_bus *bus) {
         return bus->current_message;
 }
 
+/// UNNEEDED by elogind
+#if 0
 _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);
@@ -3349,6 +3374,8 @@ _public_ int sd_bus_default(sd_bus **ret) {
         return sd_bus_default_system(ret);
 }
 
+/// UNNEEDED by elogind
+#if 0
 _public_ int sd_bus_get_tid(sd_bus *b, pid_t *tid) {
         assert_return(b, -EINVAL);
         assert_return(tid, -EINVAL);
@@ -3406,6 +3433,7 @@ _public_ int sd_bus_path_decode(const char *path, const char *prefix, char **ext
         *external_id = ret;
         return 1;
 }
+#endif // 0
 
 _public_ int sd_bus_try_close(sd_bus *bus) {
         int r;
@@ -3433,6 +3461,8 @@ _public_ int sd_bus_try_close(sd_bus *bus) {
         return 0;
 }
 
+/// UNNEEDED by elogind
+#if 0
 _public_ int sd_bus_get_description(sd_bus *bus, const char **description) {
         assert_return(bus, -EINVAL);
         assert_return(description, -EINVAL);
@@ -3442,6 +3472,7 @@ _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;
@@ -3461,6 +3492,8 @@ int bus_get_root_path(sd_bus *bus) {
         return r;
 }
 
+/// UNNEEDED by elogind
+#if 0
 _public_ int sd_bus_get_scope(sd_bus *bus, const char **scope) {
         int r;
 
@@ -3558,3 +3591,4 @@ _public_ int sd_bus_is_monitor(sd_bus *bus) {
 
         return !!(bus->hello_flags & KDBUS_HELLO_MONITOR);
 }
+#endif // 0