return 0;
}
+void manager_set_switching_root(Manager *m, bool switching_root) {
+ m->switching_root = MANAGER_IS_SYSTEM(m) && switching_root;
+}
+
int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager **_m) {
_cleanup_(manager_freep) Manager *m = NULL;
int r;
(void) touch_file("/run/systemd/systemd-units-load", false,
m->timestamps[MANAGER_TIMESTAMP_UNITS_LOAD].realtime ?: now(CLOCK_REALTIME),
UID_INVALID, GID_INVALID, 0444);
-
- m->honor_device_enumeration = true;
}
Manager* manager_reloading_start(Manager *m) {
manager_ready(m);
+ manager_set_switching_root(m, false);
+
return 0;
}
return 0;
}
- /* As extra safety check, let's make sure the string we get doesn't contain embedded NUL bytes. We permit one
- * trailing NUL byte in the message, but don't expect it. */
+ /* As extra safety check, let's make sure the string we get doesn't contain embedded NUL bytes.
+ * We permit one trailing NUL byte in the message, but don't expect it. */
if (n > 1 && memchr(buf, 0, n-1)) {
log_warning("Received notify message with embedded NUL bytes. Ignoring.");
return 0;
}
- /* Make sure it's NUL-terminated, then parse it to obtain the tags list */
+ /* Make sure it's NUL-terminated, then parse it to obtain the tags list. */
buf[n] = 0;
tags = strv_split_newlines(buf);
if (!tags) {
return 0;
}
- /* possibly a barrier fd, let's see */
+ /* Possibly a barrier fd, let's see. */
if (manager_process_barrier_fd(tags, fds))
return 0;
if (!array_copy)
log_oom();
}
- /* And now invoke the per-unit callbacks. Note that manager_invoke_notify_message() will handle duplicate units
- * make sure we only invoke each unit's handler once. */
+ /* And now invoke the per-unit callbacks. Note that manager_invoke_notify_message() will handle
+ * duplicate units make sure we only invoke each unit's handler once. */
if (u1) {
manager_invoke_notify_message(m, u1, ucred, tags, fds);
found = true;
assert(source);
assert(m);
- /* First we call waitid() for a PID and do not reap the zombie. That way we can still access /proc/$PID for it
- * while it is a zombie. */
+ /* First we call waitid() for a PID and do not reap the zombie. That way we can still access
+ * /proc/$PID for it while it is a zombie. */
if (waitid(P_ALL, 0, &si, WEXITED|WNOHANG|WNOWAIT) < 0) {
assert(m);
assert(m->idle_pipe[2] == fd);
- /* There's at least one Type=idle child that just gave up on us waiting for the boot process to complete. Let's
- * now turn off any further console output if there's at least one service that needs console access, so that
- * from now on our own output should not spill into that service's output anymore. After all, we support
- * Type=idle only to beautify console output and it generally is set on services that want to own the console
- * exclusively without our interference. */
+ /* There's at least one Type=idle child that just gave up on us waiting for the boot process to
+ * complete. Let's now turn off any further console output if there's at least one service that needs
+ * console access, so that from now on our own output should not spill into that service's output
+ * anymore. After all, we support Type=idle only to beautify console output and it generally is set
+ * on services that want to own the console exclusively without our interference. */
m->no_console_output = m->n_on_console > 0;
- /* Acknowledge the child's request, and let all all other children know too that they shouldn't wait any longer
- * by closing the pipes towards them, which is what they are waiting for. */
+ /* Acknowledge the child's request, and let all all other children know too that they shouldn't wait
+ * any longer by closing the pipes towards them, which is what they are waiting for. */
manager_close_idle_pipe(m);
return 0;
if (r < 0)
return r;
- /* Permit addressing units by invocation ID: if the passed bus path is suffixed by a 128bit ID then we use it
- * as invocation ID. */
+ /* Permit addressing units by invocation ID: if the passed bus path is suffixed by a 128bit ID then
+ * we use it as invocation ID. */
r = sd_id128_from_string(n, &invocation_id);
if (r >= 0) {
u = hashmap_get(m->units_by_invocation_id, &invocation_id);
assert(m->n_reloading > 0);
m->n_reloading--;
- /* On manager reloading, device tag data should exists, thus, we should honor the results of device
- * enumeration. The flag should be always set correctly by the serialized data, but it may fail. So,
- * let's always set the flag here for safety. */
- m->honor_device_enumeration = true;
-
manager_ready(m);
m->send_reloading_done = true;
void manager_recheck_dbus(Manager *m) {
assert(m);
- /* Connects to the bus if the dbus service and socket are running. If we are running in user mode this is all
- * it does. In system mode we'll also connect to the system bus (which will most likely just reuse the
- * connection of the API bus). That's because the system bus after all runs as service of the system instance,
- * while in the user instance we can assume it's already there. */
+ /* Connects to the bus if the dbus service and socket are running. If we are running in user mode
+ * this is all it does. In system mode we'll also connect to the system bus (which will most likely
+ * just reuse the connection of the API bus). That's because the system bus after all runs as service
+ * of the system instance, while in the user instance we can assume it's already there. */
if (MANAGER_IS_RELOADING(m))
return; /* don't check while we are reloading… */
if (MANAGER_IS_RELOADING(m))
return;
- /* The journal is fully and entirely up? If so, let's permit logging to it, if that's configured. If the
- * journal is down, don't ever log to it, otherwise we might end up deadlocking ourselves as we might trigger
- * an activation ourselves we can't fulfill. */
+ /* The journal is fully and entirely up? If so, let's permit logging to it, if that's configured. If
+ * the journal is down, don't ever log to it, otherwise we might end up deadlocking ourselves as we
+ * might trigger an activation ourselves we can't fulfill. */
log_set_prohibit_ipc(!manager_journal_is_running(m));
log_open();
}
assert(uid_is_valid(uid));
assert(_clean_ipc);
- /* A generic implementation, covering both manager_unref_uid() and manager_unref_gid(), under the assumption
- * that uid_t and gid_t are actually defined the same way, with the same validity rules.
+ /* A generic implementation, covering both manager_unref_uid() and manager_unref_gid(), under the
+ * assumption that uid_t and gid_t are actually defined the same way, with the same validity rules.
*
- * We store a hashmap where the key is the UID/GID and the value is a 32bit reference counter, whose highest
- * bit is used as flag for marking UIDs/GIDs whose IPC objects to remove when the last reference to the UID/GID
- * is dropped. The flag is set to on, once at least one reference from a unit where RemoveIPC= is set is added
- * on a UID/GID. It is reset when the UID's/GID's reference counter drops to 0 again. */
+ * We store a hashmap where the key is the UID/GID and the value is a 32bit reference counter, whose
+ * highest bit is used as flag for marking UIDs/GIDs whose IPC objects to remove when the last
+ * reference to the UID/GID is dropped. The flag is set to on, once at least one reference from a
+ * unit where RemoveIPC= is set is added on a UID/GID. It is reset when the UID's/GID's reference
+ * counter drops to 0 again. */
assert_cc(sizeof(uid_t) == sizeof(gid_t));
assert_cc(UID_INVALID == (uid_t) GID_INVALID);
assert(uid_refs);
assert(uid_is_valid(uid));
- /* A generic implementation, covering both manager_ref_uid() and manager_ref_gid(), under the assumption
- * that uid_t and gid_t are actually defined the same way, with the same validity rules. */
+ /* A generic implementation, covering both manager_ref_uid() and manager_ref_gid(), under the
+ * assumption that uid_t and gid_t are actually defined the same way, with the same validity
+ * rules. */
assert_cc(sizeof(uid_t) == sizeof(gid_t));
assert_cc(UID_INVALID == (uid_t) GID_INVALID);
assert_se(source);
assert_se(m);
- /* Invoked whenever a child process succeeded resolving its user/group to use and sent us the resulting UID/GID
- * in a datagram. We parse the datagram here and pass it off to the unit, so that it can add a reference to the
- * UID/GID so that it can destroy the UID/GID's IPC objects when the reference counter drops to 0. */
+ /* Invoked whenever a child process succeeded resolving its user/group to use and sent us the
+ * resulting UID/GID in a datagram. We parse the datagram here and pass it off to the unit, so that
+ * it can add a reference to the UID/GID so that it can destroy the UID/GID's IPC objects when the
+ * reference counter drops to 0. */
l = recv(fd, &buffer, sizeof(buffer), MSG_DONTWAIT);
if (l < 0) {