mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
ask-passwd: slightly optimize handling arguments
It is not necessary to copy arguments for each console.
This commit is contained in:
parent
8c69fe79df
commit
6e79d2b5a4
@ -693,8 +693,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
* and its own controlling terminal. If one of the tasks does handle a password, the remaining tasks will be
|
* and its own controlling terminal. If one of the tasks does handle a password, the remaining tasks will be
|
||||||
* terminated.
|
* terminated.
|
||||||
*/
|
*/
|
||||||
static int ask_on_this_console(const char *tty, pid_t *ret_pid, char *argv[]) {
|
static int ask_on_this_console(const char *tty, pid_t *ret_pid, char **arguments) {
|
||||||
_cleanup_strv_free_ char **arguments = NULL;
|
|
||||||
static const struct sigaction sigchld = {
|
static const struct sigaction sigchld = {
|
||||||
.sa_handler = nop_signal_handler,
|
.sa_handler = nop_signal_handler,
|
||||||
.sa_flags = SA_NOCLDSTOP | SA_RESTART,
|
.sa_flags = SA_NOCLDSTOP | SA_RESTART,
|
||||||
@ -705,10 +704,6 @@ static int ask_on_this_console(const char *tty, pid_t *ret_pid, char *argv[]) {
|
|||||||
};
|
};
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
arguments = strv_copy(argv);
|
|
||||||
if (!arguments)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
assert_se(sigaction(SIGCHLD, &sigchld, NULL) >= 0);
|
assert_se(sigaction(SIGCHLD, &sigchld, NULL) >= 0);
|
||||||
assert_se(sigaction(SIGHUP, &sighup, NULL) >= 0);
|
assert_se(sigaction(SIGHUP, &sighup, NULL) >= 0);
|
||||||
assert_se(sigprocmask_many(SIG_UNBLOCK, NULL, SIGHUP, SIGCHLD, -1) >= 0);
|
assert_se(sigprocmask_many(SIG_UNBLOCK, NULL, SIGHUP, SIGCHLD, -1) >= 0);
|
||||||
@ -797,7 +792,7 @@ static void terminate_agents(Set *pids) {
|
|||||||
|
|
||||||
static int ask_on_consoles(char *argv[]) {
|
static int ask_on_consoles(char *argv[]) {
|
||||||
_cleanup_set_free_ Set *pids = NULL;
|
_cleanup_set_free_ Set *pids = NULL;
|
||||||
_cleanup_strv_free_ char **consoles = NULL;
|
_cleanup_strv_free_ char **consoles = NULL, **arguments = NULL;
|
||||||
siginfo_t status = {};
|
siginfo_t status = {};
|
||||||
char **tty;
|
char **tty;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@ -811,9 +806,13 @@ static int ask_on_consoles(char *argv[]) {
|
|||||||
if (!pids)
|
if (!pids)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
arguments = strv_copy(argv);
|
||||||
|
if (!arguments)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
/* Start an agent on each console. */
|
/* Start an agent on each console. */
|
||||||
STRV_FOREACH(tty, consoles) {
|
STRV_FOREACH(tty, consoles) {
|
||||||
r = ask_on_this_console(*tty, &pid, argv);
|
r = ask_on_this_console(*tty, &pid, arguments);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user