1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-03 01:17:45 +03:00

Merge pull request #26328 from yuwata/udev-worker-set-process-name

udev: set worker process name
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-02-08 08:57:05 +01:00 committed by GitHub
commit ef9962212a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 9 additions and 30 deletions

View File

@ -27,7 +27,6 @@
#include "path-util.h" #include "path-util.h"
#include "proc-cmdline.h" #include "proc-cmdline.h"
#include "process-util.h" #include "process-util.h"
#include "rlimit-util.h"
#include "signal-util.h" #include "signal-util.h"
#include "socket-util.h" #include "socket-util.h"
#include "special.h" #include "special.h"
@ -346,7 +345,7 @@ static int run(int argc, char *argv[]) {
pipe(progress_pipe) < 0) pipe(progress_pipe) < 0)
return log_error_errno(errno, "pipe(): %m"); return log_error_errno(errno, "pipe(): %m");
r = safe_fork("(fsck)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); r = safe_fork("(fsck)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE, &pid);
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) { if (r == 0) {
@ -395,8 +394,6 @@ static int run(int argc, char *argv[]) {
cmdline[i++] = device; cmdline[i++] = device;
cmdline[i++] = NULL; cmdline[i++] = NULL;
(void) rlimit_nofile_safe();
execv(cmdline[0], (char**) cmdline); execv(cmdline[0], (char**) cmdline);
_exit(FSCK_OPERATIONAL_ERROR); _exit(FSCK_OPERATIONAL_ERROR);
} }

View File

@ -16,7 +16,6 @@
#include "process-util.h" #include "process-util.h"
#include "pull-common.h" #include "pull-common.h"
#include "pull-job.h" #include "pull-job.h"
#include "rlimit-util.h"
#include "rm-rf.h" #include "rm-rf.h"
#include "signal-util.h" #include "signal-util.h"
#include "siphash24.h" #include "siphash24.h"
@ -415,7 +414,7 @@ static int verify_gpg(
gpg_home_created = true; gpg_home_created = true;
r = safe_fork("(gpg)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); r = safe_fork("(gpg)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE, &pid);
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) { if (r == 0) {
@ -446,8 +445,6 @@ static int verify_gpg(
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
(void) rlimit_nofile_safe();
cmd[k++] = strjoina("--homedir=", gpg_home); cmd[k++] = strjoina("--homedir=", gpg_home);
/* We add the user keyring only to the command line arguments, if it's around since gpg fails /* We add the user keyring only to the command line arguments, if it's around since gpg fails

View File

@ -85,7 +85,7 @@ static int spawn_child(const char* child, char** argv) {
if (pipe(fd) < 0) if (pipe(fd) < 0)
return log_error_errno(errno, "Failed to create pager pipe: %m"); return log_error_errno(errno, "Failed to create pager pipe: %m");
r = safe_fork("(remote)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &child_pid); r = safe_fork("(remote)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE, &child_pid);
if (r < 0) { if (r < 0) {
safe_close_pair(fd); safe_close_pair(fd);
return r; return r;
@ -101,8 +101,6 @@ static int spawn_child(const char* child, char** argv) {
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
(void) rlimit_nofile_safe();
execvp(child, argv); execvp(child, argv);
log_error_errno(errno, "Failed to exec child %s: %m", child); log_error_errno(errno, "Failed to exec child %s: %m", child);
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);

View File

@ -22,7 +22,6 @@
#include "memory-util.h" #include "memory-util.h"
#include "path-util.h" #include "path-util.h"
#include "process-util.h" #include "process-util.h"
#include "rlimit-util.h"
#include "signal-util.h" #include "signal-util.h"
#include "stdio-util.h" #include "stdio-util.h"
#include "string-util.h" #include "string-util.h"
@ -995,7 +994,7 @@ int bus_socket_exec(sd_bus *b) {
if (r < 0) if (r < 0)
return -errno; return -errno;
r = safe_fork_full("(sd-busexec)", s+1, 1, FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS, &b->busexec_pid); r = safe_fork_full("(sd-busexec)", s+1, 1, FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_RLIMIT_NOFILE_SAFE, &b->busexec_pid);
if (r < 0) { if (r < 0) {
safe_close_pair(s); safe_close_pair(s);
return r; return r;
@ -1008,8 +1007,6 @@ int bus_socket_exec(sd_bus *b) {
if (r < 0) if (r < 0)
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
(void) rlimit_nofile_safe();
if (b->exec_argv) if (b->exec_argv)
execvp(b->exec_path, b->exec_argv); execvp(b->exec_path, b->exec_argv);
else else

View File

@ -12,7 +12,6 @@
#include "mkdir.h" #include "mkdir.h"
#include "nspawn-setuid.h" #include "nspawn-setuid.h"
#include "process-util.h" #include "process-util.h"
#include "rlimit-util.h"
#include "signal-util.h" #include "signal-util.h"
#include "string-util.h" #include "string-util.h"
#include "strv.h" #include "strv.h"
@ -29,7 +28,7 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
if (pipe2(pipe_fds, O_CLOEXEC) < 0) if (pipe2(pipe_fds, O_CLOEXEC) < 0)
return log_error_errno(errno, "Failed to allocate pipe: %m"); return log_error_errno(errno, "Failed to allocate pipe: %m");
r = safe_fork("(getent)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); r = safe_fork("(getent)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE, &pid);
if (r < 0) { if (r < 0) {
safe_close_pair(pipe_fds); safe_close_pair(pipe_fds);
return r; return r;
@ -44,8 +43,6 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
(void) close_all_fds(NULL, 0); (void) close_all_fds(NULL, 0);
(void) rlimit_nofile_safe();
execle("/usr/bin/getent", "getent", database, key, NULL, &empty_env); execle("/usr/bin/getent", "getent", database, key, NULL, &empty_env);
execle("/bin/getent", "getent", database, key, NULL, &empty_env); execle("/bin/getent", "getent", database, key, NULL, &empty_env);
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);

View File

@ -20,7 +20,6 @@
#include "missing_syscall.h" #include "missing_syscall.h"
#include "path-util.h" #include "path-util.h"
#include "process-util.h" #include "process-util.h"
#include "rlimit-util.h"
#include "serialize.h" #include "serialize.h"
#include "set.h" #include "set.h"
#include "signal-util.h" #include "signal-util.h"
@ -43,7 +42,7 @@ static int do_spawn(const char *path, char *argv[], int stdout_fd, pid_t *pid, b
return 0; return 0;
} }
r = safe_fork("(direxec)", FORK_DEATHSIG|FORK_LOG, &_pid); r = safe_fork("(direxec)", FORK_DEATHSIG|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE, &_pid);
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) { if (r == 0) {
@ -55,8 +54,6 @@ static int do_spawn(const char *path, char *argv[], int stdout_fd, pid_t *pid, b
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
(void) rlimit_nofile_safe();
if (set_systemd_exec_pid) { if (set_systemd_exec_pid) {
r = setenv_systemd_exec_pid(false); r = setenv_systemd_exec_pid(false);
if (r < 0) if (r < 0)
@ -493,7 +490,7 @@ int fork_agent(const char *name, const int except[], size_t n_except, pid_t *ret
r = safe_fork_full(name, r = safe_fork_full(name,
except, except,
n_except, n_except,
FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_REOPEN_LOG, FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_REOPEN_LOG|FORK_RLIMIT_NOFILE_SAFE,
ret_pid); ret_pid);
if (r < 0) if (r < 0)
return r; return r;
@ -537,8 +534,6 @@ int fork_agent(const char *name, const int except[], size_t n_except, pid_t *ret
} }
} }
(void) rlimit_nofile_safe();
/* Count arguments */ /* Count arguments */
va_start(ap, path); va_start(ap, path);
for (n = 0; va_arg(ap, char*); n++) for (n = 0; va_arg(ap, char*); n++)

View File

@ -23,7 +23,6 @@
#include "parse-util.h" #include "parse-util.h"
#include "path-util.h" #include "path-util.h"
#include "process-util.h" #include "process-util.h"
#include "rlimit-util.h"
#include "signal-util.h" #include "signal-util.h"
#include "stdio-util.h" #include "stdio-util.h"
#include "string-util.h" #include "string-util.h"
@ -811,7 +810,7 @@ int udev_event_spawn(
log_device_debug(event->dev, "Starting '%s'", cmd); log_device_debug(event->dev, "Starting '%s'", cmd);
r = safe_fork("(spawn)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); r = safe_fork("(spawn)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE, &pid);
if (r < 0) if (r < 0)
return log_device_error_errno(event->dev, r, return log_device_error_errno(event->dev, r,
"Failed to fork() to execute command '%s': %m", cmd); "Failed to fork() to execute command '%s': %m", cmd);
@ -820,7 +819,6 @@ int udev_event_spawn(
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
(void) close_all_fds(NULL, 0); (void) close_all_fds(NULL, 0);
(void) rlimit_nofile_safe();
DEVICE_TRACE_POINT(spawn_exec, event->dev, cmd); DEVICE_TRACE_POINT(spawn_exec, event->dev, cmd);

View File

@ -807,7 +807,7 @@ static int worker_spawn(Manager *manager, Event *event) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Worker: Failed to enable receiving of device: %m"); return log_error_errno(r, "Worker: Failed to enable receiving of device: %m");
r = safe_fork(NULL, FORK_DEATHSIG, &pid); r = safe_fork("(udev-worker)", FORK_DEATHSIG, &pid);
if (r < 0) { if (r < 0) {
event->state = EVENT_QUEUED; event->state = EVENT_QUEUED;
return log_error_errno(r, "Failed to fork() worker: %m"); return log_error_errno(r, "Failed to fork() worker: %m");