Compare commits
10 Commits
642f220d33
...
0e04342999
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e04342999 | ||
|
|
3f51b78ba7 | ||
|
|
c7cd3001b9 | ||
|
|
3243603711 | ||
|
|
714b890652 | ||
|
|
832e3bf8c0 | ||
|
|
51a9f1eab8 | ||
|
|
f9a8d97e90 | ||
|
|
82e330ab21 | ||
|
|
66a3f8d37a |
@ -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 @@
|
||||
@ -209,7 +209,7 @@ index 0000000..e287647
|
||||
+
|
||||
+ int i = 0;
|
||||
+ while (true) {
|
||||
+ list1 = extract_word_inlist(list1, &res);
|
||||
+ list1 = extract_word_inlist(list1, &res, 1);
|
||||
+ if (!list1)
|
||||
+ break;
|
||||
+ c_assert(!strcmp(res, res1[i++]));
|
||||
@ -217,7 +217,7 @@ index 0000000..e287647
|
||||
+
|
||||
+ i = 0;
|
||||
+ while (true) {
|
||||
+ list2 = extract_word_inlist(list2, &res);
|
||||
+ list2 = extract_word_inlist(list2, &res, 3);
|
||||
+ if (!list2)
|
||||
+ break;
|
||||
+ c_assert(!strcmp(res, res2[i++]));
|
||||
@ -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
|
||||
|
||||
|
||||
Binary file not shown.
BIN
dbus-broker-35.tar.xz
Normal file
BIN
dbus-broker-35.tar.xz
Normal file
Binary file not shown.
@ -1,13 +1,16 @@
|
||||
Name: dbus-broker
|
||||
Version: 31
|
||||
Release: 3
|
||||
Version: 35
|
||||
Release: 2
|
||||
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
|
||||
# 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)
|
||||
@ -85,6 +88,21 @@ fi
|
||||
%{_userunitdir}/dbus-broker.service
|
||||
|
||||
%changelog
|
||||
* Fri May 24 2024 huyubiao<huyubiao@huawei.com> - 35-2
|
||||
- fix enable-dbus-broker-to-reexecute.patch
|
||||
|
||||
* Tue Feb 27 2024 hongjinghao<hongjinghao@huawei.com> - 35-1
|
||||
- upgrade to 35
|
||||
|
||||
* Sat Oct 7 2023 hongjinghao<hongjinghao@huawei.com> - 31-6
|
||||
- Fix buffer leakage
|
||||
|
||||
* Wed Aug 9 2023 hongjinghao<hongjinghao@huawei.com> - 31-5
|
||||
- sync patches from dbus-broker community
|
||||
|
||||
* Sun Jun 25 2023 hongjinghao<hongjinghao@huawei.com> - 31-4
|
||||
- sync patches from dbus-broker community
|
||||
|
||||
* Wed Jun 7 2023 hongjinghao<hongjinghao@huawei.com> - 31-3
|
||||
- Enable dbus-broker to reexecute without disconnection
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -864,7 +864,7 @@ index ce4584c..3f72dbf 100644
|
||||
+ SASL_LENGTH_MAX};
|
||||
+ for (int i = 0; i < _PEER_INDEX_MAX; i++) {
|
||||
+ char *tmp_str = malloc(tmp_str_length[i]);
|
||||
+ peer_str = extract_word_inlist(peer_str, &tmp_str);
|
||||
+ peer_str = extract_word_inlist(peer_str, &tmp_str, tmp_str_length[i]);
|
||||
+ if (strlen(tmp_str) <= 0) {
|
||||
+ return error_origin(-EINVAL);
|
||||
+ }
|
||||
@ -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 <unistd.h>
|
||||
@@ -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
|
||||
@ -1922,7 +1917,7 @@ index 0000000..c027999
|
||||
+ r = log_commitf(&broker->log, "NameOwner string %s is invalid, skipping.\n",
|
||||
+ nameowner_ship_str);
|
||||
+ if (r < 0)
|
||||
+ return error_fold(r);
|
||||
+ return error_fold(r);
|
||||
+ close(peeri->connection.socket.fd);
|
||||
+ continue;
|
||||
+ }
|
||||
@ -1937,7 +1932,6 @@ index 0000000..c027999
|
||||
+ if (arg0 && !strncmp(arg0 + strlen("arg0"), "=':1", strlen("=':1"))) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ rule_str_list_cur = stpcpy(rule_str_list_cur, rule_str);
|
||||
+ left_length -= strlen(rule_str);
|
||||
+ /* Besides the next rule_str, we should also keep MATCH_RULE_LENGTH_MAX
|
||||
+ * bytes for sasl_str. sasl_str usually doesn't need that much space,
|
||||
@ -1946,6 +1940,7 @@ index 0000000..c027999
|
||||
+ skip_this_peer = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ rule_str_list_cur = stpcpy(rule_str_list_cur, rule_str);
|
||||
+ }
|
||||
+
|
||||
+ if (skip_this_peer) {
|
||||
@ -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;
|
||||
+
|
||||
@ -2075,7 +2069,7 @@ index dfbdced..4016f98 100644
|
||||
+@ret: value between ";""
|
||||
+input example: 1;2;3
|
||||
+output example: 1 => 2 => 3 (one by one) */
|
||||
+char *extract_word_inlist(char *string, char **ret) {
|
||||
+char *extract_word_inlist(char *string, char **ret, int ret_length) {
|
||||
+ int i = 0, length = strlen(string);
|
||||
+ bool found_value = false;
|
||||
+ while (i < length) {
|
||||
@ -2092,7 +2086,7 @@ index dfbdced..4016f98 100644
|
||||
+ }
|
||||
+ i++;
|
||||
+ }
|
||||
+ if (!found_value) {
|
||||
+ if (!found_value || ret_length < i) {
|
||||
+ **ret = 0;
|
||||
+ return NULL;
|
||||
+ }
|
||||
@ -2134,20 +2128,24 @@ 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);
|
||||
+char *extract_word_inlist(char *string, char **ret, int ret_length);
|
||||
+char *extract_list_element(char *string, char **ret);
|
||||
|
||||
/**
|
||||
* string_compare() - compare two strings
|
||||
--
|
||||
2.30.2
|
||||
2.33.0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user