From 7aed43437175623e0f3ae8b071bbc500c13ce893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 19 Mar 2024 11:14:55 +0100 Subject: [PATCH] Rename uid0 to run0 Naming is always a matter of preference, and the old name would certainly work, but I think the new one has the following advantages: - A verb is better than a noun. - The name more similar to "the competition", i.e. 'sudo', 'pkexec', 'runas', 'doas', which generally include an action verb. - The connection between 'systemd-run' and 'run0' is more obvious. There has been no release yet with the old name, so we can rename without caring for backwards compatibility. --- NEWS | 2 +- TODO | 2 +- man/rules/meson.build | 2 +- man/{uid0.xml => run0.xml} | 26 ++++++++++---------- man/systemd-run.xml | 2 +- src/run/meson.build | 8 +++--- src/run/run.c | 8 +++--- src/run/{systemd-uid0.in => systemd-run0.in} | 2 +- test/units/testsuite-74.run.sh | 16 ++++++------ 9 files changed, 34 insertions(+), 34 deletions(-) rename man/{uid0.xml => run0.xml} (93%) rename src/run/{systemd-uid0.in => systemd-run0.in} (96%) diff --git a/NEWS b/NEWS index 1f71030ebfd..7014e7582af 100644 --- a/NEWS +++ b/NEWS @@ -329,7 +329,7 @@ CHANGES WITH 256 in spe: Command-line tools: - * systemd-run is now a multi-call binary. When invoked as 'uid0', it + * systemd-run is now a multi-call binary. When invoked as 'run0', it provides as interface similar to 'sudo', with all arguments starting at the first non-option parameter being treated the command to invoke as root. Unlike 'sudo' and similar tools, it does not make use diff --git a/TODO b/TODO index 3b76e98bdeb..38b82b6a03f 100644 --- a/TODO +++ b/TODO @@ -255,7 +255,7 @@ Features: * add a new ExecStart= flag that inserts the configured user's shell as first word in the command line. (maybe use character '.'). Usecase: tool such as - uid0 can use that to spawn the target user's default shell. + run0 can use that to spawn the target user's default shell. * varlink: figure out how to do docs for our varlink interfaces. Idea: install interface files augmented with docs in /usr/share/ somewhere. And have diff --git a/man/rules/meson.build b/man/rules/meson.build index 465ea4e4b3e..38a0749fc75 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -75,6 +75,7 @@ manpages = [ ['repart.d', '5', [], 'ENABLE_REPART'], ['resolvectl', '1', ['resolvconf'], 'ENABLE_RESOLVE'], ['resolved.conf', '5', ['resolved.conf.d'], 'ENABLE_RESOLVE'], + ['run0', '1', [], ''], ['runlevel', '8', [], 'HAVE_SYSV_COMPAT'], ['sd-bus-errors', '3', @@ -1265,7 +1266,6 @@ manpages = [ ''], ['udev_new', '3', ['udev_ref', 'udev_unref'], ''], ['udevadm', '8', [], ''], - ['uid0', '1', [], ''], ['ukify', '1', [], 'ENABLE_UKIFY'], ['user@.service', '5', diff --git a/man/uid0.xml b/man/run0.xml similarity index 93% rename from man/uid0.xml rename to man/run0.xml index f0bfa40b9d9..09e5620cce5 100644 --- a/man/uid0.xml +++ b/man/run0.xml @@ -3,27 +3,27 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> - - uid0 + run0 systemd - uid0 + run0 1 - uid0 + run0 Elevate privileges - uid0 + run0 OPTIONS COMMAND @@ -32,7 +32,7 @@ Description - uid0 may be used to temporarily and interactively acquire elevated or different + run0 may be used to temporarily and interactively acquire elevated or different privileges. It serves a similar purpose as sudo8, but operates differently in a couple of key areas: @@ -57,10 +57,10 @@ setting the NoNewPrivileges= variable in systemd-system.conf5). - Any session invoked via uid0 will run through the - systemd-uid0 PAM stack. + Any session invoked via run0 will run through the + systemd-run0 PAM stack. - Note that uid0 is implemented as an alternative multi-call invocation of + Note that run0 is implemented as an alternative multi-call invocation of systemd-run1. @@ -123,11 +123,11 @@ Make the new .service unit part of the slice the - uid0 itself has been invoked in. This option may be combined with + run0 itself has been invoked in. This option may be combined with , in which case the slice specified via is placed - within the slice the uid0 command is invoked in. + within the slice the run0 command is invoked in. - Example: consider uid0 being invoked in the slice + Example: consider run0 being invoked in the slice foo.slice, and the argument is bar. The unit will then be placed under foo-bar.slice. @@ -215,7 +215,7 @@ Exit status - On success, 0 is returned. If uid0 failed to start the session or the specified command fails, a + On success, 0 is returned. If run0 failed to start the session or the specified command fails, a non-zero return value will be returned. diff --git a/man/systemd-run.xml b/man/systemd-run.xml index e891920c630..c6fd4ac20c1 100644 --- a/man/systemd-run.xml +++ b/man/systemd-run.xml @@ -706,7 +706,7 @@ $ systemd-run --user --wait -p SuccessExitStatus=SIGUSR1 --expand-environment=no systemd.timer5 systemd-mount1 machinectl1 - uid01 + run01 diff --git a/src/run/meson.build b/src/run/meson.build index 95336b86fe5..221b441fac8 100644 --- a/src/run/meson.build +++ b/src/run/meson.build @@ -12,12 +12,12 @@ install_emptydir(bindir) meson.add_install_script(sh, '-c', ln_s.format(bindir / 'systemd-run', - bindir / 'uid0')) + bindir / 'run0')) custom_target( - 'systemd-uid0', - input : 'systemd-uid0.in', - output : 'systemd-uid0', + 'systemd-run0', + input : 'systemd-run0.in', + output : 'systemd-run0', command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'], install : pamconfdir != 'no', install_dir : pamconfdir) diff --git a/src/run/run.c b/src/run/run.c index c0c65b2ea1f..e8dc3388c05 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -159,7 +159,7 @@ static int help_sudo_mode(void) { _cleanup_free_ char *link = NULL; int r; - r = terminal_urlify_man("uid0", "1", &link); + r = terminal_urlify_man("run0", "1", &link); if (r < 0) return log_oom(); @@ -743,7 +743,7 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) { ARG_BACKGROUND, }; - /* If invoked as "uid0" binary, let's expose a more sudo-like interface. We add various extensions + /* If invoked as "run0" binary, let's expose a more sudo-like interface. We add various extensions * though (but limit the extension to long options). */ static const struct option options[] = { @@ -943,7 +943,7 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) { if (strv_extendf(&arg_property, "LogExtraFields=ELEVATED_USER=%s", un) < 0) return log_oom(); - if (strv_extend(&arg_property, "PAMName=systemd-uid0") < 0) + if (strv_extend(&arg_property, "PAMName=systemd-run0") < 0) return log_oom(); if (!arg_background && arg_stdio == ARG_STDIO_PTY) { @@ -2262,7 +2262,7 @@ static int run(int argc, char* argv[]) { log_parse_environment(); log_open(); - if (invoked_as(argv, "uid0")) + if (invoked_as(argv, "run0")) r = parse_argv_sudo_mode(argc, argv); else r = parse_argv(argc, argv); diff --git a/src/run/systemd-uid0.in b/src/run/systemd-run0.in similarity index 96% rename from src/run/systemd-uid0.in rename to src/run/systemd-run0.in index 57bd5e38b92..11f830b7b08 100644 --- a/src/run/systemd-uid0.in +++ b/src/run/systemd-run0.in @@ -1,7 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # This file is part of systemd. # -# Used by uid0 sessions +# Used by run0 sessions {% if ENABLE_HOMED %} -account sufficient pam_systemd_home.so diff --git a/test/units/testsuite-74.run.sh b/test/units/testsuite-74.run.sh index a94776eadd1..4f3c967e2cf 100755 --- a/test/units/testsuite-74.run.sh +++ b/test/units/testsuite-74.run.sh @@ -231,15 +231,15 @@ assert_eq "$KVER" "$UNIT_KVER" umount /proc/version rm -f "$TMP_KVER" -# Check that invoking the tool under the uid0 alias name works -uid0 ls / -assert_eq "$(uid0 echo foo)" "foo" +# Check that invoking the tool under the run0 alias name works +run0 ls / +assert_eq "$(run0 echo foo)" "foo" # Check if we set some expected environment variables for arg in "" "--user=root" "--user=testuser"; do - assert_eq "$(uid0 ${arg:+"$arg"} bash -c 'echo $SUDO_USER')" "$USER" - assert_eq "$(uid0 ${arg:+"$arg"} bash -c 'echo $SUDO_UID')" "$(id -u "$USER")" - assert_eq "$(uid0 ${arg:+"$arg"} bash -c 'echo $SUDO_GID')" "$(id -u "$USER")" + assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_USER')" "$USER" + assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_UID')" "$(id -u "$USER")" + assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_GID')" "$(id -u "$USER")" done -# Let's chain a couple of uid0 calls together, for fun -readarray -t cmdline < <(printf "%.0suid0\n" {0..31}) +# Let's chain a couple of run0 calls together, for fun +readarray -t cmdline < <(printf "%.0srun0\n" {0..31}) assert_eq "$("${cmdline[@]}" bash -c 'echo $SUDO_USER')" "$USER"