mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
analyze: don't connect to bus from analyze test run (#36719)
This thing should not be "live", hence don't try to connect to the bus, or bind the private bus socket. Fixes: #36540
This commit is contained in:
commit
e707d0459c
@ -161,6 +161,9 @@ static int manager_varlink_send_managed_oom_initial(Manager *m) {
|
||||
if (!MANAGER_IS_USER(m))
|
||||
return 0;
|
||||
|
||||
if (MANAGER_IS_TEST_RUN(m))
|
||||
return 0;
|
||||
|
||||
assert(m->managed_oom_varlink);
|
||||
|
||||
r = build_managed_oom_cgroups_json(m, &v);
|
||||
@ -207,6 +210,9 @@ static int manager_varlink_managed_oom_connect(Manager *m) {
|
||||
if (!MANAGER_IS_USER(m))
|
||||
return -EINVAL;
|
||||
|
||||
if (MANAGER_IS_TEST_RUN(m))
|
||||
return 0;
|
||||
|
||||
r = sd_varlink_connect_address(&link, VARLINK_ADDR_PATH_MANAGED_OOM_USER);
|
||||
if (r == -ENOENT)
|
||||
return 0;
|
||||
@ -246,6 +252,9 @@ int manager_varlink_send_managed_oom_update(Unit *u) {
|
||||
if (!UNIT_VTABLE(u)->can_set_managed_oom || !u->manager)
|
||||
return 0;
|
||||
|
||||
if (MANAGER_IS_TEST_RUN(u->manager))
|
||||
return 0;
|
||||
|
||||
crt = unit_get_cgroup_runtime(u);
|
||||
if (!crt || !crt->cgroup_path)
|
||||
return 0;
|
||||
@ -633,7 +642,7 @@ static int manager_varlink_init_system(Manager *m) {
|
||||
bool fresh = r > 0;
|
||||
|
||||
if (!MANAGER_IS_TEST_RUN(m)) {
|
||||
(void) mkdir_p_label("/run/systemd/userdb", 0755);
|
||||
(void) mkdir_label("/run/systemd/userdb", 0755);
|
||||
|
||||
FOREACH_STRING(address, "/run/systemd/userdb/io.systemd.DynamicUser", VARLINK_ADDR_PATH_MANAGED_OOM_SYSTEM) {
|
||||
if (!fresh) {
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "log.h"
|
||||
#include "mkdir-label.h"
|
||||
#include "process-util.h"
|
||||
#include "selinux-access.h"
|
||||
#include "serialize.h"
|
||||
@ -978,7 +977,6 @@ int bus_init_private(Manager *m) {
|
||||
return log_error_errno(r, "Failed set socket path for private bus: %m");
|
||||
sa_len = r;
|
||||
|
||||
(void) mkdir_parents_label(sa.un.sun_path, 0755);
|
||||
(void) sockaddr_un_unlink(&sa.un);
|
||||
|
||||
fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
|
||||
|
@ -932,7 +932,7 @@ static int setup_credentials_internal(
|
||||
|
||||
r = path_is_mount_point(final);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return log_debug_errno(r, "Failed to determine if '%s' is a mountpoint: %m", final);
|
||||
final_mounted = r > 0;
|
||||
|
||||
if (final_mounted) {
|
||||
@ -1125,7 +1125,7 @@ int exec_setup_credentials(
|
||||
FOREACH_STRING(i, t, u) {
|
||||
r = mkdir_label(i, 0700);
|
||||
if (r < 0 && r != -EEXIST)
|
||||
return r;
|
||||
return log_debug_errno(r, "Failed to make directory '%s': %m", i);
|
||||
}
|
||||
|
||||
r = setup_credentials_internal(
|
||||
|
@ -336,7 +336,7 @@ static int manager_check_ask_password(Manager *m) {
|
||||
if (inotify_fd < 0)
|
||||
return log_error_errno(errno, "Failed to create inotify object: %m");
|
||||
|
||||
(void) mkdir_p_label("/run/systemd/ask-password", 0755);
|
||||
(void) mkdir_label("/run/systemd/ask-password", 0755);
|
||||
r = inotify_add_watch_and_warn(inotify_fd, "/run/systemd/ask-password", IN_CLOSE_WRITE|IN_DELETE|IN_MOVED_TO|IN_ONLYDIR);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -1047,7 +1047,7 @@ int manager_new(RuntimeScope runtime_scope, ManagerTestRunFlags test_run_flags,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = mkdir_p_label(units_path, 0755);
|
||||
r = mkdir_label(units_path, 0755);
|
||||
}
|
||||
if (r < 0 && r != -EEXIST)
|
||||
return r;
|
||||
@ -1105,7 +1105,6 @@ static int manager_setup_notify(Manager *m) {
|
||||
m->notify_socket);
|
||||
sa_len = r;
|
||||
|
||||
(void) mkdir_parents_label(m->notify_socket, 0755);
|
||||
(void) sockaddr_un_unlink(&sa.un);
|
||||
|
||||
r = mac_selinux_bind(fd, &sa.sa, sa_len);
|
||||
@ -1969,6 +1968,9 @@ static bool manager_dbus_is_running(Manager *m, bool deserialized) {
|
||||
static void manager_setup_bus(Manager *m) {
|
||||
assert(m);
|
||||
|
||||
if (MANAGER_IS_TEST_RUN(m))
|
||||
return;
|
||||
|
||||
/* Let's set up our private bus connection now, unconditionally */
|
||||
(void) bus_init_private(m);
|
||||
|
||||
@ -2045,11 +2047,31 @@ void manager_reloading_stopp(Manager **m) {
|
||||
}
|
||||
}
|
||||
|
||||
static int manager_make_runtime_dir(Manager *m) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
||||
_cleanup_free_ char *d = path_join(m->prefix[EXEC_DIRECTORY_RUNTIME], "systemd");
|
||||
if (!d)
|
||||
return log_oom();
|
||||
|
||||
r = mkdir_label(d, 0755);
|
||||
if (r < 0 && r != -EEXIST)
|
||||
return log_error_errno(r, "Failed to create directory '%s/': %m", d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int manager_startup(Manager *m, FILE *serialization, FDSet *fds, const char *root) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
||||
r = manager_make_runtime_dir(m);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* If we are running in test mode, we still want to run the generators,
|
||||
* but we should not touch the real generator directories. */
|
||||
r = lookup_paths_init_or_warn(&m->lookup_paths, m->runtime_scope,
|
||||
|
@ -1420,9 +1420,10 @@ static void run_tests(RuntimeScope scope, char **patterns) {
|
||||
start = now(CLOCK_MONOTONIC);
|
||||
|
||||
for (const test_entry *test = tests; test->f; test++)
|
||||
if (strv_fnmatch_or_empty(patterns, test->name, FNM_NOESCAPE))
|
||||
if (strv_fnmatch_or_empty(patterns, test->name, FNM_NOESCAPE)) {
|
||||
log_info("Starting %s.", test->name);
|
||||
test->f(m);
|
||||
else
|
||||
} else
|
||||
log_info("Skipping %s because it does not match any pattern.", test->name);
|
||||
|
||||
finish = now(CLOCK_MONOTONIC);
|
||||
|
Loading…
x
Reference in New Issue
Block a user