From: Sven Eden Date: Wed, 31 May 2017 05:39:59 +0000 (+0200) Subject: Prep v230: Apply missing upstream fixes and updates (5/8) src/libelogind. X-Git-Tag: v231.3~140 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=2e95ec430d1d295404c517aee832ab5097f36e1c Prep v230: Apply missing upstream fixes and updates (5/8) src/libelogind. --- diff --git a/src/libelogind/libelogind.sym b/src/libelogind/libelogind.sym index 5e801400b..abdcafc9a 100644 --- a/src/libelogind/libelogind.sym +++ b/src/libelogind/libelogind.sym @@ -498,3 +498,12 @@ global: * sd_journal_restart_fields; * } LIBSYSTEMD_227; */ + +/* + * These methods are not needed by elogind. + * LIBSYSTEMD_230 { + * global: + * sd_journal_open_directory_fd; + * sd_journal_open_files_fd; + * } LIBSYSTEMD_229; +*/ diff --git a/src/libelogind/sd-bus/bus-common-errors.h b/src/libelogind/sd-bus/bus-common-errors.h index 464834979..c8f369cb7 100644 --- a/src/libelogind/sd-bus/bus-common-errors.h +++ b/src/libelogind/sd-bus/bus-common-errors.h @@ -34,6 +34,8 @@ #define BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC "org.freedesktop.systemd1.TransactionOrderIsCyclic" #define BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE "org.freedesktop.systemd1.TransactionIsDestructive" #define BUS_ERROR_UNIT_MASKED "org.freedesktop.systemd1.UnitMasked" +#define BUS_ERROR_UNIT_GENERATED "org.freedesktop.systemd1.UnitGenerated" +#define BUS_ERROR_UNIT_LINKED "org.freedesktop.systemd1.UnitLinked" #define BUS_ERROR_JOB_TYPE_NOT_APPLICABLE "org.freedesktop.systemd1.JobTypeNotApplicable" #define BUS_ERROR_NO_ISOLATION "org.freedesktop.systemd1.NoIsolation" #define BUS_ERROR_SHUTTING_DOWN "org.freedesktop.systemd1.ShuttingDown" diff --git a/src/libelogind/sd-bus/bus-introspect.c b/src/libelogind/sd-bus/bus-introspect.c index 8f93edb8d..f71130044 100644 --- a/src/libelogind/sd-bus/bus-introspect.c +++ b/src/libelogind/sd-bus/bus-introspect.c @@ -83,7 +83,7 @@ static void introspect_write_flags(struct introspect *i, int type, int flags) { if (type == _SD_BUS_VTABLE_PROPERTY || type == _SD_BUS_VTABLE_WRITABLE_PROPERTY) { if (flags & SD_BUS_VTABLE_PROPERTY_EXPLICIT) - fputs(" \n", i->f); + fputs(" \n", i->f); if (flags & SD_BUS_VTABLE_PROPERTY_CONST) fputs(" \n", i->f); @@ -96,7 +96,7 @@ static void introspect_write_flags(struct introspect *i, int type, int flags) { if (!i->trusted && (type == _SD_BUS_VTABLE_METHOD || type == _SD_BUS_VTABLE_WRITABLE_PROPERTY) && !(flags & SD_BUS_VTABLE_UNPRIVILEGED)) - fputs(" \n", i->f); + fputs(" \n", i->f); } static int introspect_write_arguments(struct introspect *i, const char *signature, const char *direction) { diff --git a/src/libelogind/sd-bus/bus-kernel.c b/src/libelogind/sd-bus/bus-kernel.c index 7886e3a38..5db011b71 100644 --- a/src/libelogind/sd-bus/bus-kernel.c +++ b/src/libelogind/sd-bus/bus-kernel.c @@ -1695,52 +1695,6 @@ int bus_kernel_open_bus_fd(const char *bus, char **path) { return fd; } -#if 0 /// UNNEEDED by elogind -int bus_kernel_create_endpoint(const char *bus_name, const char *ep_name, char **ep_path) { - _cleanup_free_ char *path = NULL; - struct kdbus_cmd *make; - struct kdbus_item *n; - const char *name; - int fd; - - fd = bus_kernel_open_bus_fd(bus_name, &path); - if (fd < 0) - return fd; - - make = alloca0_align(ALIGN8(offsetof(struct kdbus_cmd, items)) + - ALIGN8(offsetof(struct kdbus_item, str) + DECIMAL_STR_MAX(uid_t) + 1 + strlen(ep_name) + 1), - 8); - make->size = ALIGN8(offsetof(struct kdbus_cmd, items)); - make->flags = KDBUS_MAKE_ACCESS_WORLD; - - n = make->items; - sprintf(n->str, UID_FMT "-%s", getuid(), ep_name); - n->size = offsetof(struct kdbus_item, str) + strlen(n->str) + 1; - n->type = KDBUS_ITEM_MAKE_NAME; - make->size += ALIGN8(n->size); - name = n->str; - - if (ioctl(fd, KDBUS_CMD_ENDPOINT_MAKE, make) < 0) { - safe_close(fd); - return -errno; - } - - if (ep_path) { - char *p; - - p = strjoin(dirname(path), "/", name, NULL); - if (!p) { - safe_close(fd); - return -ENOMEM; - } - - *ep_path = p; - } - - return fd; -} -#endif // 0 - int bus_kernel_try_close(sd_bus *bus) { struct kdbus_cmd byebye = { .size = sizeof(byebye) }; diff --git a/src/libelogind/sd-bus/bus-match.c b/src/libelogind/sd-bus/bus-match.c index feb4ce805..dda0b5c50 100644 --- a/src/libelogind/sd-bus/bus-match.c +++ b/src/libelogind/sd-bus/bus-match.c @@ -940,7 +940,7 @@ char *bus_match_to_string(struct bus_match_component *components, unsigned n_com char *buffer = NULL; size_t size = 0; unsigned i; - int r; + int r; if (n_components <= 0) return strdup(""); diff --git a/src/libelogind/sd-bus/bus-message.c b/src/libelogind/sd-bus/bus-message.c index fb3311c27..d4f59117b 100644 --- a/src/libelogind/sd-bus/bus-message.c +++ b/src/libelogind/sd-bus/bus-message.c @@ -5676,8 +5676,8 @@ int bus_message_get_arg(sd_bus_message *m, unsigned i, const char **str) { assert(str); r = bus_message_get_arg_skip(m, i, &type, NULL); - if (r < 0) - return r; + if (r < 0) + return r; if (!IN_SET(type, SD_BUS_TYPE_STRING, SD_BUS_TYPE_OBJECT_PATH, SD_BUS_TYPE_SIGNATURE)) return -ENXIO; @@ -5694,8 +5694,8 @@ int bus_message_get_arg_strv(sd_bus_message *m, unsigned i, char ***strv) { assert(strv); r = bus_message_get_arg_skip(m, i, &type, &contents); - if (r < 0) - return r; + if (r < 0) + return r; if (type != SD_BUS_TYPE_ARRAY) return -ENXIO; diff --git a/src/libelogind/sd-bus/bus-track.c b/src/libelogind/sd-bus/bus-track.c index 0d01f9d84..b2e562358 100644 --- a/src/libelogind/sd-bus/bus-track.c +++ b/src/libelogind/sd-bus/bus-track.c @@ -24,7 +24,6 @@ #include "bus-track.h" #include "bus-util.h" - struct sd_bus_track { unsigned n_ref; sd_bus *bus; diff --git a/src/libelogind/sd-bus/sd-bus.c b/src/libelogind/sd-bus/sd-bus.c index 8a5cd38f7..c35bd5a01 100644 --- a/src/libelogind/sd-bus/sd-bus.c +++ b/src/libelogind/sd-bus/sd-bus.c @@ -1172,7 +1172,7 @@ _public_ int sd_bus_open(sd_bus **ret) { return sd_bus_open_user(ret); else #endif // 0 - return sd_bus_open_system(ret); + return sd_bus_open_system(ret); } r = sd_bus_new(&b); @@ -2074,8 +2074,8 @@ _public_ int sd_bus_call( } else if (incoming->header->type == SD_BUS_MESSAGE_METHOD_ERROR) { r = sd_bus_error_copy(error, &incoming->error); - sd_bus_message_unref(incoming); - return r; + sd_bus_message_unref(incoming); + return r; } else { r = -EIO; goto fail; @@ -3435,7 +3435,7 @@ _public_ int sd_bus_default(sd_bus **ret) { return sd_bus_default_user(ret); else #endif // 0 - return sd_bus_default_system(ret); + return sd_bus_default_system(ret); } #if 0 /// UNNEEDED by elogind diff --git a/src/libelogind/sd-daemon/sd-daemon.c b/src/libelogind/sd-daemon/sd-daemon.c index 44816401e..85edfea21 100644 --- a/src/libelogind/sd-daemon/sd-daemon.c +++ b/src/libelogind/sd-daemon/sd-daemon.c @@ -103,7 +103,7 @@ _public_ int sd_listen_fds(int unset_environment) { finish: unsetenv_all(unset_environment); return r; - } +} _public_ int sd_listen_fds_with_names(int unset_environment, char ***names) { _cleanup_strv_free_ char **l = NULL; @@ -137,8 +137,8 @@ _public_ int sd_listen_fds_with_names(int unset_environment, char ***names) { } else { r = strv_extend_n(&l, "unknown", n_fds); if (r < 0) - return r; -} + return r; + } *names = l; l = NULL; diff --git a/src/libelogind/sd-event/sd-event.c b/src/libelogind/sd-event/sd-event.c index d76f01b7d..192dc0ea6 100644 --- a/src/libelogind/sd-event/sd-event.c +++ b/src/libelogind/sd-event/sd-event.c @@ -649,7 +649,7 @@ static int event_make_signal_data( if (sigismember(&d->sigset, sig) > 0) { if (ret) *ret = d; - return 0; + return 0; } } else { r = hashmap_ensure_allocated(&e->signal_data, &uint64_hash_ops); @@ -696,7 +696,7 @@ static int event_make_signal_data( ev.data.ptr = d; r = epoll_ctl(e->epoll_fd, EPOLL_CTL_ADD, d->fd, &ev); - if (r < 0) { + if (r < 0) { r = -errno; goto fail; } @@ -953,7 +953,7 @@ static sd_event_source *source_new(sd_event *e, bool floating, EventSourceType t sd_event_ref(e); LIST_PREPEND(sources, e->sources, s); - e->n_sources ++; + e->n_sources++; return s; } @@ -1184,10 +1184,10 @@ _public_ int sd_event_add_signal( e->signal_sources[sig] = s; r = event_make_signal_data(e, sig, &d); - if (r < 0) { - source_free(s); - return r; - } + if (r < 0) { + source_free(s); + return r; + } /* Use the signal name as description for the event source by default */ (void) sd_event_source_set_description(s, signal_to_string(sig)); @@ -1241,14 +1241,14 @@ _public_ int sd_event_add_child( return r; } - e->n_enabled_child_sources ++; + e->n_enabled_child_sources++; r = event_make_signal_data(e, SIGCHLD, NULL); - if (r < 0) { + if (r < 0) { e->n_enabled_child_sources--; - source_free(s); - return r; - } + source_free(s); + return r; + } e->need_process_child = true; @@ -1585,7 +1585,7 @@ _public_ int sd_event_source_set_priority(sd_event_source *s, int64_t priority) event_unmask_signal_data(s->event, old, s->signal.sig); } else - s->priority = priority; + s->priority = priority; if (s->pending) prioq_reshuffle(s->event->pending, s, &s->pending_index); @@ -1713,11 +1713,11 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) { s->enabled = m; r = event_make_signal_data(s->event, s->signal.sig, NULL); - if (r < 0) { - s->enabled = SD_EVENT_OFF; + if (r < 0) { + s->enabled = SD_EVENT_OFF; event_gc_signal_data(s->event, &s->priority, s->signal.sig); - return r; - } + return r; + } break; @@ -1729,12 +1729,12 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) { s->enabled = m; r = event_make_signal_data(s->event, SIGCHLD, NULL); - if (r < 0) { - s->enabled = SD_EVENT_OFF; + if (r < 0) { + s->enabled = SD_EVENT_OFF; s->event->n_enabled_child_sources--; event_gc_signal_data(s->event, &s->priority, SIGCHLD); - return r; - } + return r; + } break; @@ -2564,7 +2564,7 @@ _public_ int sd_event_wait(sd_event *e, uint64_t timeout) { switch (*t) { case WAKEUP_EVENT_SOURCE: - r = process_io(e, ev_queue[i].data.ptr, ev_queue[i].events); + r = process_io(e, ev_queue[i].data.ptr, ev_queue[i].events); break; case WAKEUP_CLOCK_DATA: { diff --git a/src/libelogind/sd-id128/sd-id128.c b/src/libelogind/sd-id128/sd-id128.c index 81bd84264..d9c0116f6 100644 --- a/src/libelogind/sd-id128/sd-id128.c +++ b/src/libelogind/sd-id128/sd-id128.c @@ -27,7 +27,7 @@ #include "hexdecoct.h" #include "io-util.h" #include "macro.h" - #include "random-util.h" +#include "random-util.h" #include "util.h" _public_ char *sd_id128_to_string(sd_id128_t id, char s[SD_ID128_STRING_MAX]) { diff --git a/src/libelogind/sd-login/sd-login.c b/src/libelogind/sd-login/sd-login.c index a0bd299d8..e7f6143d9 100644 --- a/src/libelogind/sd-login/sd-login.c +++ b/src/libelogind/sd-login/sd-login.c @@ -378,7 +378,7 @@ static int file_of_seat(const char *seat, char **_p) { if (!filename_is_valid(seat)) return -EINVAL; - p = strappend("/run/systemd/seats/", seat); + p = strappend("/run/systemd/seats/", seat); } else { _cleanup_free_ char *buf = NULL; @@ -442,10 +442,10 @@ static int uid_get_array(uid_t uid, const char *variable, char ***array) { r = parse_env_file(p, NEWLINE, variable, &s, NULL); if (r == -ENOENT || (r >= 0 && isempty(s))) { - if (array) - *array = NULL; - return 0; - } + if (array) + *array = NULL; + return 0; + } if (r < 0) return r; diff --git a/src/libelogind/sd-login/test-login.c b/src/libelogind/sd-login/test-login.c index 9e24ab9d9..c1fd7dd33 100644 --- a/src/libelogind/sd-login/test-login.c +++ b/src/libelogind/sd-login/test-login.c @@ -25,7 +25,6 @@ #include "alloc-util.h" #include "fd-util.h" #include "formats-util.h" -#include "musl_missing.h" #include "string-util.h" #include "strv.h" #include "util.h" @@ -256,7 +255,6 @@ static void test_login(void) { } int main(int argc, char* argv[]) { - elogind_set_program_name(argv[0]); log_parse_environment(); log_open();