diff --git a/add-unit-test-for-dbus-broker.patch b/add-unit-test-for-dbus-broker.patch index ea5068a..3fc2299 100644 --- a/add-unit-test-for-dbus-broker.patch +++ b/add-unit-test-for-dbus-broker.patch @@ -10,14 +10,14 @@ Subject: [PATCH 2/2] add unit test for dbus-broker test/dbus/util-broker.c | 138 ++++++++++++++++++++++++++++++----- test/dbus/util-broker.h | 12 +++- 5 files changed, 401 insertions(+), 20 deletions(-) - create mode 100755 test/dbus/test-reexecute.c - create mode 100755 test/dbus/test-serialize.c + create mode 100644 test/dbus/test-reexecute.c + create mode 100644 test/dbus/test-serialize.c diff --git a/test/dbus/meson.build b/test/dbus/meson.build -index c111283..c2d1d79 100644 +index 683a653..e4ae0f1 100644 --- a/test/dbus/meson.build +++ b/test/dbus/meson.build -@@ -67,6 +67,12 @@ test('Client Lifetime', test_lifetime) +@@ -72,6 +72,12 @@ test('Client Lifetime', test_lifetime) test_matches = executable('test-matches', ['test-matches.c'], dependencies: [ dep_test ]) test('Signals and Matches', test_matches) @@ -31,7 +31,7 @@ index c111283..c2d1d79 100644 dbus_bin = dep_dbus.get_pkgconfig_variable('bindir') + '/dbus-daemon' diff --git a/test/dbus/test-reexecute.c b/test/dbus/test-reexecute.c -new file mode 100755 +new file mode 100644 index 0000000..43025e7 --- /dev/null +++ b/test/dbus/test-reexecute.c @@ -158,8 +158,8 @@ index 0000000..43025e7 + return 0; +} diff --git a/test/dbus/test-serialize.c b/test/dbus/test-serialize.c -new file mode 100755 -index 0000000..e287647 +new file mode 100644 +index 0000000..22e32d6 --- /dev/null +++ b/test/dbus/test-serialize.c @@ -0,0 +1,144 @@ @@ -308,7 +308,7 @@ index 0000000..e287647 + return 0; +} diff --git a/test/dbus/util-broker.c b/test/dbus/util-broker.c -index 0bdcefc..5d33b52 100644 +index 3cb4e1d..9b1ec74 100644 --- a/test/dbus/util-broker.c +++ b/test/dbus/util-broker.c @@ -15,6 +15,7 @@ @@ -402,14 +402,14 @@ index 0bdcefc..5d33b52 100644 "a(btbs)" \ @@ -59,7 +125,7 @@ static int util_event_sigchld(sd_event_source *source, const siginfo_t *si, void "a(ss)" \ - "b" + "bs" -static int util_append_policy(sd_bus_message *m) { +int util_append_policy(sd_bus_message *m) { int r; r = sd_bus_message_open_container(m, 'v', "(" POLICY_T ")"); -@@ -165,18 +231,49 @@ static int util_method_reload_config(sd_bus_message *message, void *userdata, sd +@@ -171,18 +237,49 @@ static int util_method_reload_config(sd_bus_message *message, void *userdata, sd return sd_bus_reply_method_return(message, NULL); } @@ -461,7 +461,7 @@ index 0bdcefc..5d33b52 100644 int r, pair[2]; pid_t pid; -@@ -214,7 +311,13 @@ void util_fork_broker(sd_bus **busp, sd_event *event, int listener_fd, pid_t *pi +@@ -220,7 +317,13 @@ void util_fork_broker(sd_bus **busp, sd_event *event, int listener_fd, pid_t *pi if (pidp) *pidp = pid; @@ -476,7 +476,7 @@ index 0bdcefc..5d33b52 100644 c_assert(r >= 0); r = sd_bus_new(&bus); -@@ -223,11 +326,12 @@ void util_fork_broker(sd_bus **busp, sd_event *event, int listener_fd, pid_t *pi +@@ -229,11 +332,12 @@ void util_fork_broker(sd_bus **busp, sd_event *event, int listener_fd, pid_t *pi /* consumes the fd */ r = sd_bus_set_fd(bus, pair[0], pair[0]); c_assert(r >= 0); @@ -490,7 +490,7 @@ index 0bdcefc..5d33b52 100644 c_assert(r >= 0); r = sd_bus_start(bus); -@@ -381,10 +485,16 @@ static void *util_broker_thread(void *userdata) { +@@ -387,10 +491,16 @@ static void *util_broker_thread(void *userdata) { r = sd_event_add_signal(event, NULL, SIGUSR1, util_event_sigusr1, broker); c_assert(r >= 0); @@ -508,7 +508,7 @@ index 0bdcefc..5d33b52 100644 broker->listener_fd = c_close(broker->listener_fd); } else { c_assert(broker->listener_fd < 0); -@@ -478,18 +588,7 @@ void util_broker_spawn(Broker *broker) { +@@ -484,18 +594,7 @@ void util_broker_spawn(Broker *broker) { * run and babysit the broker. */ @@ -528,7 +528,7 @@ index 0bdcefc..5d33b52 100644 r = pthread_create(&broker->thread, NULL, util_broker_thread, broker); c_assert(r >= 0); } -@@ -512,6 +611,7 @@ void util_broker_terminate(Broker *broker) { +@@ -518,6 +617,7 @@ void util_broker_terminate(Broker *broker) { r = pthread_join(broker->thread, &value); c_assert(!r); @@ -574,5 +574,5 @@ index a3f5f49..fa6de9d 100644 /* broker */ -- -2.30.2 +2.33.0 diff --git a/backport-bus-peer-fix-catching-OOM-when-linking-match-rules.patch b/backport-bus-peer-fix-catching-OOM-when-linking-match-rules.patch deleted file mode 100644 index e045554..0000000 --- a/backport-bus-peer-fix-catching-OOM-when-linking-match-rules.patch +++ /dev/null @@ -1,45 +0,0 @@ -From af6bf48ba27408725d14378e4a11139106506f3b Mon Sep 17 00:00:00 2001 -From: David Rheinsberg -Date: Mon, 12 Jun 2023 10:56:31 +0200 -Subject: [PATCH] bus/peer: fix catching OOM when linking match-rules - -When the match-rule infrastructure was extended to have per-key lookup -tables, all call-sites had to be amended to catch errors when linking -new rules. One such site was missed, so fix this and catch the error -properly. - -The conversion was initially performed in: - - commit 6c2b082522a6af033cd6699b669a4de614c41ad7 - Author: Tom Gundersen - Date: Wed Apr 25 17:16:47 2018 +0200 - - match: make match_rule_link() fallible - -This fixes a possible bug where ENOMEM is ignored and thus a match rule -is silently dropped instead of being linked and retained. - -Reported-by: Mark Esler -Signed-off-by: David Rheinsberg ---- - src/bus/peer.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/bus/peer.c b/src/bus/peer.c -index 1867223..9de3566 100644 ---- a/src/bus/peer.c -+++ b/src/bus/peer.c -@@ -548,7 +548,9 @@ static int peer_link_match(Peer *peer, MatchRule *rule, bool monitor) { - case ADDRESS_TYPE_ID: { - sender = peer_registry_find_peer(&peer->bus->peers, addr.id); - if (sender) { -- match_rule_link(rule, &sender->sender_matches, monitor); -+ r = match_rule_link(rule, &sender->sender_matches, monitor); -+ if (r) -+ return error_fold(r); - } else if (addr.id >= peer->bus->peers.ids) { - /* - * This peer does not yet exist, by the same --- -2.33.0 - diff --git a/backport-dbus-socket-set-msgheader-controllen-size-using-the-.patch b/backport-dbus-socket-set-msgheader-controllen-size-using-the-.patch deleted file mode 100644 index 33ce167..0000000 --- a/backport-dbus-socket-set-msgheader-controllen-size-using-the-.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 743db9327bf8223dba59b1b666ba547a14e18afb Mon Sep 17 00:00:00 2001 -From: Luca Boccassi -Date: Tue, 4 Apr 2023 01:58:02 +0100 -Subject: [PATCH] dbus/socket: set msgheader controllen size using the right - macro - -Use CMSG_SPACE to set the size of msg_controllen when sending FDs. -CMSG_LEN was used implicicly before, which for 1 FD is 20 bytes, -while CMSG_SPACE is 24 bytes. - -Signed-off-by: Luca Boccassi -Signed-off-by: David Rheinsberg ---- - src/dbus/socket.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/dbus/socket.c b/src/dbus/socket.c -index d429588..85eedda 100644 ---- a/src/dbus/socket.c -+++ b/src/dbus/socket.c -@@ -806,7 +806,7 @@ static int socket_dispatch_write(Socket *socket) { - buffer->message->fds && - socket_buffer_is_uncomsumed(buffer)) { - msg->msg_control = buffer->message->fds->cmsg; -- msg->msg_controllen = buffer->message->fds->cmsg->cmsg_len; -+ msg->msg_controllen = fdlist_size(buffer->message->fds); - } else { - msg->msg_control = NULL; - msg->msg_controllen = 0; --- -2.33.0 - diff --git a/backport-launch-config-avoid-expat.h-in-header.patch b/backport-launch-config-avoid-expat.h-in-header.patch deleted file mode 100644 index 6aaf79a..0000000 --- a/backport-launch-config-avoid-expat.h-in-header.patch +++ /dev/null @@ -1,42 +0,0 @@ -From c2f07184beddb26d7e62c4c32d6503ad47830152 Mon Sep 17 00:00:00 2001 -From: David Rheinsberg -Date: Wed, 5 Jul 2023 09:41:11 +0200 -Subject: [PATCH] launch/config: avoid expat.h in header - -To reduce exposure of expat, avoid it in config.h. The only definition -we use can be easily forward-declared, and thus we can completely -contain expat in config.c. - -Signed-off-by: David Rheinsberg ---- - src/launch/config.h | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/src/launch/config.h b/src/launch/config.h -index c36819d..881974a 100644 ---- a/src/launch/config.h -+++ b/src/launch/config.h -@@ -6,9 +6,10 @@ - - #include - #include --#include - #include - -+struct XML_ParserStruct; -+ - typedef struct ConfigPath ConfigPath; - typedef struct ConfigNode ConfigNode; - typedef struct ConfigParser ConfigParser; -@@ -218,7 +219,7 @@ struct ConfigRoot { - } - - struct ConfigParser { -- XML_Parser xml; -+ struct XML_ParserStruct *xml; - - struct ConfigState { - NSSCache *nss; --- -2.33.0 - diff --git a/backport-launch-config-use-AT_RANDOM-for-XML-hash-salt.patch b/backport-launch-config-use-AT_RANDOM-for-XML-hash-salt.patch deleted file mode 100644 index 86433a2..0000000 --- a/backport-launch-config-use-AT_RANDOM-for-XML-hash-salt.patch +++ /dev/null @@ -1,73 +0,0 @@ -This fixes an issue where libexpat might read from `/dev/urandom` and -thus block until the entropy pool is initialized. This hidden -dependency is very hard to debug. Instead, we require the service -launcher to delay startup until suitable entropy is available. This -explicit dependency is much easier to manage, debug, and control. - -Reported-by: Stefan Agner -Signed-off-by: David Rheinsberg ---- - src/launch/config.c | 17 +++++++++++++++++ - src/launch/config.h | 1 + - 2 files changed, 18 insertions(+) - -diff --git a/src/launch/config.c b/src/launch/config.c -index 85521bd..4a6a11e 100644 ---- a/src/launch/config.c -+++ b/src/launch/config.c -@@ -6,6 +6,7 @@ - #include - #include - #include -+#include - #include "dbus/protocol.h" - #include "launch/config.h" - #include "launch/nss-cache.h" -@@ -1216,9 +1217,24 @@ static void config_parser_blob_fn(void *userdata, const XML_Char *data, int n_da - * config_parser_init() - XXX - */ - void config_parser_init(ConfigParser *parser) { -+ void *random; -+ - *parser = (ConfigParser)CONFIG_PARSER_NULL(*parser); - - parser->xml = XML_ParserCreate(NULL); -+ -+ /* -+ * The hash-tables of libexpat require a reliable random seed. -+ * Depending on libexpat compilation flags, this might end up using -+ * `/dev/urandom` and thus block until random-initialization is -+ * finished. We avoid this hidden dependency and instead use the -+ * entropy provided via `AT_RANDOM`. Hence, entropy availability is -+ * tightly coupled to process startup, and it is the job of the -+ * service manager to order processes accordingly. -+ */ -+ random = (void *)getauxval(AT_RANDOM); -+ c_assert(random); -+ c_memcpy(&parser->salt, random, sizeof(parser->salt)); - } - - /** -@@ -1262,6 +1278,7 @@ static int config_parser_include(ConfigParser *parser, ConfigRoot *root, ConfigN - } - - XML_ParserReset(parser->xml, NULL); -+ XML_SetHashSalt(parser->xml, parser->salt); - XML_SetUserData(parser->xml, &parser->state); - XML_SetElementHandler(parser->xml, config_parser_begin_fn, config_parser_end_fn); - XML_SetCharacterDataHandler(parser->xml, config_parser_blob_fn); -diff --git a/src/launch/config.h b/src/launch/config.h -index 4c8df18..8ae9be6 100644 ---- a/src/launch/config.h -+++ b/src/launch/config.h -@@ -216,6 +216,7 @@ struct ConfigRoot { - - struct ConfigParser { - struct XML_ParserStruct *xml; -+ unsigned long salt; - - struct ConfigState { - NSSCache *nss; --- -2.33.0 - diff --git a/backport-util-fdlist-add-helper-to-return-list-size.patch b/backport-util-fdlist-add-helper-to-return-list-size.patch deleted file mode 100644 index f76836c..0000000 --- a/backport-util-fdlist-add-helper-to-return-list-size.patch +++ /dev/null @@ -1,33 +0,0 @@ -From b0096d204afcd5fd096ec35a8f7ab113bcc5ab95 Mon Sep 17 00:00:00 2001 -From: Luca Boccassi -Date: Tue, 4 Apr 2023 13:36:46 +0100 -Subject: [PATCH] util/fdlist: add helper to return list size - -Provide a new helper to return the space occupied by a full FDList. This -includes trailing padding and is required for cmsg-based transactions. - -Signed-off-by: Luca Boccassi -(fix commit message) -Signed-off-by: David Rheinsberg ---- - src/util/fdlist.h | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/src/util/fdlist.h b/src/util/fdlist.h -index 33ff73c..233ffc0 100644 ---- a/src/util/fdlist.h -+++ b/src/util/fdlist.h -@@ -33,6 +33,10 @@ static inline size_t fdlist_count(FDList *list) { - return list ? (list->cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int) : 0; - } - -+static inline size_t fdlist_size(FDList *list) { -+ return list ? CMSG_SPACE(fdlist_count(list) * sizeof(int)) : 0; -+} -+ - static inline int fdlist_get(FDList *list, size_t index) { - return index < fdlist_count(list) ? fdlist_data(list)[index] : -1; - } --- -2.33.0 - diff --git a/backport-util-selinux-follow-permissive-mode.patch b/backport-util-selinux-follow-permissive-mode.patch deleted file mode 100644 index 3f921e9..0000000 --- a/backport-util-selinux-follow-permissive-mode.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 01a500868f3343489c8b4af08e0e352874bdb04e Mon Sep 17 00:00:00 2001 -From: David Rheinsberg -Date: Mon, 12 Jun 2023 12:09:12 +0200 -Subject: [PATCH] util/selinux: follow permissive mode - -Make sure to follow the rules of enforcing/permissive mode and avoid -operation denials in permissive mode. - -Reported-by: Daan De Meyer -Signed-off-by: David Rheinsberg ---- - src/util/selinux.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/util/selinux.c b/src/util/selinux.c -index 4b61ec7..a72cc0a 100644 ---- a/src/util/selinux.c -+++ b/src/util/selinux.c -@@ -242,7 +242,7 @@ int bus_selinux_check_own(BusSELinuxRegistry *registry, - "dbus", - "acquire_svc", - NULL); -- if (r < 0) { -+ if (r < 0 && bus_selinux_is_enforcing()) { - /* - * Treat unknown contexts (possibly due to policy reload) - * as access denied. -@@ -289,7 +289,7 @@ int bus_selinux_check_send(BusSELinuxRegistry *registry, - "dbus", - "send_msg", - NULL); -- if (r < 0) { -+ if (r < 0 && bus_selinux_is_enforcing()) { - /* - * Treat unknown contexts (possibly due to policy reload) - * as access denied. --- -2.33.0 - diff --git a/backport-util-selinux-provide-helper-to-check-enforcing-mode.patch b/backport-util-selinux-provide-helper-to-check-enforcing-mode.patch deleted file mode 100644 index 95ef45f..0000000 --- a/backport-util-selinux-provide-helper-to-check-enforcing-mode.patch +++ /dev/null @@ -1,72 +0,0 @@ -From df23f09376386fbdefb4bcc049c1c81a9a893baf Mon Sep 17 00:00:00 2001 -From: David Rheinsberg -Date: Mon, 12 Jun 2023 12:04:47 +0200 -Subject: [PATCH] util/selinux: provide helper to check enforcing mode - -Add a new helper to check the selinux enforcing mode. This will be used -in follow-ups to avoid AVC denials in permissive mode. - -Signed-off-by: David Rheinsberg ---- - src/util/selinux-fallback.c | 4 ++++ - src/util/selinux.c | 16 ++++++++++++++++ - src/util/selinux.h | 1 + - 3 files changed, 21 insertions(+) - -diff --git a/src/util/selinux-fallback.c b/src/util/selinux-fallback.c -index ec4d458..0654a07 100644 ---- a/src/util/selinux-fallback.c -+++ b/src/util/selinux-fallback.c -@@ -16,6 +16,10 @@ bool bus_selinux_is_enabled(void) { - return false; - } - -+bool bus_selinux_is_enforcing(void) { -+ return false; -+} -+ - const char *bus_selinux_policy_root(void) { - return NULL; - } -diff --git a/src/util/selinux.c b/src/util/selinux.c -index f8b4c8a..4b61ec7 100644 ---- a/src/util/selinux.c -+++ b/src/util/selinux.c -@@ -38,6 +38,22 @@ bool bus_selinux_is_enabled(void) { - return is_selinux_enabled(); - } - -+/** -+ * bus_selinux_is_enforcing() - checks if SELinux is in enforcing mode -+ * -+ * If selinux is not enabled or otherwise unavailable, this will return true. -+ * That is, this will only return false, if selinux is enabled and in -+ * permissive mode. -+ * -+ * Returns: true if SELinux is in enforcing mode, false otherwise. -+ */ -+bool bus_selinux_is_enforcing(void) { -+ if (bus_selinux_status_open) -+ return selinux_status_getenforce() != 0; -+ else -+ return security_getenforce() != 0; -+} -+ - /** - * bus_selinux_policy_root() - the root directory where the current SELinux policy can be found - * -diff --git a/src/util/selinux.h b/src/util/selinux.h -index 9a71e90..435c8a8 100644 ---- a/src/util/selinux.h -+++ b/src/util/selinux.h -@@ -16,6 +16,7 @@ enum { - }; - - bool bus_selinux_is_enabled(void); -+bool bus_selinux_is_enforcing(void); - const char *bus_selinux_policy_root(void); - - int bus_selinux_registry_new(BusSELinuxRegistry **registryp, const char *fallback_context); --- -2.33.0 - diff --git a/backport-util-selinux-try-opening-the-status-page.patch b/backport-util-selinux-try-opening-the-status-page.patch deleted file mode 100644 index b80b8cf..0000000 --- a/backport-util-selinux-try-opening-the-status-page.patch +++ /dev/null @@ -1,68 +0,0 @@ -Subject: [PATCH] util/selinux: try opening the status page - -Try opening the selinux status page for faster access to selinux status -values. If running on older kernels without the status page, simply -avoid using it. - -Signed-off-by: David Rheinsberg ---- - src/util/selinux.c | 29 +++++++++++++++++++++++++++++ - 1 file changed, 29 insertions(+) - -diff --git a/src/util/selinux.c b/src/util/selinux.c -index 0264ea7..ea6af75 100644 ---- a/src/util/selinux.c -+++ b/src/util/selinux.c -@@ -27,6 +27,7 @@ struct BusSELinuxName { - typedef struct BusSELinuxName BusSELinuxName; - - static bool bus_selinux_avc_open; -+static bool bus_selinux_status_open; - - /** bus_selinux_is_enabled() - checks if SELinux is currently enabled - * -@@ -360,6 +361,29 @@ int bus_selinux_init_global(void) { - bus_selinux_avc_open = true; - } - -+ if (!bus_selinux_status_open) { -+ r = selinux_status_open(0); -+ if (r == 0) { -+ /* -+ * The status page was successfully opened and can now -+ * be used for faster selinux status-checks. -+ */ -+ bus_selinux_status_open = true; -+ } else if (r > 0) { -+ /* -+ * >0 indicates success but with the netlink-fallback. -+ * We didn't request the netlink-fallback, so close the -+ * status-page again and treat it as unavailable. -+ */ -+ selinux_status_close(); -+ } else { -+ /* -+ * If the status page could not be opened, treat it as -+ * unavailable and use the slower fallback functions. -+ */ -+ } -+ } -+ - selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback)bus_selinux_log); - - /* XXX: set audit callback to get more metadata in the audit log? */ -@@ -378,6 +402,11 @@ void bus_selinux_deinit_global(void) { - if (!is_selinux_enabled()) - return; - -+ if (bus_selinux_status_open) { -+ selinux_status_close(); -+ bus_selinux_status_open = false; -+ } -+ - if (bus_selinux_avc_open) { - avc_destroy(); - bus_selinux_avc_open = false; --- -2.33.0 - diff --git a/dbus-broker-31.tar.xz b/dbus-broker-31.tar.xz deleted file mode 100644 index 36c9d75..0000000 Binary files a/dbus-broker-31.tar.xz and /dev/null differ diff --git a/dbus-broker-35.tar.xz b/dbus-broker-35.tar.xz new file mode 100644 index 0000000..10151ce Binary files /dev/null and b/dbus-broker-35.tar.xz differ diff --git a/dbus-broker.spec b/dbus-broker.spec index 50a16a9..7052772 100644 --- a/dbus-broker.spec +++ b/dbus-broker.spec @@ -1,21 +1,16 @@ Name: dbus-broker -Version: 31 -Release: 6 +Version: 35 +Release: 1 Summary: Linux D-Bus Message Broker License: Apache-2.0 URL: https://github.com/bus1/dbus-broker Source0: https://github.com/bus1/dbus-broker/releases/download/v%{version}/%{name}-%{version}.tar.xz -Patch0001: enable-dbus-broker-to-reexecute.patch -Patch0002: add-unit-test-for-dbus-broker.patch -Patch0003: backport-bus-peer-fix-catching-OOM-when-linking-match-rules.patch -Patch0004: backport-dbus-socket-set-msgheader-controllen-size-using-the-.patch -Patch0005: backport-launch-config-avoid-expat.h-in-header.patch -Patch0006: backport-util-fdlist-add-helper-to-return-list-size.patch -Patch0007: backport-util-selinux-follow-permissive-mode.patch -Patch0008: backport-util-selinux-provide-helper-to-check-enforcing-mode.patch -Patch0009: backport-util-selinux-try-opening-the-status-page.patch -Patch0010: backport-launch-config-use-AT_RANDOM-for-XML-hash-salt.patch +# Patches from upstream use Patch0001 + +# Patches from openEuler use Patch8001 +Patch8001: enable-dbus-broker-to-reexecute.patch +Patch8002: add-unit-test-for-dbus-broker.patch BuildRequires: cmake gcc glibc-devel meson python-docutils dbus BuildRequires: pkgconfig(expat) pkgconfig(libsystemd) pkgconfig(libselinux) @@ -93,8 +88,12 @@ fi %{_userunitdir}/dbus-broker.service %changelog +* Tue Feb 27 2024 hongjinghao - 35-1 +- upgrade to 35 + * Sat Oct 7 2023 hongjinghao - 31-6 - Fix buffer leakage + * Wed Aug 9 2023 hongjinghao - 31-5 - sync patches from dbus-broker community diff --git a/enable-dbus-broker-to-reexecute.patch b/enable-dbus-broker-to-reexecute.patch index 2fd4591..fffe7f0 100644 --- a/enable-dbus-broker-to-reexecute.patch +++ b/enable-dbus-broker-to-reexecute.patch @@ -21,7 +21,7 @@ Subject: [PATCH 1/2] enable dbus-broker to reexecute src/dbus/connection.h | 1 + src/dbus/socket.c | 2 +- src/dbus/socket.h | 1 + - src/launch/launcher.c | 213 +++++++++++++++--- + src/launch/launcher.c | 212 +++++++++++++++--- src/launch/launcher.h | 6 +- src/launch/main.c | 119 +++++++++- src/meson.build | 1 + @@ -31,12 +31,12 @@ Subject: [PATCH 1/2] enable dbus-broker to reexecute src/util/serialize.h | 39 ++++ src/util/string.c | 79 +++++++ src/util/string.h | 3 + - 27 files changed, 1305 insertions(+), 51 deletions(-) + 27 files changed, 1304 insertions(+), 51 deletions(-) create mode 100644 src/util/serialize.c create mode 100644 src/util/serialize.h diff --git a/src/broker/broker.c b/src/broker/broker.c -index 49f2680..51c7e8f 100644 +index 7a56fa7..eba2970 100644 --- a/src/broker/broker.c +++ b/src/broker/broker.c @@ -10,6 +10,7 @@ @@ -182,7 +182,7 @@ index 49f2680..51c7e8f 100644 broker->signals_file = (DispatchFile)DISPATCH_FILE_NULL(broker->signals_file); broker->controller = (Controller)CONTROLLER_NULL(broker->controller); -@@ -200,7 +307,6 @@ int broker_run(Broker *broker) { +@@ -210,7 +317,6 @@ int broker_run(Broker *broker) { sigemptyset(&signew); sigaddset(&signew, SIGTERM); sigaddset(&signew, SIGINT); @@ -190,7 +190,7 @@ index 49f2680..51c7e8f 100644 sigprocmask(SIG_BLOCK, &signew, &sigold); r = connection_open(&broker->controller.connection); -@@ -209,6 +315,12 @@ int broker_run(Broker *broker) { +@@ -219,6 +325,12 @@ int broker_run(Broker *broker) { else if (r) return error_fold(r); @@ -203,7 +203,7 @@ index 49f2680..51c7e8f 100644 do { r = dispatch_context_dispatch(&broker->dispatcher); if (r == DISPATCH_E_EXIT) -@@ -217,8 +329,20 @@ int broker_run(Broker *broker) { +@@ -227,8 +339,20 @@ int broker_run(Broker *broker) { r = MAIN_FAILED; else r = error_fold(r); @@ -224,7 +224,7 @@ index 49f2680..51c7e8f 100644 peer_registry_flush(&broker->bus.peers); k = broker_log_metrics(broker); -@@ -248,3 +372,24 @@ int broker_reload_config(Broker *broker, User *sender_user, uint64_t sender_id, +@@ -258,3 +382,24 @@ int broker_reload_config(Broker *broker, User *sender_user, uint64_t sender_id, return 0; } @@ -326,7 +326,7 @@ index a38f597..a6bca1a 100644 } +int deserialize_broker(Broker *broker, int mem_fd); diff --git a/src/broker/controller-dbus.c b/src/broker/controller-dbus.c -index 449151d..3c3ab7d 100644 +index 68be2bc..504a35d 100644 --- a/src/broker/controller-dbus.c +++ b/src/broker/controller-dbus.c @@ -11,6 +11,7 @@ @@ -337,7 +337,7 @@ index 449151d..3c3ab7d 100644 #include "dbus/connection.h" #include "dbus/message.h" #include "dbus/protocol.h" -@@ -271,8 +272,18 @@ static int controller_method_add_listener(Controller *controller, const char *_p +@@ -273,8 +274,18 @@ static int controller_method_add_listener(Controller *controller, const char *_p policy = NULL; fdlist_steal(fds, fd_index); @@ -356,7 +356,7 @@ index 449151d..3c3ab7d 100644 return 0; } -@@ -520,6 +531,12 @@ static int controller_dispatch_reply(Controller *controller, uint32_t serial, co +@@ -528,6 +539,12 @@ static int controller_dispatch_reply(Controller *controller, uint32_t serial, co ControllerReload *reload; int r; @@ -369,7 +369,7 @@ index 449151d..3c3ab7d 100644 reload = controller_find_reload(controller, serial); if (!reload) return CONTROLLER_E_UNEXPECTED_REPLY; -@@ -781,3 +798,47 @@ int controller_dbus_send_reload(Controller *controller, User *user, uint32_t ser +@@ -789,3 +806,47 @@ int controller_dbus_send_reload(Controller *controller, User *user, uint32_t ser return 0; } @@ -418,7 +418,7 @@ index 449151d..3c3ab7d 100644 + return 0; +} diff --git a/src/broker/controller.c b/src/broker/controller.c -index 450c4ad..6a67077 100644 +index b9ce927..6ee2f62 100644 --- a/src/broker/controller.c +++ b/src/broker/controller.c @@ -373,6 +373,22 @@ int controller_request_reload(Controller *controller, @@ -445,10 +445,10 @@ index 450c4ad..6a67077 100644 * controller_find_name() - XXX */ diff --git a/src/broker/controller.h b/src/broker/controller.h -index a353003..ea680bc 100644 +index c3d18f0..acb550e 100644 --- a/src/broker/controller.h +++ b/src/broker/controller.h -@@ -139,6 +139,10 @@ int controller_request_reload(Controller *controller, +@@ -153,6 +153,10 @@ int controller_request_reload(Controller *controller, User *user, uint64_t sender_id, uint32_t sender_serial); @@ -459,7 +459,7 @@ index a353003..ea680bc 100644 ControllerName *controller_find_name(Controller *controller, const char *path); ControllerListener *controller_find_listener(Controller *controller, const char *path); ControllerReload *controller_find_reload(Controller *controller, uint32_t serial); -@@ -146,6 +150,7 @@ ControllerReload *controller_find_reload(Controller *controller, uint32_t serial +@@ -160,6 +164,7 @@ ControllerReload *controller_find_reload(Controller *controller, uint32_t serial int controller_dbus_dispatch(Controller *controller, Message *message); int controller_dbus_send_activation(Controller *controller, const char *path, uint64_t serial); int controller_dbus_send_reload(Controller *controller, User *user, uint32_t serial); @@ -563,18 +563,18 @@ index 81afb3d..37c822b 100644 }; diff --git a/src/bus/driver.c b/src/bus/driver.c -index b9774d6..874cc73 100644 +index 6fff07a..ef99ccb 100644 --- a/src/bus/driver.c +++ b/src/bus/driver.c -@@ -19,6 +19,7 @@ - #include "dbus/protocol.h" +@@ -21,6 +21,7 @@ #include "dbus/socket.h" + #include "util/apparmor.h" #include "util/error.h" +#include "util/proc.h" #include "util/selinux.h" #include "util/string.h" -@@ -1592,6 +1593,45 @@ static int driver_method_reload_config(Peer *peer, const char *path, CDVar *in_v +@@ -1658,6 +1659,45 @@ static int driver_method_reload_config(Peer *peer, const char *path, CDVar *in_v return 0; } @@ -620,12 +620,12 @@ index b9774d6..874cc73 100644 static int driver_method_get_id(Peer *peer, const char *path, CDVar *in_v, uint32_t serial, CDVar *out_v) { char buffer[sizeof(peer->bus->guid) * 2 + 1] = {}; int r; -@@ -2285,6 +2325,7 @@ static const DriverMethod driver_methods[] = { - { "UpdateActivationEnvironment", true, "/org/freedesktop/DBus", driver_method_update_activation_environment, driver_type_in_apss, driver_type_out_unit }, - { "GetNameOwner", true, NULL, driver_method_get_name_owner, driver_type_in_s, driver_type_out_s }, - { "ReloadConfig", true, NULL, driver_method_reload_config, c_dvar_type_unit, driver_type_out_unit }, -+ { "Reexecute", true, NULL, driver_method_reexecute, c_dvar_type_unit, driver_type_out_s }, - { "GetId", true, NULL, driver_method_get_id, c_dvar_type_unit, driver_type_out_s }, +@@ -2363,6 +2403,7 @@ static const DriverMethod driver_methods[] = { + { "UpdateActivationEnvironment", true, "/org/freedesktop/DBus", driver_method_update_activation_environment, driver_type_in_apss, driver_type_out_unit, false }, + { "GetNameOwner", true, NULL, driver_method_get_name_owner, driver_type_in_s, driver_type_out_s, false }, + { "ReloadConfig", true, NULL, driver_method_reload_config, c_dvar_type_unit, driver_type_out_unit, false }, ++ { "Reexecute", true, NULL, driver_method_reexecute, c_dvar_type_unit, driver_type_out_s, false }, + { "GetId", true, NULL, driver_method_get_id, c_dvar_type_unit, driver_type_out_s, false }, { }, }; diff --git a/src/bus/listener.c b/src/bus/listener.c @@ -710,7 +710,7 @@ index a6b39ea..59eaf7f 100644 void match_owner_get_stats(MatchOwner *owner, unsigned int *n_bytesp, unsigned int *n_matchesp); void match_owner_move(MatchOwner *to, MatchOwner *from); diff --git a/src/bus/peer.c b/src/bus/peer.c -index ce4584c..3f72dbf 100644 +index 9d64d78..0a35c45 100644 --- a/src/bus/peer.c +++ b/src/bus/peer.c @@ -8,6 +8,7 @@ @@ -749,7 +749,7 @@ index ce4584c..3f72dbf 100644 _c_cleanup_(peer_freep) Peer *peer = NULL; _c_cleanup_(user_unrefp) User *user = NULL; _c_cleanup_(c_freep) gid_t *gids = NULL; -@@ -269,7 +274,11 @@ int peer_new_with_fd(Peer **peerp, +@@ -270,7 +275,11 @@ int peer_new_with_fd(Peer **peerp, if (r < 0) return error_origin(-errno); @@ -759,10 +759,10 @@ index ce4584c..3f72dbf 100644 + else + r = user_registry_ref_user(&bus->users, &user, ucred.uid); + - if (r < 0) + if (r) return error_fold(r); -@@ -324,7 +333,10 @@ int peer_new_with_fd(Peer **peerp, +@@ -337,7 +346,10 @@ int peer_new_with_fd(Peer **peerp, if (r < 0) return error_fold(r); @@ -774,7 +774,7 @@ index ce4584c..3f72dbf 100644 slot = c_rbtree_find_slot(&bus->peers.peer_tree, peer_compare, &peer->id, &parent); c_assert(slot); /* peer->id is guaranteed to be unique */ c_rbtree_add(&bus->peers.peer_tree, parent, slot, &peer->registry_node); -@@ -353,6 +365,7 @@ Peer *peer_free(Peer *peer) { +@@ -367,6 +379,7 @@ Peer *peer_free(Peer *peer) { reply_owner_deinit(&peer->owned_replies); reply_registry_deinit(&peer->replies); match_owner_deinit(&peer->owned_matches); @@ -782,7 +782,7 @@ index ce4584c..3f72dbf 100644 match_registry_deinit(&peer->name_owner_changed_matches); match_registry_deinit(&peer->sender_matches); name_owner_deinit(&peer->owned_names); -@@ -376,7 +389,6 @@ int peer_spawn(Peer *peer) { +@@ -390,7 +403,6 @@ int peer_spawn(Peer *peer) { } void peer_register(Peer *peer) { @@ -790,7 +790,7 @@ index ce4584c..3f72dbf 100644 c_assert(!peer->monitor); peer->registered = true; -@@ -460,6 +472,24 @@ void peer_release_name_ownership(Peer *peer, NameOwnership *ownership, NameChang +@@ -476,6 +488,24 @@ void peer_release_name_ownership(Peer *peer, NameOwnership *ownership, NameChang name_ownership_release(ownership, change); } @@ -815,7 +815,7 @@ index ce4584c..3f72dbf 100644 static int peer_link_match(Peer *peer, MatchRule *rule, bool monitor) { Address addr; Peer *sender, *owner; -@@ -591,6 +621,10 @@ int peer_add_match(Peer *peer, const char *rule_string) { +@@ -609,6 +639,10 @@ int peer_add_match(Peer *peer, const char *rule_string) { _c_cleanup_(match_rule_user_unrefp) MatchRule *rule = NULL; int r; @@ -826,7 +826,7 @@ index ce4584c..3f72dbf 100644 r = match_owner_ref_rule(&peer->owned_matches, &rule, peer->user, rule_string, false); if (r) { if (r == MATCH_E_QUOTA) -@@ -811,7 +845,7 @@ int peer_queue_unicast(PolicySnapshot *sender_policy, NameSet *sender_names, Rep +@@ -849,7 +883,7 @@ int peer_queue_unicast(PolicySnapshot *sender_policy, NameSet *sender_names, Rep int peer_queue_reply(Peer *sender, const char *destination, uint32_t reply_serial, Message *message) { _c_cleanup_(reply_slot_freep) ReplySlot *slot = NULL; @@ -835,7 +835,7 @@ index ce4584c..3f72dbf 100644 Address addr; int r; -@@ -820,10 +854,13 @@ int peer_queue_reply(Peer *sender, const char *destination, uint32_t reply_seria +@@ -858,10 +892,13 @@ int peer_queue_reply(Peer *sender, const char *destination, uint32_t reply_seria return PEER_E_UNEXPECTED_REPLY; slot = reply_slot_get_by_id(&sender->replies, addr.id, reply_serial); @@ -852,7 +852,7 @@ index ce4584c..3f72dbf 100644 r = connection_queue(&receiver->connection, NULL, message); if (r) { -@@ -880,3 +917,225 @@ Peer *peer_registry_find_peer(PeerRegistry *registry, uint64_t id) { +@@ -918,3 +955,225 @@ Peer *peer_registry_find_peer(PeerRegistry *registry, uint64_t id) { return peer && peer->registered ? peer : NULL; } @@ -1079,7 +1079,7 @@ index ce4584c..3f72dbf 100644 + return 0; +} diff --git a/src/bus/peer.h b/src/bus/peer.h -index b9e30c5..cb5feff 100644 +index 4cf202a..457c7b5 100644 --- a/src/bus/peer.h +++ b/src/bus/peer.h @@ -8,6 +8,7 @@ @@ -1090,7 +1090,7 @@ index b9e30c5..cb5feff 100644 #include "bus/match.h" #include "bus/name.h" #include "bus/policy.h" -@@ -75,6 +76,7 @@ struct Peer { +@@ -76,6 +77,7 @@ struct Peer { MatchRegistry sender_matches; MatchRegistry name_owner_changed_matches; MatchOwner owned_matches; @@ -1098,7 +1098,7 @@ index b9e30c5..cb5feff 100644 ReplyRegistry replies; ReplyOwner owned_replies; }; -@@ -90,6 +92,7 @@ struct Peer { +@@ -89,6 +91,7 @@ struct Peer { .sender_matches = MATCH_REGISTRY_INIT((_x).sender_matches), \ .name_owner_changed_matches = MATCH_REGISTRY_INIT((_x).name_owner_changed_matches), \ .owned_matches = MATCH_OWNER_INIT((_x).owned_matches), \ @@ -1106,7 +1106,7 @@ index b9e30c5..cb5feff 100644 .replies = REPLY_REGISTRY_INIT, \ .owned_replies = REPLY_OWNER_INIT((_x).owned_replies), \ } -@@ -101,7 +104,8 @@ struct PeerRegistry { +@@ -100,7 +103,8 @@ struct PeerRegistry { #define PEER_REGISTRY_INIT {} @@ -1116,7 +1116,7 @@ index b9e30c5..cb5feff 100644 Peer *peer_free(Peer *peer); int peer_dispatch(DispatchFile *file); -@@ -130,6 +134,8 @@ void peer_registry_deinit(PeerRegistry *registry); +@@ -129,6 +133,8 @@ void peer_registry_deinit(PeerRegistry *registry); void peer_registry_flush(PeerRegistry *registry); Peer *peer_registry_find_peer(PeerRegistry *registry, uint64_t id); @@ -1151,7 +1151,7 @@ index d694fc6..4c7343a 100644 }; diff --git a/src/dbus/socket.c b/src/dbus/socket.c -index c0a9aff..58e784b 100644 +index 85eedda..672f353 100644 --- a/src/dbus/socket.c +++ b/src/dbus/socket.c @@ -732,7 +732,7 @@ static int socket_dispatch_read(Socket *socket) { @@ -1176,11 +1176,11 @@ index 67a49ae..077458f 100644 void socket_close(Socket *socket); void socket_get_stats(Socket *socket, diff --git a/src/launch/launcher.c b/src/launch/launcher.c -index 3fd69e0..69adb19 100644 +index a4b7460..8b52bef 100644 --- a/src/launch/launcher.c +++ b/src/launch/launcher.c -@@ -28,7 +28,10 @@ - #include "util/error.h" +@@ -29,7 +29,10 @@ + #include "util/fs.h" #include "util/log.h" #include "util/misc.h" +#include "util/proc.h" @@ -1190,7 +1190,7 @@ index 3fd69e0..69adb19 100644 /* * These are the default limits used when spawning dbus-broker. They are -@@ -43,6 +46,18 @@ static const uint64_t main_max_match_rules_per_connection = 256; +@@ -44,6 +47,18 @@ static const uint64_t main_max_match_rules_per_connection = 256; static const char * main_arg_broker = BINDIR "/dbus-broker"; @@ -1209,7 +1209,7 @@ index 3fd69e0..69adb19 100644 static sd_bus *bus_close_unref(sd_bus *bus) { /* * It is not sufficient to simply call sd_bus_unref(), as messages -@@ -100,6 +115,79 @@ static void log_append_service_user(Log *log, const char *user) { +@@ -101,6 +116,79 @@ static void log_append_service_user(Log *log, const char *user) { } static int launcher_reload_config(Launcher *launcher); @@ -1289,7 +1289,7 @@ index 3fd69e0..69adb19 100644 static int launcher_on_sighup(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) { Launcher *launcher = userdata; -@@ -187,7 +275,8 @@ static int launcher_open_log(Launcher *launcher) { +@@ -188,7 +276,8 @@ static int launcher_open_log(Launcher *launcher) { return 0; } @@ -1299,7 +1299,7 @@ index 3fd69e0..69adb19 100644 _c_cleanup_(launcher_freep) Launcher *launcher = NULL; int r; -@@ -199,7 +288,10 @@ int launcher_new(Launcher **launcherp, int fd_listen, bool audit, const char *co +@@ -200,7 +289,10 @@ int launcher_new(Launcher **launcherp, int fd_listen, bool audit, const char *co launcher->fd_listen = fd_listen; launcher->uid = -1; launcher->gid = -1; @@ -1310,7 +1310,7 @@ index 3fd69e0..69adb19 100644 launcher->user_scope = user_scope; if (configfile) -@@ -266,7 +358,7 @@ static noreturn void launcher_run_child(Launcher *launcher, int fd_log, int fd_c +@@ -267,7 +359,7 @@ static noreturn void launcher_run_child(Launcher *launcher, int fd_log, int fd_c str_max_fds[C_DECIMAL_MAX(uint64_t)], str_max_matches[C_DECIMAL_MAX(uint64_t)]; const char * const argv[] = { @@ -1319,7 +1319,7 @@ index 3fd69e0..69adb19 100644 "--log", str_log, "--controller", -@@ -290,12 +382,6 @@ static noreturn void launcher_run_child(Launcher *launcher, int fd_log, int fd_c +@@ -291,12 +383,6 @@ static noreturn void launcher_run_child(Launcher *launcher, int fd_log, int fd_c goto exit; } @@ -1332,7 +1332,7 @@ index 3fd69e0..69adb19 100644 r = fcntl(fd_log, F_GETFD); if (r < 0) { r = error_origin(-errno); -@@ -361,10 +447,37 @@ static int launcher_on_child_exit(sd_event_source *source, const siginfo_t *si, +@@ -362,10 +448,37 @@ static int launcher_on_child_exit(sd_event_source *source, const siginfo_t *si, if (r) return error_fold(r); @@ -1371,7 +1371,7 @@ index 3fd69e0..69adb19 100644 static int launcher_fork(Launcher *launcher, int fd_controller) { pid_t pid; int r; -@@ -376,6 +489,7 @@ static int launcher_fork(Launcher *launcher, int fd_controller) { +@@ -377,6 +490,7 @@ static int launcher_fork(Launcher *launcher, int fd_controller) { if (!pid) launcher_run_child(launcher, log_get_fd(&launcher->log), fd_controller); @@ -1379,7 +1379,7 @@ index 3fd69e0..69adb19 100644 r = sd_event_add_child(launcher->event, NULL, pid, WEXITED, launcher_on_child_exit, launcher); if (r < 0) return error_origin(-errno); -@@ -1101,7 +1215,8 @@ static int launcher_load_policy(Launcher *launcher, ConfigRoot *root, Policy *po +@@ -1102,7 +1216,8 @@ static int launcher_load_policy(Launcher *launcher, ConfigRoot *root, Policy *po return 0; } @@ -1389,7 +1389,7 @@ index 3fd69e0..69adb19 100644 _c_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; int r; -@@ -1303,13 +1418,22 @@ static int bus_method_reload_config(sd_bus_message *message, void *userdata, sd_ +@@ -1304,13 +1419,22 @@ static int bus_method_reload_config(sd_bus_message *message, void *userdata, sd_ return sd_bus_reply_method_return(message, NULL); } @@ -1417,7 +1417,7 @@ index 3fd69e0..69adb19 100644 int launcher_run(Launcher *launcher) { _c_cleanup_(config_root_freep) ConfigRoot *root = NULL; -@@ -1371,26 +1495,45 @@ int launcher_run(Launcher *launcher) { +@@ -1378,26 +1502,45 @@ int launcher_run(Launcher *launcher) { return 0; } @@ -1479,7 +1479,7 @@ index 3fd69e0..69adb19 100644 r = sd_bus_add_object_vtable(launcher->bus_controller, NULL, "/org/bus1/DBus/Controller", "org.bus1.DBus.Controller", launcher_vtable, launcher); if (r < 0) -@@ -1412,6 +1555,11 @@ int launcher_run(Launcher *launcher) { +@@ -1419,6 +1562,11 @@ int launcher_run(Launcher *launcher) { if (r) return error_trace(r); @@ -1491,12 +1491,7 @@ index 3fd69e0..69adb19 100644 r = launcher_connect(launcher); if (r) return error_trace(r); -@@ -1434,10 +1582,13 @@ int launcher_run(Launcher *launcher) { - return error_fold(r); - } - -+ log_append_here(&launcher->log, LOG_INFO, 0, NULL); - r = log_commitf(&launcher->log, "Ready\n"); +@@ -1446,6 +1594,8 @@ int launcher_run(Launcher *launcher) { if (r) return error_fold(r); @@ -1724,7 +1719,7 @@ index ed08e85..672c99e 100644 if (r) goto exit; diff --git a/src/meson.build b/src/meson.build -index c363cbc..7db1ecb 100644 +index 2014372..c07f1c5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -41,6 +41,7 @@ sources_bus = [ @@ -1736,10 +1731,10 @@ index c363cbc..7db1ecb 100644 'util/string.c', 'util/systemd.c', diff --git a/src/units/system/dbus-broker.service.in b/src/units/system/dbus-broker.service.in -index 4155630..9912572 100644 +index cc5ae36..163853f 100644 --- a/src/units/system/dbus-broker.service.in +++ b/src/units/system/dbus-broker.service.in -@@ -16,6 +16,8 @@ PrivateTmp=true +@@ -17,6 +17,8 @@ PrivateTmp=true PrivateDevices=true ExecStart=@bindir@/dbus-broker-launch --scope system --audit ExecReload=@bindir@/busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus ReloadConfig @@ -1749,17 +1744,17 @@ index 4155630..9912572 100644 [Install] Alias=dbus.service diff --git a/src/util/proc.c b/src/util/proc.c -index 06d4e27..b502da1 100644 +index 4a876b9..a3cdf0f 100644 --- a/src/util/proc.c +++ b/src/util/proc.c -@@ -8,6 +8,7 @@ - #include +@@ -9,6 +9,7 @@ #include "util/error.h" #include "util/proc.h" + #include "util/string.h" +#include "util/serialize.h" - int proc_get_seclabel(pid_t pid, char **labelp, size_t *n_labelp) { - _c_cleanup_(c_fclosep) FILE *f = NULL; + /* + * A file in /proc can be at most 4M minus one. If required, we start with a 4K diff --git a/src/util/serialize.c b/src/util/serialize.c new file mode 100644 index 0000000..c027999 @@ -2048,14 +2043,13 @@ index 0000000..5a5758d +int serialize_peers(FILE *f, Broker *broker); \ No newline at end of file diff --git a/src/util/string.c b/src/util/string.c -index dfbdced..4016f98 100644 +index e138d9f..71b5920 100644 --- a/src/util/string.c +++ b/src/util/string.c -@@ -55,3 +55,82 @@ int util_strtou64(uint64_t *valp, const char *string) { - +@@ -56,6 +56,85 @@ int util_strtou64(uint64_t *valp, const char *string) { return 0; } -+ + +void generate_args_string(bool valid_arg, char **ret, int size, int *cur_i, char *option, char *val) { + int i = *cur_i; + @@ -2134,14 +2128,18 @@ index dfbdced..4016f98 100644 + *ret = strndup(string + pi, i - pi); + return string + i + 1; +} ++ + int util_strtoint(int *valp, const char *string) { + long val; + char *end; diff --git a/src/util/string.h b/src/util/string.h -index 14f7171..f1c7d10 100644 +index 5ceeb2f..5138409 100644 --- a/src/util/string.h +++ b/src/util/string.h -@@ -17,6 +17,9 @@ enum { - +@@ -18,6 +18,9 @@ enum { int util_strtou32(uint32_t *valp, const char *string); int util_strtou64(uint64_t *valp, const char *string); + int util_strtoint(int *valp, const char *string); +void generate_args_string(bool valid_arg, char **ret, int size, int *cur_i, char *option, char *val); +char *extract_word_inlist(char *string, char **ret, int ret_length); +char *extract_list_element(char *string, char **ret); @@ -2149,5 +2147,5 @@ index 14f7171..f1c7d10 100644 /** * string_compare() - compare two strings -- -2.30.2 +2.33.0