mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
exec-invoke: Move KSM logic up
Let's move it up to be located together with other resource logic instead of having it stuffed inbetween the sandboxing logic.
This commit is contained in:
@@ -4864,6 +4864,19 @@ int exec_invoke(
|
||||
}
|
||||
}
|
||||
|
||||
if (context->memory_ksm >= 0)
|
||||
if (prctl(PR_SET_MEMORY_MERGE, context->memory_ksm, 0, 0, 0) < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(errno))
|
||||
log_exec_debug_errno(context,
|
||||
params,
|
||||
errno,
|
||||
"KSM support not available, ignoring.");
|
||||
else {
|
||||
*exit_status = EXIT_KSM;
|
||||
return log_exec_error_errno(context, params, errno, "Failed to set KSM: %m");
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_UTMP
|
||||
if (context->utmp_id) {
|
||||
_cleanup_free_ char *username_alloc = NULL;
|
||||
@@ -5247,19 +5260,6 @@ int exec_invoke(
|
||||
return r;
|
||||
}
|
||||
|
||||
if (context->memory_ksm >= 0)
|
||||
if (prctl(PR_SET_MEMORY_MERGE, context->memory_ksm, 0, 0, 0) < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(errno))
|
||||
log_exec_debug_errno(context,
|
||||
params,
|
||||
errno,
|
||||
"KSM support not available, ignoring.");
|
||||
else {
|
||||
*exit_status = EXIT_KSM;
|
||||
return log_exec_error_errno(context, params, errno, "Failed to set KSM: %m");
|
||||
}
|
||||
}
|
||||
|
||||
/* Drop groups as early as possible.
|
||||
* This needs to be done after PrivateDevices=yes setup as device nodes should be owned by the host's root.
|
||||
* For non-root in a userns, devices will be owned by the user/group before the group change, and nobody. */
|
||||
|
||||
Reference in New Issue
Block a user