Merge pull request #30165 from YHNdnzj/executor-open-fix
core,analyze: several fixlets
This commit is contained in:
@@ -92,7 +92,7 @@ static int verify_conditions(char **lines, RuntimeScope scope, const char *unit,
|
||||
assert_se(set_unit_path(var) >= 0);
|
||||
}
|
||||
|
||||
r = manager_new(scope, MANAGER_TEST_RUN_MINIMAL, &m);
|
||||
r = manager_new(scope, MANAGER_TEST_RUN_MINIMAL|MANAGER_TEST_DONT_OPEN_EXECUTOR, &m);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to initialize manager: %m");
|
||||
|
||||
|
||||
@@ -2690,6 +2690,7 @@ static int offline_security_checks(
|
||||
MANAGER_TEST_RUN_MINIMAL |
|
||||
MANAGER_TEST_RUN_ENV_GENERATORS |
|
||||
MANAGER_TEST_RUN_IGNORE_DEPENDENCIES |
|
||||
MANAGER_TEST_DONT_OPEN_EXECUTOR |
|
||||
run_generators * MANAGER_TEST_RUN_GENERATORS;
|
||||
|
||||
_cleanup_(manager_freep) Manager *m = NULL;
|
||||
|
||||
@@ -168,12 +168,12 @@ static int verify_executables(Unit *u, const char *root) {
|
||||
RET_GATHER(r, verify_executable(u, exec, root));
|
||||
|
||||
if (u->type == UNIT_SERVICE)
|
||||
for (unsigned i = 0; i < ELEMENTSOF(SERVICE(u)->exec_command); i++)
|
||||
RET_GATHER(r, verify_executable(u, SERVICE(u)->exec_command[i], root));
|
||||
FOREACH_ARRAY(i, SERVICE(u)->exec_command, ELEMENTSOF(SERVICE(u)->exec_command))
|
||||
RET_GATHER(r, verify_executable(u, *i, root));
|
||||
|
||||
if (u->type == UNIT_SOCKET)
|
||||
for (unsigned i = 0; i < ELEMENTSOF(SOCKET(u)->exec_command); i++)
|
||||
RET_GATHER(r, verify_executable(u, SOCKET(u)->exec_command[i], root));
|
||||
FOREACH_ARRAY(i, SOCKET(u)->exec_command, ELEMENTSOF(SOCKET(u)->exec_command))
|
||||
RET_GATHER(r, verify_executable(u, *i, root));
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ static int verify_unit(Unit *u, bool check_man, const char *root) {
|
||||
return r;
|
||||
}
|
||||
|
||||
static void set_destroy_ignore_pointer_max(Set** s) {
|
||||
static void set_destroy_ignore_pointer_max(Set **s) {
|
||||
if (*s == POINTER_MAX)
|
||||
return;
|
||||
set_free_free(*s);
|
||||
@@ -242,6 +242,7 @@ int verify_units(
|
||||
const ManagerTestRunFlags flags =
|
||||
MANAGER_TEST_RUN_MINIMAL |
|
||||
MANAGER_TEST_RUN_ENV_GENERATORS |
|
||||
MANAGER_TEST_DONT_OPEN_EXECUTOR |
|
||||
(recursive_errors == RECURSIVE_ERRORS_NO) * MANAGER_TEST_RUN_IGNORE_DEPENDENCIES |
|
||||
run_generators * MANAGER_TEST_RUN_GENERATORS;
|
||||
|
||||
@@ -302,8 +303,8 @@ int verify_units(
|
||||
count++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
RET_GATHER(r, verify_unit(units[i], check_man, root));
|
||||
FOREACH_ARRAY(i, units, count)
|
||||
RET_GATHER(r, verify_unit(*i, check_man, root));
|
||||
|
||||
if (s == POINTER_MAX)
|
||||
return log_oom();
|
||||
|
||||
+12
-12
@@ -847,12 +847,12 @@ static int compare_job_priority(const void *a, const void *b) {
|
||||
return unit_compare_priority(x->unit, y->unit);
|
||||
}
|
||||
|
||||
int manager_new(RuntimeScope runtime_scope, ManagerTestRunFlags test_run_flags, Manager **_m) {
|
||||
int manager_new(RuntimeScope runtime_scope, ManagerTestRunFlags test_run_flags, Manager **ret) {
|
||||
_cleanup_(manager_freep) Manager *m = NULL;
|
||||
int r;
|
||||
|
||||
assert(_m);
|
||||
assert(IN_SET(runtime_scope, RUNTIME_SCOPE_SYSTEM, RUNTIME_SCOPE_USER));
|
||||
assert(ret);
|
||||
|
||||
m = new(Manager, 1);
|
||||
if (!m)
|
||||
@@ -1030,31 +1030,31 @@ int manager_new(RuntimeScope runtime_scope, ManagerTestRunFlags test_run_flags,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
self_dir_fd = open_parent(self_exe, O_CLOEXEC|O_DIRECTORY, 0);
|
||||
self_dir_fd = open_parent(self_exe, O_CLOEXEC|O_PATH|O_DIRECTORY, 0);
|
||||
if (self_dir_fd < 0)
|
||||
return -errno;
|
||||
return self_dir_fd;
|
||||
|
||||
m->executor_fd = openat(self_dir_fd, "systemd-executor", O_CLOEXEC|O_PATH);
|
||||
if (m->executor_fd < 0 && errno == ENOENT)
|
||||
m->executor_fd = openat(AT_FDCWD, "systemd-executor", O_CLOEXEC|O_PATH);
|
||||
if (m->executor_fd < 0 && errno == ENOENT) {
|
||||
m->executor_fd = open(SYSTEMD_EXECUTOR_BINARY_PATH, O_CLOEXEC|O_PATH);
|
||||
m->executor_fd = RET_NERRNO(openat(self_dir_fd, "systemd-executor", O_CLOEXEC|O_PATH));
|
||||
if (m->executor_fd == -ENOENT)
|
||||
m->executor_fd = RET_NERRNO(openat(AT_FDCWD, "systemd-executor", O_CLOEXEC|O_PATH));
|
||||
if (m->executor_fd == -ENOENT) {
|
||||
m->executor_fd = RET_NERRNO(open(SYSTEMD_EXECUTOR_BINARY_PATH, O_CLOEXEC|O_PATH));
|
||||
level = LOG_WARNING; /* Tests should normally use local builds */
|
||||
}
|
||||
if (m->executor_fd < 0)
|
||||
return -errno;
|
||||
return m->executor_fd;
|
||||
|
||||
r = fd_get_path(m->executor_fd, &executor_path);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
log_full(level, "Using systemd-executor binary from '%s'", executor_path);
|
||||
log_full(level, "Using systemd-executor binary from '%s'.", executor_path);
|
||||
}
|
||||
|
||||
/* Note that we do not set up the notify fd here. We do that after deserialization,
|
||||
* since they might have gotten serialized across the reexec. */
|
||||
|
||||
*_m = TAKE_PTR(m);
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user