From fb2cfa6c1304cafa38016729942a0a3af4fd3620 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 4 Sep 2020 23:49:44 +0200 Subject: [PATCH 1/3] sd-bus: move SD_BUS_MAXIMUM_(SIGNATURE|NAME)_LENGTH to sd-bus-protocol.h So far we kept all defines directly originating from the spec in sd-bus-protocol.h, do this for this too. The precise place doesn't matter much API-wise given that sd-bus.h includes sd-bus-protocol.h, hence let's just clean this up. --- src/systemd/sd-bus-protocol.h | 6 ++++++ src/systemd/sd-bus.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/systemd/sd-bus-protocol.h b/src/systemd/sd-bus-protocol.h index a3f4e74359..8883ec62b9 100644 --- a/src/systemd/sd-bus-protocol.h +++ b/src/systemd/sd-bus-protocol.h @@ -94,6 +94,12 @@ enum { #define SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED \ "org.freedesktop.DBus.Error.InteractiveAuthorizationRequired" +/* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-signature */ +#define SD_BUS_MAXIMUM_SIGNATURE_LENGTH 255 + +/* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names */ +#define SD_BUS_MAXIMUM_NAME_LENGTH 255 + _SD_END_DECLARATIONS; #endif diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 787bc71271..9c37e7e6c9 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -34,12 +34,6 @@ _SD_BEGIN_DECLARATIONS; #define SD_BUS_DEFAULT_USER ((sd_bus *) 2) #define SD_BUS_DEFAULT_SYSTEM ((sd_bus *) 3) -/* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-signature */ -#define SD_BUS_MAXIMUM_SIGNATURE_LENGTH 255 - -/* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names */ -#define SD_BUS_MAXIMUM_NAME_LENGTH 255 - /* Types */ typedef struct sd_bus sd_bus; From 1ba37106b36b7804054d88fa51ee28641f64037f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 4 Sep 2020 23:52:39 +0200 Subject: [PATCH 2/3] ptyfwd: don't set prio if event source that might not exist We support read-only ptyfwd options, and on those the input event source won't be allocated. Deal with that and don't invoke a function on it that will then instantly fail. --- src/shared/ptyfwd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c index fe17b3781a..6d67c079e4 100644 --- a/src/shared/ptyfwd.c +++ b/src/shared/ptyfwd.c @@ -572,9 +572,11 @@ int pty_forward_set_priority(PTYForward *f, int64_t priority) { int r; assert(f); - r = sd_event_source_set_priority(f->stdin_event_source, priority); - if (r < 0) - return r; + if (f->stdin_event_source) { + r = sd_event_source_set_priority(f->stdin_event_source, priority); + if (r < 0) + return r; + } r = sd_event_source_set_priority(f->stdout_event_source, priority); if (r < 0) From 8d91b2206c0bb5c0467a99570b7b7896d6b98ec4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 4 Sep 2020 23:54:11 +0200 Subject: [PATCH 3/3] varlink: properly allocate connection event source Let's make sure we keep a reference to the event source (Note that this code is currently not used, which is why this was never used: in all cases we do not add listener fds after the event is attached, but before. In that case this code is not called.) --- src/shared/varlink.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/shared/varlink.c b/src/shared/varlink.c index a84c51f2af..aeec424754 100644 --- a/src/shared/varlink.c +++ b/src/shared/varlink.c @@ -2212,9 +2212,7 @@ int varlink_server_listen_fd(VarlinkServer *s, int fd) { }; if (s->event) { - _cleanup_(sd_event_source_unrefp) sd_event_source *es = NULL; - - r = sd_event_add_io(s->event, &es, fd, EPOLLIN, connect_callback, ss); + r = sd_event_add_io(s->event, &ss->event_source, fd, EPOLLIN, connect_callback, ss); if (r < 0) return r;