]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: change --kill-who to --kill-whom
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 24 Aug 2022 08:41:30 +0000 (10:41 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 26 Aug 2022 02:15:44 +0000 (11:15 +0900)
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

18 files changed:
man/loginctl.xml
man/machinectl.xml
man/systemctl.xml
shell-completion/bash/loginctl
shell-completion/bash/machinectl
shell-completion/bash/systemctl.in
shell-completion/zsh/_loginctl
shell-completion/zsh/_machinectl
shell-completion/zsh/_systemctl.in
src/login/loginctl.c
src/machine/machinectl.c
src/systemctl/systemctl-kill.c
src/systemctl/systemctl.c
src/systemctl/systemctl.h
test/fuzz/fuzz-systemctl-parse-argv/help.input
test/units/testsuite-57-binds-to.service
test/units/testsuite-57-prop-stop-one.service
test/units/testsuite-57-short-lived.sh

index bef3be71c96ebcf72eef4c57a3812649ac3bd7a4..792166300de605c598074fddbe3bed4ba499e406 100644 (file)
         <term><command>kill-session</command> <replaceable>ID</replaceable>…</term>
 
         <listitem><para>Send a signal to one or more processes of the session. Use
-        <option>--kill-who=</option> to select which process to kill. Use <option>--signal=</option> to
+        <option>--kill-whom=</option> to select which process to kill. Use <option>--signal=</option> to
         select the signal to send. If the argument is specified as empty string the signal is sent to the
         session invoking the command.</para></listitem>
       </varlistentry>
       </varlistentry>
 
       <varlistentry>
-        <term><option>--kill-who=</option></term>
+        <term><option>--kill-whom=</option></term>
 
         <listitem><para>When used with
         <command>kill-session</command>, choose which processes to
index 1b39e42e3867762f6355cbad2294e751a491b4f0..7abe2adf736aad54ada7ab3b9c0213812008ec1c 100644 (file)
         <listitem><para>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 <option>--kill-who=</option> to select which
+        container. Use <option>--kill-whom=</option> to select which
         process to kill. Use <option>--signal=</option> to select the
         signal to send.</para></listitem>
       </varlistentry>
       </varlistentry>
 
       <varlistentry>
-        <term><option>--kill-who=</option></term>
+        <term><option>--kill-whom=</option></term>
 
         <listitem><para>When used with <command>kill</command>, choose
         which processes to kill. Must be one of
index 6fd9d910d9b3818a8c8be1018d075574a5754fc2..5c0e743d812e7f31f96039eb7aeb2a467194e144 100644 (file)
@@ -498,7 +498,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
 
           <listitem>
             <para>Send a signal to one or more processes of the
-            unit. Use <option>--kill-who=</option> to select which
+            unit. Use <option>--kill-whom=</option> to select which
             process to kill. Use <option>--signal=</option> to select
             the signal to send.</para>
           </listitem>
@@ -2086,7 +2086,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
       </varlistentry>
 
       <varlistentry>
-        <term><option>--kill-who=</option></term>
+        <term><option>--kill-whom=</option></term>
 
         <listitem>
           <para>When used with <command>kill</command>, choose which
index b98b019aa4c4a7c18866dca58ccc91c7428b0662..7af848fdd17a3d153e2090493f581268e9724f4d 100644 (file)
@@ -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)
index b37b059708929c826fa9938da6188da00032dbbb..ebac999897648d40e9bd791e7ba768485deff107 100644 (file)
@@ -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)
index c8ca2882c09552f5dc62847a4b3dfcc0aee38e78..a3e423b845da213e4d4d00eebee5eb7334653f19 100644 (file)
@@ -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)
index 6478a52fe4ac975667e2a96cb9873056c5a69cbd..5473020e3d6d524e83ab777e22d5238a1c39c628 100644 (file)
@@ -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' \
index 8f4e57f123c2c436cee2f7ad065ad3ac0bd838d8..4b4d044ec83c9ecac96a90116b14437fa69eefad 100644 (file)
@@ -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.]' \
index 8b8c59e0d7758fbb8c207dc5fddb107c2e8a5e8b..3d3fbdf32a37800ac77fa4f0ac1277421a0e3d4f 100644 (file)
@@ -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' \
index d00a280e66380cb8539d8bdbf723771efecec9b5..b2c15aad81eac81f0479d935bf21ceb8a124e67f 100644 (file)
@@ -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':
index ef600e8ee41d45c17bf642bb7ca7042ea2dae665..921af58c94d2325a3d3585b27346e3350772f48b 100644 (file)
@@ -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':
index 1a8b4a3eda840db9cdbd829dbbab88b4890c95a9..b3ae8bbcc29f3a3ca2b9f7caf2c2ccb07b975b53 100644 (file)
@@ -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)
index fb40c478c2984ad01a8538f37a654e754df3f777..ae046e73a3d8d081c4e8674b874eb41dc0261634 100644 (file)
@@ -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':
index 7507398c4ab71b62d43460093471d281dd0e8e54..2454c4c714f7f26f79d76c396743daacc6e28ff9 100644 (file)
@@ -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;
index faf1a42e17aa5cb0fdf3e727ce4568a4888e9cb8..280a5f139e3cd8568dfbf692c642a5b04c9b6e2a 100644 (file)
Binary files a/test/fuzz/fuzz-systemctl-parse-argv/help.input and b/test/fuzz/fuzz-systemctl-parse-argv/help.input differ
index f8115a2ecd480a81826db84de04c179ac6685230..c542896d941cd1f50a634dc54852c7fc3c5c3721 100644 (file)
@@ -6,4 +6,5 @@ After=testsuite-57-bound-by.service
 
 [Service]
 ExecStart=/bin/sleep infinity
+# --kill-who= (no 'm') to check that the short form is accepted
 ExecStopPost=systemctl kill --kill-who=main -sRTMIN+1 testsuite-57.service
index 1a25d9e3717b1260183880a4afc7f40d1ad8b258..a942b529e373d7aaf3a89d59eaa863107a247029 100644 (file)
@@ -7,4 +7,4 @@ StopPropagatedFrom=testsuite-57-prop-stop-two.service
 
 [Service]
 ExecStart=/bin/sleep infinity
-ExecStopPost=systemctl kill --kill-who=main -sUSR2 testsuite-57.service
+ExecStopPost=systemctl kill --kill-whom=main -sUSR2 testsuite-57.service
index 164fb0f1de1ccfe261407f666502b5e1082b3c67..cd797a16e14a03994b470756459f964fd29c0db2 100755 (executable)
@@ -12,7 +12,7 @@ fi
 echo "$counter" > /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