From 4ccde410a3fc141c9ddf285f24a22dfea99e0287 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 24 Aug 2022 10:41:30 +0200 Subject: [PATCH] tree-wide: change --kill-who to --kill-whom MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit getopt allows non-ambiguous abbreviations, so backwards-compat is maintained, and people can use --kill-who (or even shorter abbreviations). English is flexible, so in common speach people would use both forms, even if "whom" is technically more correct. The advantage of using the longer form in the code is that we effectively allow both forms, so we stop punishing people who DTGCT¹, but still allow people to use the spoken form if they prefer. 1. Do the gramatically correct thing --- man/loginctl.xml | 4 ++-- man/machinectl.xml | 4 ++-- man/systemctl.xml | 4 ++-- shell-completion/bash/loginctl | 4 ++-- shell-completion/bash/machinectl | 4 ++-- shell-completion/bash/systemctl.in | 4 ++-- shell-completion/zsh/_loginctl | 2 +- shell-completion/zsh/_machinectl | 2 +- shell-completion/zsh/_systemctl.in | 2 +- src/login/loginctl.c | 22 +++++++++--------- src/machine/machinectl.c | 22 +++++++++--------- src/systemctl/systemctl-kill.c | 10 ++++---- src/systemctl/systemctl.c | 14 +++++------ src/systemctl/systemctl.h | 2 +- .../fuzz/fuzz-systemctl-parse-argv/help.input | Bin 1027 -> 1028 bytes test/units/testsuite-57-binds-to.service | 1 + test/units/testsuite-57-prop-stop-one.service | 2 +- test/units/testsuite-57-short-lived.sh | 2 +- 18 files changed, 53 insertions(+), 52 deletions(-) diff --git a/man/loginctl.xml b/man/loginctl.xml index bef3be71c9..792166300d 100644 --- a/man/loginctl.xml +++ b/man/loginctl.xml @@ -122,7 +122,7 @@ kill-session ID… Send a signal to one or more processes of the session. Use - to select which process to kill. Use to + to select which process to kill. Use to select the signal to send. If the argument is specified as empty string the signal is sent to the session invoking the command. @@ -320,7 +320,7 @@ - + When used with kill-session, choose which processes to diff --git a/man/machinectl.xml b/man/machinectl.xml index 1b39e42e38..7abe2adf73 100644 --- a/man/machinectl.xml +++ b/man/machinectl.xml @@ -279,7 +279,7 @@ Send a signal to one or more processes of the virtual machine or container. This means processes as seen by the host, not the processes inside the virtual machine or - container. Use to select which + container. Use to select which process to kill. Use to select the signal to send. @@ -682,7 +682,7 @@ - + When used with kill, choose which processes to kill. Must be one of diff --git a/man/systemctl.xml b/man/systemctl.xml index 6fd9d910d9..5c0e743d81 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -498,7 +498,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err Send a signal to one or more processes of the - unit. Use to select which + unit. Use to select which process to kill. Use to select the signal to send. @@ -2086,7 +2086,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err - + When used with kill, choose which diff --git a/shell-completion/bash/loginctl b/shell-completion/bash/loginctl index b98b019aa4..7af848fdd1 100644 --- a/shell-completion/bash/loginctl +++ b/shell-completion/bash/loginctl @@ -42,7 +42,7 @@ _loginctl () { local -A OPTS=( [STANDALONE]='--all -a --help -h --no-pager --version --no-legend --no-ask-password -l --full --value' - [ARG]='--host -H --kill-who --property -p --signal -s -M --machine + [ARG]='--host -H --kill-whom --property -p --signal -s -M --machine -n --lines -o --output -P' ) @@ -52,7 +52,7 @@ _loginctl () { _signals return ;; - --kill-who) + --kill-whom|--kill-who) comps='all leader' ;; --host|-H) diff --git a/shell-completion/bash/machinectl b/shell-completion/bash/machinectl index b37b059708..ebac999897 100644 --- a/shell-completion/bash/machinectl +++ b/shell-completion/bash/machinectl @@ -36,7 +36,7 @@ _machinectl() { local -A OPTS=( [STANDALONE]='--all -a -l --full --help -h --no-ask-password --no-legend --no-pager --version --value --mkdir --read-only --force -q --quiet' - [ARG]='--host -H --kill-who -M --machine --property -p --signal -s --uid -E --setenv -n --lines + [ARG]='--host -H --kill-whom -M --machine --property -p --signal -s --uid -E --setenv -n --lines -o --output --verify --format --max-addresses' ) @@ -64,7 +64,7 @@ _machinectl() { _signals return ;; - --kill-who) + --kill-whom|--kill-who) comps='all leader' ;; --host|-H) diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index c8ca2882c0..a3e423b845 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -128,7 +128,7 @@ _systemctl () { --help -h --no-ask-password --no-block --legend=no --no-pager --no-reload --no-wall --now --quiet -q --system --user --version --runtime --recursive -r --firmware-setup --show-types --plain --failed --value --fail --dry-run --wait' - [ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --job-mode --root + [ARG]='--host -H --kill-whom --property -p --signal -s --type -t --state --job-mode --root --preset-mode -n --lines -o --output -M --machine --message --timestamp --check-inhibitors' ) @@ -156,7 +156,7 @@ _systemctl () { comps='fail replace replace-irreversibly isolate ignore-dependencies ignore-requirements flush' ;; - --kill-who) + --kill-whom|--kill-who) comps='all control main' ;; --root) diff --git a/shell-completion/zsh/_loginctl b/shell-completion/zsh/_loginctl index 6478a52fe4..5473020e3d 100644 --- a/shell-completion/zsh/_loginctl +++ b/shell-completion/zsh/_loginctl @@ -169,7 +169,7 @@ _arguments -s \ '--version[Show package version]' \ \*{-p+,--property=}'[Show only properties by this name]:unit property' \ {-a,--all}'[Show all properties, including empty ones]' \ - '--kill-who=[Who to send signal to]:killwho:(main control all)' \ + '--kill-whom=[Whom to send signal to]:killwhom:(main control all)' \ {-s+,--signal=}'[Which signal to send]:signal:_signals' \ {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ {-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \ diff --git a/shell-completion/zsh/_machinectl b/shell-completion/zsh/_machinectl index 8f4e57f123..4b4d044ec8 100644 --- a/shell-completion/zsh/_machinectl +++ b/shell-completion/zsh/_machinectl @@ -95,7 +95,7 @@ _arguments \ {-a,--all}'[Show all properties.]' \ {-q,--quiet}'[Suppress output.]' \ {-l,--full}'[Do not ellipsize cgroup members.]' \ - '--kill-who=[Who to send signal to.]:killwho:(leader all)' \ + '--kill-whom=[Whom to send signal to.]:killwhom:(leader all)' \ {-s+,--signal=}'[Which signal to send.]:signal:_signals' \ '--read-only[Create read-only bind mount.]' \ '--mkdir[Create directory before bind mounting, if missing.]' \ diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in index 8b8c59e0d7..3d3fbdf32a 100644 --- a/shell-completion/zsh/_systemctl.in +++ b/shell-completion/zsh/_systemctl.in @@ -489,7 +489,7 @@ _arguments -s \ '--global[Enable/disable/mask default user unit files globally]' \ "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \ '--no-ask-password[Do not ask for system passwords]' \ - '--kill-who=[Who to send signal to]:killwho:(main control all)' \ + '--kill-whom=[Whom to send signal to]:killwhom:(main control all)' \ {-s+,--signal=}'[Which signal to send]:signal:_signals' \ {-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \ '--root=[Enable/disable/mask unit files in the specified root directory]:directory:_directories' \ diff --git a/src/login/loginctl.c b/src/login/loginctl.c index d00a280e66..b2c15aad81 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -43,7 +43,7 @@ static BusPrintPropertyFlags arg_print_flags = 0; static bool arg_full = false; static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; -static const char *arg_kill_who = NULL; +static const char *arg_kill_whom = NULL; static int arg_signal = SIGTERM; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static char *arg_host = NULL; @@ -1005,8 +1005,8 @@ static int kill_session(int argc, char *argv[], void *userdata) { polkit_agent_open_if_enabled(arg_transport, arg_ask_password); - if (!arg_kill_who) - arg_kill_who = "all"; + if (!arg_kill_whom) + arg_kill_whom = "all"; for (int i = 1; i < argc; i++) { @@ -1015,7 +1015,7 @@ static int kill_session(int argc, char *argv[], void *userdata) { bus_login_mgr, "KillSession", &error, NULL, - "ssi", argv[i], arg_kill_who, arg_signal); + "ssi", argv[i], arg_kill_whom, arg_signal); if (r < 0) return log_error_errno(r, "Could not kill session: %s", bus_error_message(&error, r)); } @@ -1113,8 +1113,8 @@ static int kill_user(int argc, char *argv[], void *userdata) { polkit_agent_open_if_enabled(arg_transport, arg_ask_password); - if (!arg_kill_who) - arg_kill_who = "all"; + if (!arg_kill_whom) + arg_kill_whom = "all"; for (int i = 1; i < argc; i++) { uid_t uid; @@ -1277,7 +1277,7 @@ static int help(int argc, char *argv[], void *userdata) { " -a --all Show all properties, including empty ones\n" " --value When showing properties, only print the value\n" " -l --full Do not ellipsize output\n" - " --kill-who=WHO Who to send signal to\n" + " --kill-whom=WHOM Whom to send signal to\n" " -s --signal=SIGNAL Which signal to send\n" " -n --lines=INTEGER Number of journal entries to show\n" " -o --output=STRING Change journal output mode (short, short-precise,\n" @@ -1300,7 +1300,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_VALUE, ARG_NO_PAGER, ARG_NO_LEGEND, - ARG_KILL_WHO, + ARG_KILL_WHOM, ARG_NO_ASK_PASSWORD, }; @@ -1313,7 +1313,7 @@ static int parse_argv(int argc, char *argv[]) { { "full", no_argument, NULL, 'l' }, { "no-pager", no_argument, NULL, ARG_NO_PAGER }, { "no-legend", no_argument, NULL, ARG_NO_LEGEND }, - { "kill-who", required_argument, NULL, ARG_KILL_WHO }, + { "kill-whom", required_argument, NULL, ARG_KILL_WHOM }, { "signal", required_argument, NULL, 's' }, { "host", required_argument, NULL, 'H' }, { "machine", required_argument, NULL, 'M' }, @@ -1399,8 +1399,8 @@ static int parse_argv(int argc, char *argv[]) { arg_ask_password = false; break; - case ARG_KILL_WHO: - arg_kill_who = optarg; + case ARG_KILL_WHOM: + arg_kill_whom = optarg; break; case 's': diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index ef600e8ee4..921af58c94 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -68,7 +68,7 @@ static BusPrintPropertyFlags arg_print_flags = 0; static bool arg_full = false; static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; -static const char *arg_kill_who = NULL; +static const char *arg_kill_whom = NULL; static int arg_signal = SIGTERM; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static const char *arg_host = NULL; @@ -1044,8 +1044,8 @@ static int kill_machine(int argc, char *argv[], void *userdata) { polkit_agent_open_if_enabled(arg_transport, arg_ask_password); - if (!arg_kill_who) - arg_kill_who = "all"; + if (!arg_kill_whom) + arg_kill_whom = "all"; for (int i = 1; i < argc; i++) { r = bus_call_method( @@ -1054,7 +1054,7 @@ static int kill_machine(int argc, char *argv[], void *userdata) { "KillMachine", &error, NULL, - "ssi", argv[i], arg_kill_who, arg_signal); + "ssi", argv[i], arg_kill_whom, arg_signal); if (r < 0) return log_error_errno(r, "Could not kill machine: %s", bus_error_message(&error, r)); } @@ -1063,14 +1063,14 @@ static int kill_machine(int argc, char *argv[], void *userdata) { } static int reboot_machine(int argc, char *argv[], void *userdata) { - arg_kill_who = "leader"; + arg_kill_whom = "leader"; arg_signal = SIGINT; /* sysvinit + systemd */ return kill_machine(argc, argv, userdata); } static int poweroff_machine(int argc, char *argv[], void *userdata) { - arg_kill_who = "leader"; + arg_kill_whom = "leader"; arg_signal = SIGRTMIN+4; /* only systemd */ return kill_machine(argc, argv, userdata); @@ -2500,7 +2500,7 @@ static int help(int argc, char *argv[], void *userdata) { " -a --all Show all properties, including empty ones\n" " --value When showing properties, only print the value\n" " -l --full Do not ellipsize output\n" - " --kill-who=WHO Who to send signal to\n" + " --kill-whom=WHOM Whom to send signal to\n" " -s --signal=SIGNAL Which signal to send\n" " --uid=USER Specify user ID to invoke shell as\n" " -E --setenv=VAR[=VALUE] Add an environment variable for shell\n" @@ -2534,7 +2534,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_NO_PAGER, ARG_NO_LEGEND, ARG_VALUE, - ARG_KILL_WHO, + ARG_KILL_WHOM, ARG_READ_ONLY, ARG_MKDIR, ARG_NO_ASK_PASSWORD, @@ -2554,7 +2554,7 @@ static int parse_argv(int argc, char *argv[]) { { "full", no_argument, NULL, 'l' }, { "no-pager", no_argument, NULL, ARG_NO_PAGER }, { "no-legend", no_argument, NULL, ARG_NO_LEGEND }, - { "kill-who", required_argument, NULL, ARG_KILL_WHO }, + { "kill-whom", required_argument, NULL, ARG_KILL_WHOM }, { "signal", required_argument, NULL, 's' }, { "host", required_argument, NULL, 'H' }, { "machine", required_argument, NULL, 'M' }, @@ -2693,8 +2693,8 @@ static int parse_argv(int argc, char *argv[]) { arg_legend = false; break; - case ARG_KILL_WHO: - arg_kill_who = optarg; + case ARG_KILL_WHOM: + arg_kill_whom = optarg; break; case 's': diff --git a/src/systemctl/systemctl-kill.c b/src/systemctl/systemctl-kill.c index 1a8b4a3eda..b3ae8bbcc2 100644 --- a/src/systemctl/systemctl-kill.c +++ b/src/systemctl/systemctl-kill.c @@ -8,7 +8,7 @@ int verb_kill(int argc, char *argv[], void *userdata) { _cleanup_strv_free_ char **names = NULL; - char *kill_who = NULL; + char *kill_whom = NULL; sd_bus *bus; int r, q; @@ -18,12 +18,12 @@ int verb_kill(int argc, char *argv[], void *userdata) { polkit_agent_open_maybe(); - if (!arg_kill_who) - arg_kill_who = "all"; + if (!arg_kill_whom) + arg_kill_whom = "all"; /* --fail was specified */ if (streq(arg_job_mode(), "fail")) - kill_who = strjoina(arg_kill_who, "-fail"); + kill_whom = strjoina(arg_kill_whom, "-fail"); r = expand_unit_names(bus, strv_skip(argv, 1), NULL, &names, NULL); if (r < 0) @@ -38,7 +38,7 @@ int verb_kill(int argc, char *argv[], void *userdata) { "KillUnit", &error, NULL, - "ssi", *name, kill_who ? kill_who : arg_kill_who, arg_signal); + "ssi", *name, kill_whom ?: arg_kill_whom, arg_signal); if (q < 0) { log_error_errno(q, "Failed to kill unit %s: %s", *name, bus_error_message(&error, q)); if (r == 0) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index fb40c478c2..ae046e73a3 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -89,7 +89,7 @@ bool arg_ask_password = false; bool arg_runtime = false; UnitFilePresetMode arg_preset_mode = UNIT_FILE_PRESET_FULL; char **arg_wall = NULL; -const char *arg_kill_who = NULL; +const char *arg_kill_whom = NULL; int arg_signal = SIGTERM; char *arg_root = NULL; usec_t arg_when = 0; @@ -117,7 +117,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_states, strv_freep); STATIC_DESTRUCTOR_REGISTER(arg_properties, strv_freep); STATIC_DESTRUCTOR_REGISTER(_arg_job_mode, unsetp); STATIC_DESTRUCTOR_REGISTER(arg_wall, strv_freep); -STATIC_DESTRUCTOR_REGISTER(arg_kill_who, unsetp); +STATIC_DESTRUCTOR_REGISTER(arg_kill_whom, unsetp); STATIC_DESTRUCTOR_REGISTER(arg_root, freep); STATIC_DESTRUCTOR_REGISTER(arg_reboot_argument, unsetp); STATIC_DESTRUCTOR_REGISTER(arg_host, unsetp); @@ -262,7 +262,7 @@ static int systemctl_help(void) { " Whether to check inhibitors before shutting down,\n" " sleeping, or hibernating\n" " -i Shortcut for --check-inhibitors=no\n" - " --kill-who=WHO Whom to send signal to\n" + " --kill-whom=WHOM Whom to send signal to\n" " -s --signal=SIGNAL Which signal to send\n" " --what=RESOURCES Which types of resources to remove\n" " --now Start or stop unit after enabling or disabling it\n" @@ -403,7 +403,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { ARG_NO_WALL, ARG_ROOT, ARG_NO_RELOAD, - ARG_KILL_WHO, + ARG_KILL_WHOM, ARG_NO_ASK_PASSWORD, ARG_FAILED, ARG_RUNTIME, @@ -459,7 +459,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { { "root", required_argument, NULL, ARG_ROOT }, { "force", no_argument, NULL, 'f' }, { "no-reload", no_argument, NULL, ARG_NO_RELOAD }, - { "kill-who", required_argument, NULL, ARG_KILL_WHO }, + { "kill-whom", required_argument, NULL, ARG_KILL_WHOM }, { "signal", required_argument, NULL, 's' }, { "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD }, { "host", required_argument, NULL, 'H' }, @@ -693,8 +693,8 @@ static int systemctl_parse_argv(int argc, char *argv[]) { arg_no_reload = true; break; - case ARG_KILL_WHO: - arg_kill_who = optarg; + case ARG_KILL_WHOM: + arg_kill_whom = optarg; break; case 's': diff --git a/src/systemctl/systemctl.h b/src/systemctl/systemctl.h index 7507398c4a..2454c4c714 100644 --- a/src/systemctl/systemctl.h +++ b/src/systemctl/systemctl.h @@ -74,7 +74,7 @@ extern bool arg_ask_password; extern bool arg_runtime; extern UnitFilePresetMode arg_preset_mode; extern char **arg_wall; -extern const char *arg_kill_who; +extern const char *arg_kill_whom; extern int arg_signal; extern char *arg_root; extern usec_t arg_when; diff --git a/test/fuzz/fuzz-systemctl-parse-argv/help.input b/test/fuzz/fuzz-systemctl-parse-argv/help.input index faf1a42e17aa5cb0fdf3e727ce4568a4888e9cb8..280a5f139e3cd8568dfbf692c642a5b04c9b6e2a 100644 GIT binary patch delta 14 VcmZqXXyMop$H /tmp/testsuite-57.counter if [ "$counter" -eq 5 ] ; then - systemctl kill --kill-who=main -sUSR1 testsuite-57.service + systemctl kill --kill-whom=main -sUSR1 testsuite-57.service fi exec sleep 1.5 -- 2.25.1