Skip to content

Commit 0042a61

Browse files
committed
sys-apps/systemd: add systemd sysext patch
this patch reloads the daemon when merging/unmerging a systemd sysext image. Signed-off-by: Mathieu Tortuyaux <[email protected]>
1 parent 51274ac commit 0042a61

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
From 86a236734d79fded9a4ec268f9bd607847a371d9 Mon Sep 17 00:00:00 2001
2+
From: Mathieu Tortuyaux <[email protected]>
3+
Date: Mon, 17 Apr 2023 12:27:55 +0200
4+
Subject: [PATCH] v252-sysext: reload the daemon on merge/unmerge/refresh
5+
6+
this ensure to properly load/unload the systemd unit files from the
7+
systemd sysext image.
8+
9+
Signed-off-by: Mathieu Tortuyaux <[email protected]>
10+
---
11+
src/sysext/sysext.c | 48 +++++++++++++++++++++++++++++++++++++++++++++
12+
1 file changed, 48 insertions(+)
13+
14+
diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c
15+
index 0875099d5f..97b8adf435 100644
16+
--- a/src/sysext/sysext.c
17+
+++ b/src/sysext/sysext.c
18+
@@ -7,8 +7,14 @@
19+
#include <sys/mount.h>
20+
#include <unistd.h>
21+
22+
+#include "sd-bus.h"
23+
+
24+
+#include "bus-locator.h"
25+
+#include "bus-error.h"
26+
+#include "bus-util.h"
27+
#include "capability-util.h"
28+
#include "chase-symlinks.h"
29+
+#include "def.h"
30+
#include "devnum-util.h"
31+
#include "discover-image.h"
32+
#include "dissect-image.h"
33+
@@ -43,10 +49,33 @@ static JsonFormatFlags arg_json_format_flags = JSON_FORMAT_OFF;
34+
static PagerFlags arg_pager_flags = 0;
35+
static bool arg_legend = true;
36+
static bool arg_force = false;
37+
+static bool arg_no_reload = false;
38+
39+
STATIC_DESTRUCTOR_REGISTER(arg_hierarchies, strv_freep);
40+
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
41+
42+
+static int daemon_reload(void) {
43+
+ _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
44+
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
45+
+ sd_bus *bus;
46+
+ int r;
47+
+
48+
+ r = bus_connect_system_systemd(&bus);
49+
+ if (r < 0)
50+
+ return r;
51+
+
52+
+ r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "Reload");
53+
+ if (r < 0)
54+
+ return bus_log_create_error(r);
55+
+
56+
+ /* Reloading the daemon may take long, hence set a longer timeout here */
57+
+ r = sd_bus_call(bus, m, DAEMON_RELOAD_TIMEOUT_SEC, &error, NULL);
58+
+ if (r < 0)
59+
+ return log_error_errno(r, "Failed to reload daemon: %s", bus_error_message(&error, r));
60+
+
61+
+ return 0;
62+
+}
63+
+
64+
static int is_our_mount_point(const char *p) {
65+
_cleanup_free_ char *buf = NULL, *f = NULL;
66+
struct stat st;
67+
@@ -147,6 +176,12 @@ static int unmerge(void) {
68+
ret = r;
69+
}
70+
71+
+ if (!arg_no_reload) {
72+
+ r = daemon_reload();
73+
+ if (r < 0)
74+
+ return r;
75+
+ }
76+
+
77+
return ret;
78+
}
79+
80+
@@ -724,6 +759,12 @@ static int merge(Hashmap *images) {
81+
if (r < 0)
82+
return r;
83+
84+
+ if (!arg_no_reload) {
85+
+ r = daemon_reload();
86+
+ if (r < 0)
87+
+ return r;
88+
+ }
89+
+
90+
return r != 123; /* exit code 123 means: didn't do anything */
91+
}
92+
93+
@@ -889,6 +930,7 @@ static int verb_help(int argc, char **argv, void *userdata) {
94+
" --json=pretty|short|off\n"
95+
" Generate JSON output\n"
96+
" --force Ignore version incompatibilities\n"
97+
+ " --no-reload Do not reload the daemon after (un)merging/refreshing\n"
98+
"\nSee the %2$s for details.\n",
99+
program_invocation_short_name,
100+
link,
101+
@@ -909,6 +951,7 @@ static int parse_argv(int argc, char *argv[]) {
102+
ARG_ROOT,
103+
ARG_JSON,
104+
ARG_FORCE,
105+
+ ARG_NO_RELOAD,
106+
};
107+
108+
static const struct option options[] = {
109+
@@ -919,6 +962,7 @@ static int parse_argv(int argc, char *argv[]) {
110+
{ "root", required_argument, NULL, ARG_ROOT },
111+
{ "json", required_argument, NULL, ARG_JSON },
112+
{ "force", no_argument, NULL, ARG_FORCE },
113+
+ { "no-reload", no_argument, NULL, ARG_NO_RELOAD },
114+
{}
115+
};
116+
117+
@@ -962,6 +1006,10 @@ static int parse_argv(int argc, char *argv[]) {
118+
arg_force = true;
119+
break;
120+
121+
+ case ARG_NO_RELOAD:
122+
+ arg_no_reload = true;
123+
+ break;
124+
+
125+
case '?':
126+
return -EINVAL;
127+
128+
--
129+
2.35.1
130+

sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/systemd-252.5.ebuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ src_prepare() {
248248
"${FILESDIR}/0005-systemd-Disable-SELinux-permissions-checks.patch"
249249
"${FILESDIR}/0006-Revert-getty-Pass-tty-to-use-by-agetty-via-stdin.patch"
250250
"${FILESDIR}/0007-units-Keep-using-old-journal-file-format.patch"
251+
"${FILESDIR}/0008-v252-sysext-reload-the-daemon-on-merge-unmerge-refre.patch"
251252
)
252253

253254
if ! use vanilla; then

0 commit comments

Comments
 (0)