chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tty-ask-password-agent: modernization
[elogind.git]
/
src
/
core
/
manager.c
diff --git
a/src/core/manager.c
b/src/core/manager.c
index 9d9a713005daf0047e7c9dd71c626bfb5d2df36e..32c056588abca0493a5f62b02da87ae7d40cc2ea 100644
(file)
--- a/
src/core/manager.c
+++ b/
src/core/manager.c
@@
-241,6
+241,9
@@
static int manager_setup_time_change(Manager *m) {
assert(m);
assert_cc(sizeof(time_t) == sizeof(TIME_T_MAX));
assert(m);
assert_cc(sizeof(time_t) == sizeof(TIME_T_MAX));
+ if (m->test_run)
+ return 0;
+
/* Uses TFD_TIMER_CANCEL_ON_SET to get notifications whenever
* CLOCK_REALTIME makes a jump relative to CLOCK_MONOTONIC */
/* Uses TFD_TIMER_CANCEL_ON_SET to get notifications whenever
* CLOCK_REALTIME makes a jump relative to CLOCK_MONOTONIC */
@@
-302,6
+305,9
@@
static int manager_setup_signals(Manager *m) {
assert(m);
assert(m);
+ if (m->test_run)
+ return 0;
+
/* We are not interested in SIGSTOP and friends. */
assert_se(sigaction(SIGCHLD, &sa, NULL) == 0);
/* We are not interested in SIGSTOP and friends. */
assert_se(sigaction(SIGCHLD, &sa, NULL) == 0);
@@
-409,7
+415,7
@@
static int manager_default_environment(Manager *m) {
return 0;
}
return 0;
}
-int manager_new(SystemdRunningAs running_as, Manager **_m) {
+int manager_new(SystemdRunningAs running_as,
bool test_run,
Manager **_m) {
Manager *m;
int r;
Manager *m;
int r;
@@
-435,6
+441,8
@@
int manager_new(SystemdRunningAs running_as, Manager **_m) {
m->pin_cgroupfs_fd = m->notify_fd = m->signal_fd = m->time_change_fd = m->dev_autofs_fd = m->private_listen_fd = m->kdbus_fd = -1;
m->current_job_id = 1; /* start as id #1, so that we can leave #0 around as "null-like" value */
m->pin_cgroupfs_fd = m->notify_fd = m->signal_fd = m->time_change_fd = m->dev_autofs_fd = m->private_listen_fd = m->kdbus_fd = -1;
m->current_job_id = 1; /* start as id #1, so that we can leave #0 around as "null-like" value */
+ m->test_run = test_run;
+
r = manager_default_environment(m);
if (r < 0)
goto fail;
r = manager_default_environment(m);
if (r < 0)
goto fail;
@@
-514,6
+522,9
@@
fail:
static int manager_setup_notify(Manager *m) {
int r;
static int manager_setup_notify(Manager *m) {
int r;
+ if (m->test_run)
+ return 0;
+
if (m->notify_fd < 0) {
_cleanup_close_ int fd = -1;
union {
if (m->notify_fd < 0) {
_cleanup_close_ int fd = -1;
union {
@@
-592,12
+603,10
@@
static int manager_setup_notify(Manager *m) {
static int manager_setup_kdbus(Manager *m) {
#ifdef ENABLE_KDBUS
_cleanup_free_ char *p = NULL;
static int manager_setup_kdbus(Manager *m) {
#ifdef ENABLE_KDBUS
_cleanup_free_ char *p = NULL;
-#endif
-#ifdef ENABLE_KDBUS
assert(m);
assert(m);
- if (m->kdbus_fd >= 0)
+ if (m->
test_run || m->
kdbus_fd >= 0)
return 0;
m->kdbus_fd = bus_kernel_create_bus(m->running_as == SYSTEMD_SYSTEM ? "system" : "user", m->running_as == SYSTEMD_SYSTEM, &p);
return 0;
m->kdbus_fd = bus_kernel_create_bus(m->running_as == SYSTEMD_SYSTEM ? "system" : "user", m->running_as == SYSTEMD_SYSTEM, &p);
@@
-624,6
+633,9
@@
static int manager_connect_bus(Manager *m, bool reexecuting) {
assert(m);
assert(m);
+ if (m->test_run)
+ return 0;
+
try_bus_connect =
m->kdbus_fd >= 0 ||
reexecuting ||
try_bus_connect =
m->kdbus_fd >= 0 ||
reexecuting ||
@@
-993,11
+1005,8
@@
int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
dual_timestamp_get(&m->units_load_finish_timestamp);
/* Second, deserialize if there is something to deserialize */
dual_timestamp_get(&m->units_load_finish_timestamp);
/* Second, deserialize if there is something to deserialize */
- if (serialization) {
- q = manager_deserialize(m, serialization, fds);
- if (q < 0)
- r = q;
- }
+ if (serialization)
+ r = manager_deserialize(m, serialization, fds);
/* Any fds left? Find some unit which wants them. This is
* useful to allow container managers to pass some file
/* Any fds left? Find some unit which wants them. This is
* useful to allow container managers to pass some file
@@
-1005,13
+1014,15
@@
int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
* socket-based activation of entire containers. */
if (fdset_size(fds) > 0) {
q = manager_distribute_fds(m, fds);
* socket-based activation of entire containers. */
if (fdset_size(fds) > 0) {
q = manager_distribute_fds(m, fds);
- if (q < 0)
+ if (q < 0
&& r == 0
)
r = q;
}
/* We might have deserialized the notify fd, but if we didn't
* then let's create the bus now */
r = q;
}
/* We might have deserialized the notify fd, but if we didn't
* then let's create the bus now */
- manager_setup_notify(m);
+ q = manager_setup_notify(m);
+ if (q < 0 && r == 0)
+ r = q;
/* We might have deserialized the kdbus control fd, but if we
* didn't, then let's create the bus now. */
/* We might have deserialized the kdbus control fd, but if we
* didn't, then let's create the bus now. */
@@
-1021,7
+1032,7
@@
int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
/* Third, fire things up! */
q = manager_coldplug(m);
/* Third, fire things up! */
q = manager_coldplug(m);
- if (q < 0)
+ if (q < 0
&& r == 0
)
r = q;
if (serialization) {
r = q;
if (serialization) {
@@
-1864,7
+1875,7
@@
int manager_loop(Manager *m) {
if (wait_usec <= 0)
wait_usec = 1;
} else
if (wait_usec <= 0)
wait_usec = 1;
} else
- wait_usec =
(usec_t) -1
;
+ wait_usec =
USEC_INFINITY
;
r = sd_event_run(m->event, wait_usec);
if (r < 0) {
r = sd_event_run(m->event, wait_usec);
if (r < 0) {
@@
-1966,10
+1977,7
@@
void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
}
void manager_send_unit_plymouth(Manager *m, Unit *u) {
}
void manager_send_unit_plymouth(Manager *m, Unit *u) {
- union sockaddr_union sa = {
- .un.sun_family = AF_UNIX,
- .un.sun_path = "\0/org/freedesktop/plymouthd",
- };
+ union sockaddr_union sa = PLYMOUTH_SOCKET;
int n = 0;
_cleanup_free_ char *message = NULL;
int n = 0;
_cleanup_free_ char *message = NULL;
@@
-2636,6
+2644,9
@@
void manager_run_generators(Manager *m) {
assert(m);
assert(m);
+ if (m->test_run)
+ return;
+
generator_path = m->running_as == SYSTEMD_SYSTEM ? SYSTEM_GENERATOR_PATH : USER_GENERATOR_PATH;
d = opendir(generator_path);
if (!d) {
generator_path = m->running_as == SYSTEMD_SYSTEM ? SYSTEM_GENERATOR_PATH : USER_GENERATOR_PATH;
d = opendir(generator_path);
if (!d) {