Skip to content

Commit 1662732

Browse files
committed
systemd-udev-settle.service: emit deprecation notice
1 parent 18a3882 commit 1662732

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

src/udev/udevadm-settle.c

+64-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@
1313
#include <string.h>
1414
#include <unistd.h>
1515

16+
#include "sd-bus.h"
17+
#include "sd-login.h"
18+
1619
#include "libudev-util.h"
20+
#include "string-util.h"
21+
#include "strv.h"
1722
#include "time-util.h"
18-
#include "udevadm.h"
1923
#include "udev-ctrl.h"
24+
#include "udevadm.h"
25+
#include "unit-def.h"
2026
#include "util.h"
2127
#include "virt.h"
2228

@@ -79,6 +85,61 @@ static int parse_argv(int argc, char *argv[]) {
7985
return 1;
8086
}
8187

88+
static int emit_deprecation_warning(void) {
89+
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
90+
_cleanup_free_ char *unit = NULL, *unit_path = NULL;
91+
_cleanup_strv_free_ char **a = NULL, **b = NULL;
92+
int r;
93+
94+
r = sd_pid_get_unit(0, &unit);
95+
if (r < 0 || !streq(unit, "systemd-udev-settle.service"))
96+
return 0;
97+
98+
log_notice("systemd-udev-settle.service is deprecated.");
99+
100+
r = sd_bus_open_system(&bus);
101+
if (r < 0)
102+
return log_debug_errno(r, "Failed to open system bus, skipping dependency queries: %m");
103+
104+
unit_path = unit_dbus_path_from_name("systemd-udev-settle.service");
105+
if (!unit_path)
106+
return -ENOMEM;
107+
108+
(void) sd_bus_get_property_strv(
109+
bus,
110+
"org.freedesktop.systemd1",
111+
unit_path,
112+
"org.freedesktop.systemd1.Unit",
113+
"WantedBy",
114+
NULL,
115+
&a);
116+
117+
(void) sd_bus_get_property_strv(
118+
bus,
119+
"org.freedesktop.systemd1",
120+
unit_path,
121+
"org.freedesktop.systemd1.Unit",
122+
"RequiredBy",
123+
NULL,
124+
&b);
125+
126+
r = strv_extend_strv(&a, b, true);
127+
if (r < 0)
128+
return r;
129+
130+
if (!strv_isempty(a)) {
131+
_cleanup_free_ char *t = NULL;
132+
133+
t = strv_join(a, ", ");
134+
if (!t)
135+
return -ENOMEM;
136+
137+
log_notice("Hint: please fix %s not to pull it in.", t);
138+
}
139+
140+
return 0;
141+
}
142+
82143
int settle_main(int argc, char *argv[], void *userdata) {
83144
_cleanup_(udev_queue_unrefp) struct udev_queue *queue = NULL;
84145
struct pollfd pfd;
@@ -128,6 +189,8 @@ int settle_main(int argc, char *argv[], void *userdata) {
128189
.fd = r,
129190
};
130191

192+
(void) emit_deprecation_warning();
193+
131194
for (;;) {
132195
if (arg_exists && access(arg_exists, F_OK) >= 0)
133196
return 0;

0 commit comments

Comments
 (0)