mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
core: reorder systemd arguments on reexec
When reexecuting system let's put our arguments carrying deserialization info first followed by any existing arguments to make sure they get parsed in case we get weird stuff from the kernel cmdline (like --). See: https://github.com/systemd/systemd/issues/28184 (cherry picked from commit 06afda6b38d5d730fca3c65449096425933272bc) (cherry picked from commit 884ab38057dca70b8779c85884f4646057e80921)
This commit is contained in:
parent
6ec548485d
commit
163be31d38
@ -1815,13 +1815,17 @@ static int do_reexecute(
|
||||
xsprintf(sfd, "--deserialize=%i", fileno(arg_serialization));
|
||||
|
||||
i = 1; /* Leave args[0] empty for now. */
|
||||
filter_args(args, &i, argv, argc);
|
||||
|
||||
/* Put our stuff first to make sure it always gets parsed in case
|
||||
* we get weird stuff from the kernel cmdline (like --) */
|
||||
if (switch_root_dir)
|
||||
args[i++] = "--switched-root";
|
||||
|
||||
args[i++] = arg_system ? "--system" : "--user";
|
||||
args[i++] = sfd;
|
||||
|
||||
filter_args(args, &i, argv, argc);
|
||||
|
||||
args[i++] = NULL;
|
||||
|
||||
assert(i <= args_size);
|
||||
|
@ -8,6 +8,11 @@ RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}
|
||||
TEST_REQUIRE_INSTALL_TESTS=0
|
||||
TEST_SUPPORTING_SERVICES_SHOULD_BE_MASKED=0
|
||||
|
||||
# Check if we can correctly deserialize if the kernel cmdline contains "weird" stuff
|
||||
# like an invalid argument, "end of arguments" separator, or a sysvinit argument (-z)
|
||||
# See: https://github.com/systemd/systemd/issues/28184
|
||||
KERNEL_APPEND="foo -- -z bar --- baz $KERNEL_APPEND"
|
||||
|
||||
# shellcheck source=test/test-functions
|
||||
. "${TEST_BASE_DIR:?}/test-functions"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user