mirror of
https://github.com/AuxXxilium/eudev.git
synced 2025-01-12 23:15:03 +07:00
main: pass original environment block to shutdown binary so that it can detect container environments
This commit is contained in:
parent
1d7f3f5cc8
commit
d18f337c3f
21
src/main.c
21
src/main.c
@ -1648,19 +1648,16 @@ finish:
|
|||||||
fdset_free(fds);
|
fdset_free(fds);
|
||||||
|
|
||||||
if (shutdown_verb) {
|
if (shutdown_verb) {
|
||||||
char e[32];
|
|
||||||
|
|
||||||
const char * command_line[] = {
|
const char * command_line[] = {
|
||||||
SYSTEMD_SHUTDOWN_BINARY_PATH,
|
SYSTEMD_SHUTDOWN_BINARY_PATH,
|
||||||
shutdown_verb,
|
shutdown_verb,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
const char * env_block[] = {
|
char **env_block;
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
if (arm_reboot_watchdog && arg_shutdown_watchdog > 0) {
|
if (arm_reboot_watchdog && arg_shutdown_watchdog > 0) {
|
||||||
|
char e[32];
|
||||||
|
|
||||||
/* If we reboot let's set the shutdown
|
/* If we reboot let's set the shutdown
|
||||||
* watchdog and tell the shutdown binary to
|
* watchdog and tell the shutdown binary to
|
||||||
* repeatedly ping it */
|
* repeatedly ping it */
|
||||||
@ -1670,11 +1667,15 @@ finish:
|
|||||||
/* Tell the binary how often to ping */
|
/* Tell the binary how often to ping */
|
||||||
snprintf(e, sizeof(e), "WATCHDOG_USEC=%llu", (unsigned long long) arg_shutdown_watchdog);
|
snprintf(e, sizeof(e), "WATCHDOG_USEC=%llu", (unsigned long long) arg_shutdown_watchdog);
|
||||||
char_array_0(e);
|
char_array_0(e);
|
||||||
env_block[0] = e;
|
|
||||||
} else
|
|
||||||
watchdog_close(true);
|
|
||||||
|
|
||||||
execve(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line, (char**) env_block);
|
env_block = strv_append(environ, e);
|
||||||
|
} else {
|
||||||
|
env_block = strv_copy(environ);
|
||||||
|
watchdog_close(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
execve(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line, env_block);
|
||||||
|
free(env_block);
|
||||||
log_error("Failed to execute shutdown binary, freezing: %m");
|
log_error("Failed to execute shutdown binary, freezing: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user