diff options
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/libsystemd.sym.m4 | 53 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-control.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-creds.c | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-socket.c | 23 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-util.c | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/sd-bus.c | 12 | ||||
-rw-r--r-- | src/libsystemd/sd-device/device-enumerator.c | 12 | ||||
-rw-r--r-- | src/libsystemd/sd-device/device-private.c | 29 | ||||
-rw-r--r-- | src/libsystemd/sd-device/sd-device.c | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-event/sd-event.c | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-event/test-event.c | 1 |
11 files changed, 88 insertions, 58 deletions
diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4 index b443c3cfba..0b94a87dd6 100644 --- a/src/libsystemd/libsystemd.sym.m4 +++ b/src/libsystemd/libsystemd.sym.m4 @@ -169,8 +169,7 @@ global: sd_peer_get_user_slice; } LIBSYSTEMD_219; -m4_ifdef(`ENABLE_KDBUS', -LIBSYSTEMD_FUTURE { +LIBSYSTEMD_221 { global: /* sd-bus */ sd_bus_default; @@ -185,27 +184,36 @@ global: sd_bus_set_address; sd_bus_set_fd; sd_bus_set_exec; + sd_bus_get_address; sd_bus_set_bus_client; + sd_bus_is_bus_client; sd_bus_set_server; + sd_bus_is_server; sd_bus_set_anonymous; + sd_bus_is_anonymous; sd_bus_set_trusted; + sd_bus_is_trusted; sd_bus_set_monitor; + sd_bus_is_monitor; sd_bus_set_description; + sd_bus_get_description; + sd_bus_negotiate_creds; + sd_bus_negotiate_timestamp; + sd_bus_negotiate_fds; + sd_bus_can_send; + sd_bus_get_creds_mask; sd_bus_set_allow_interactive_authorization; sd_bus_get_allow_interactive_authorization; - sd_bus_negotiate_fds; - sd_bus_negotiate_timestamp; - sd_bus_negotiate_creds; sd_bus_start; sd_bus_close; sd_bus_try_close; sd_bus_ref; sd_bus_unref; sd_bus_is_open; - sd_bus_can_send; sd_bus_get_bus_id; + sd_bus_get_scope; + sd_bus_get_tid; sd_bus_get_owner_creds; - sd_bus_get_description; sd_bus_send; sd_bus_send_to; sd_bus_call; @@ -217,9 +225,10 @@ global: sd_bus_process_priority; sd_bus_wait; sd_bus_flush; - sd_bus_get_current_message; sd_bus_get_current_slot; - sd_bus_get_tid; + sd_bus_get_current_message; + sd_bus_get_current_handler; + sd_bus_get_current_userdata; sd_bus_attach_event; sd_bus_detach_event; sd_bus_get_event; @@ -239,6 +248,8 @@ global: sd_bus_slot_get_description; sd_bus_slot_set_description; sd_bus_slot_get_current_message; + sd_bus_slot_get_current_handler; + sd_bus_slot_get_current_userdata; sd_bus_message_new_signal; sd_bus_message_new_method_call; sd_bus_message_new_method_return; @@ -248,13 +259,13 @@ global: sd_bus_message_new_method_errnof; sd_bus_message_ref; sd_bus_message_unref; - sd_bus_message_get_bus; sd_bus_message_get_type; sd_bus_message_get_cookie; sd_bus_message_get_reply_cookie; + sd_bus_message_get_priority; sd_bus_message_get_expect_reply; sd_bus_message_get_auto_start; - sd_bus_message_get_priority; + sd_bus_message_get_allow_interactive_authorization; sd_bus_message_get_signature; sd_bus_message_get_path; sd_bus_message_get_interface; @@ -266,13 +277,16 @@ global: sd_bus_message_get_monotonic_usec; sd_bus_message_get_realtime_usec; sd_bus_message_get_seqnum; + sd_bus_message_get_bus; sd_bus_message_get_creds; - sd_bus_message_is_empty; sd_bus_message_is_signal; sd_bus_message_is_method_call; sd_bus_message_is_method_error; + sd_bus_message_is_empty; + sd_bus_message_has_signature; sd_bus_message_set_expect_reply; sd_bus_message_set_auto_start; + sd_bus_message_set_allow_interactive_authorization; sd_bus_message_set_destination; sd_bus_message_set_priority; sd_bus_message_append; @@ -324,6 +338,7 @@ global: sd_bus_emit_interfaces_removed_strv; sd_bus_emit_interfaces_removed; sd_bus_query_sender_creds; + sd_bus_query_sender_privilege; sd_bus_creds_new_from_pid; sd_bus_creds_ref; sd_bus_creds_unref; @@ -374,6 +389,7 @@ global: sd_bus_error_copy; sd_bus_error_is_set; sd_bus_error_has_name; + sd_bus_error_add_map; sd_bus_path_encode; sd_bus_path_decode; sd_bus_track_new; @@ -401,9 +417,10 @@ global: sd_event_add_signal; sd_event_add_child; sd_event_add_defer; + sd_event_add_post; sd_event_add_exit; - sd_event_wait; sd_event_prepare; + sd_event_wait; sd_event_dispatch; sd_event_run; sd_event_loop; @@ -417,6 +434,9 @@ global: sd_event_get_watchdog; sd_event_source_ref; sd_event_source_unref; + sd_event_source_get_event; + sd_event_source_get_userdata; + sd_event_source_set_userdata; sd_event_source_set_description; sd_event_source_get_description; sd_event_source_set_prepare; @@ -425,8 +445,6 @@ global: sd_event_source_set_priority; sd_event_source_get_enabled; sd_event_source_set_enabled; - sd_event_source_get_userdata; - sd_event_source_set_userdata; sd_event_source_get_io_fd; sd_event_source_set_io_fd; sd_event_source_get_io_events; @@ -439,8 +457,11 @@ global: sd_event_source_get_time_clock; sd_event_source_get_signal; sd_event_source_get_child_pid; - sd_event_source_get_event; +} LIBSYSTEMD_220; +m4_ifdef(`ENABLE_KDBUS', +LIBSYSTEMD_FUTURE { +global: /* sd-utf8 */ sd_utf8_is_valid; sd_ascii_is_valid; diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c index fa4c28174d..43ddfc651d 100644 --- a/src/libsystemd/sd-bus/bus-control.c +++ b/src/libsystemd/sd-bus/bus-control.c @@ -429,7 +429,7 @@ static int bus_populate_creds_from_items( c->mask |= SD_BUS_CREDS_PPID; } else if (item->pids.pid == 1) { /* The structure doesn't - * really distuingish the case + * really distinguish the case * where a process has no * parent and where we don't * know it because it could diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index fed66823c7..4d67619cf8 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -303,7 +303,7 @@ _public_ int sd_bus_creds_get_ppid(sd_bus_creds *c, pid_t *ppid) { if (!(c->mask & SD_BUS_CREDS_PPID)) return -ENODATA; - /* PID 1 has no parent process. Let's distuingish the case of + /* PID 1 has no parent process. Let's distinguish the case of * not knowing and not having a parent process by the returned * error code. */ if (c->ppid == 0) @@ -989,7 +989,7 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) { if (missing & SD_BUS_CREDS_EXE) { r = get_process_exe(pid, &c->exe); if (r == -ESRCH) { - /* Unfortunately we cannot really distuingish + /* Unfortunately we cannot really distinguish * the case here where the process does not * exist, and /proc/$PID/exe being unreadable * because $PID is a kernel thread. Hence, @@ -1101,7 +1101,7 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) { } /* In case only the exe path was to be read we cannot - * distuingish the case where the exe path was unreadable + * distinguish the case where the exe path was unreadable * because the process was a kernel thread, or when the * process didn't exist at all. Hence, let's do a final check, * to be sure. */ diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index 24b9c4d117..4fffc6581d 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -24,12 +24,13 @@ #include <unistd.h> #include <poll.h> +#include "sd-daemon.h" #include "util.h" #include "macro.h" #include "missing.h" #include "utf8.h" -#include "sd-daemon.h" #include "formats-util.h" +#include "signal-util.h" #include "sd-bus.h" #include "bus-socket.h" @@ -492,7 +493,7 @@ static int bus_socket_auth_verify(sd_bus *b) { static int bus_socket_read_auth(sd_bus *b) { struct msghdr mh; - struct iovec iov; + struct iovec iov = {}; size_t n; ssize_t k; int r; @@ -527,7 +528,6 @@ static int bus_socket_read_auth(sd_bus *b) { b->rbuffer = p; - zero(iov); iov.iov_base = (uint8_t*) b->rbuffer + b->rbuffer_size; iov.iov_len = n - b->rbuffer_size; @@ -808,23 +808,21 @@ int bus_socket_write_message(sd_bus *bus, sd_bus_message *m, size_t *idx) { if (bus->prefer_writev) k = writev(bus->output_fd, iov, m->n_iovec); else { - struct msghdr mh; - zero(mh); + struct msghdr mh = { + .msg_iov = iov, + .msg_iovlen = m->n_iovec, + }; if (m->n_fds > 0) { struct cmsghdr *control; - control = alloca(CMSG_SPACE(sizeof(int) * m->n_fds)); - mh.msg_control = control; + mh.msg_control = control = alloca(CMSG_SPACE(sizeof(int) * m->n_fds)); + mh.msg_controllen = control->cmsg_len = CMSG_LEN(sizeof(int) * m->n_fds); control->cmsg_level = SOL_SOCKET; control->cmsg_type = SCM_RIGHTS; - mh.msg_controllen = control->cmsg_len = CMSG_LEN(sizeof(int) * m->n_fds); memcpy(CMSG_DATA(control), m->fds, sizeof(int) * m->n_fds); } - mh.msg_iov = iov; - mh.msg_iovlen = m->n_iovec; - k = sendmsg(bus->output_fd, &mh, MSG_DONTWAIT|MSG_NOSIGNAL); if (k < 0 && errno == ENOTSOCK) { bus->prefer_writev = true; @@ -936,7 +934,7 @@ static int bus_socket_make_message(sd_bus *bus, size_t size) { int bus_socket_read_message(sd_bus *bus) { struct msghdr mh; - struct iovec iov; + struct iovec iov = {}; ssize_t k; size_t need; int r; @@ -966,7 +964,6 @@ int bus_socket_read_message(sd_bus *bus) { bus->rbuffer = b; - zero(iov); iov.iov_base = (uint8_t*) bus->rbuffer + bus->rbuffer_size; iov.iov_len = need - bus->rbuffer_size; diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c index 5e375af206..99937799b3 100644 --- a/src/libsystemd/sd-bus/bus-util.c +++ b/src/libsystemd/sd-bus/bus-util.c @@ -30,6 +30,7 @@ #include "path-util.h" #include "missing.h" #include "set.h" +#include "signal-util.h" #include "unit-name.h" #include "sd-bus.h" diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 214b3d04df..edc27aef87 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -3513,7 +3513,7 @@ _public_ int sd_bus_get_address(sd_bus *bus, const char **address) { return -ENODATA; } -int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *mask) { +_public_ int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *mask) { assert_return(bus, -EINVAL); assert_return(mask, -EINVAL); assert_return(!bus_pid_changed(bus), -ECHILD); @@ -3522,35 +3522,35 @@ int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *mask) { return 0; } -int sd_bus_is_bus_client(sd_bus *bus) { +_public_ int sd_bus_is_bus_client(sd_bus *bus) { assert_return(bus, -EINVAL); assert_return(!bus_pid_changed(bus), -ECHILD); return bus->bus_client; } -int sd_bus_is_server(sd_bus *bus) { +_public_ int sd_bus_is_server(sd_bus *bus) { assert_return(bus, -EINVAL); assert_return(!bus_pid_changed(bus), -ECHILD); return bus->is_server; } -int sd_bus_is_anonymous(sd_bus *bus) { +_public_ int sd_bus_is_anonymous(sd_bus *bus) { assert_return(bus, -EINVAL); assert_return(!bus_pid_changed(bus), -ECHILD); return bus->anonymous_auth; } -int sd_bus_is_trusted(sd_bus *bus) { +_public_ int sd_bus_is_trusted(sd_bus *bus) { assert_return(bus, -EINVAL); assert_return(!bus_pid_changed(bus), -ECHILD); return bus->trusted; } -int sd_bus_is_monitor(sd_bus *bus) { +_public_ int sd_bus_is_monitor(sd_bus *bus) { assert_return(bus, -EINVAL); assert_return(!bus_pid_changed(bus), -ECHILD); diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 4de36d54e1..3692d46e06 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -367,11 +367,11 @@ static bool match_sysattr(sd_device_enumerator *enumerator, sd_device *device) { assert(enumerator); assert(device); - HASHMAP_FOREACH_KEY(sysattr, value, enumerator->nomatch_sysattr, i) + HASHMAP_FOREACH_KEY(value, sysattr, enumerator->nomatch_sysattr, i) if (match_sysattr_value(device, sysattr, value)) return false; - HASHMAP_FOREACH_KEY(sysattr, value, enumerator->match_sysattr, i) + HASHMAP_FOREACH_KEY(value, sysattr, enumerator->match_sysattr, i) if (!match_sysattr_value(device, sysattr, value)) return false; @@ -389,7 +389,7 @@ static bool match_property(sd_device_enumerator *enumerator, sd_device *device) if (hashmap_isempty(enumerator->match_property)) return true; - HASHMAP_FOREACH_KEY(property, value, enumerator->match_property, i) { + HASHMAP_FOREACH_KEY(value, property, enumerator->match_property, i) { const char *property_dev, *value_dev; FOREACH_DEVICE_PROPERTY(device, property_dev, value_dev) { @@ -764,9 +764,9 @@ static int parent_crawl_children(sd_device_enumerator *enumerator, const char *p if (dent->d_type != DT_DIR) continue; - k = asprintf(&child, "%s/%s", path, dent->d_name); - if (k < 0) - return -errno; + child = strjoin(path, "/", dent->d_name, NULL); + if (!child) + return -ENOMEM; k = parent_add_child(enumerator, child); if (k < 0) diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 3cadedbf4a..2e60433246 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -636,10 +636,10 @@ int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len) { static int device_update_properties_bufs(sd_device *device) { const char *val, *prop; - char **buf_strv = NULL; - uint8_t *buf_nulstr = NULL; - size_t allocated_nulstr = 0, allocated_strv = 0; - size_t nulstr_len = 0, strv_size = 0; + _cleanup_free_ char **buf_strv = NULL; + _cleanup_free_ uint8_t *buf_nulstr = NULL; + size_t allocated_nulstr = 0; + size_t nulstr_len = 0, num = 0, i = 0; assert(device); @@ -655,20 +655,29 @@ static int device_update_properties_bufs(sd_device *device) { if (!buf_nulstr) return -ENOMEM; - buf_strv = GREEDY_REALLOC0(buf_strv, allocated_strv, strv_size + 2); - if (!buf_strv) - return -ENOMEM; - - buf_strv[++ strv_size] = (char *)&buf_nulstr[nulstr_len]; strscpyl((char *)buf_nulstr + nulstr_len, len + 1, prop, "=", val, NULL); nulstr_len += len + 1; + ++num; + } + + /* build buf_strv from buf_nulstr */ + buf_strv = new0(char *, num + 1); + if (!buf_strv) + return -ENOMEM; + + NULSTR_FOREACH(val, (char*) buf_nulstr) { + buf_strv[i] = (char *) val; + assert(i < num); + i++; } free(device->properties_nulstr); - free(device->properties_strv); device->properties_nulstr = buf_nulstr; + buf_nulstr = NULL; device->properties_nulstr_len = nulstr_len; + free(device->properties_strv); device->properties_strv = buf_strv; + buf_strv = NULL; device->properties_buf_outdated = false; diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 691b9c6327..97da4a8eea 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1193,12 +1193,12 @@ int device_get_id_filename(sd_device *device, const char **ret) { streq(subsystem, "block") ? 'b' : 'c', major(devnum), minor(devnum)); if (r < 0) - return -errno; + return -ENOMEM; } else if (ifindex > 0) { /* use netdev ifindex -- n3 */ r = asprintf(&id, "n%u", ifindex); if (r < 0) - return -errno; + return -ENOMEM; } else { /* use $subsys:$sysname -- pci:0000:00:1f.2 * sysname() has '!' translated, get it from devpath @@ -1211,7 +1211,7 @@ int device_get_id_filename(sd_device *device, const char **ret) { r = asprintf(&id, "+%s:%s", subsystem, sysname); if (r < 0) - return -errno; + return -ENOMEM; } device->id_filename = id; diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 0dc4680376..cc8bc50c04 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -33,6 +33,7 @@ #include "missing.h" #include "set.h" #include "list.h" +#include "signal-util.h" #include "sd-event.h" diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c index 721700be7b..94e98e0077 100644 --- a/src/libsystemd/sd-event/test-event.c +++ b/src/libsystemd/sd-event/test-event.c @@ -23,6 +23,7 @@ #include "log.h" #include "util.h" #include "macro.h" +#include "signal-util.h" static int prepare_handler(sd_event_source *s, void *userdata) { log_info("preparing %c", PTR_TO_INT(userdata)); |