nspawn: rename --user= to --uid= and repurpose --user/--system for runtime scope
Rename nspawn's --user=NAME option to --uid=NAME for selecting the container user. The -u short option is preserved. --user=NAME and --user NAME are still accepted but emit a deprecation warning. A pre-parsing step stitches the space-separated --user NAME form into --user=NAME before getopt sees it, preserving backwards compatibility despite --user now being an optional_argument. Repurpose --user (without argument) and --system as standalone switches for selecting the runtime scope (user vs system service manager). Replace all uses of the arg_privileged boolean with arg_runtime_scope comparisons throughout nspawn. The default scope is auto-detected from the effective UID. Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Daan De Meyer
parent
1e084aad7d
commit
e7fb7296f5
@@ -69,8 +69,8 @@ _systemd_nspawn() {
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system
|
||||
--keep-unit -n --network-veth -j -x --ephemeral -a --as-pid2 -U --suppress-sync=yes
|
||||
--cleanup'
|
||||
[ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro
|
||||
--cleanup --user --system'
|
||||
[ARG]='-D --directory -u --uid --uuid --capability --drop-capability --link-journal --bind --bind-ro
|
||||
-M --machine -S --slice -E --setenv -Z --selinux-context -L --selinux-apifs-context
|
||||
--register --network-interface --network-bridge --personality -i --image --image-policy --tmpfs
|
||||
--volatile --network-macvlan --kill-signal --template --notify-ready --root-hash --chdir
|
||||
@@ -88,7 +88,7 @@ _systemd_nspawn() {
|
||||
compopt -o nospace
|
||||
comps=$(compgen -S/ -A directory -- "$cur" )
|
||||
;;
|
||||
--user|-u)
|
||||
--uid|-u)
|
||||
comps=$( __get_users )
|
||||
;;
|
||||
--uuid|--root-hash)
|
||||
|
||||
@@ -22,7 +22,9 @@ _arguments \
|
||||
'(--ephemeral -x)'{--ephemeral,-x}'[Run container with snapshot of root directory, and remove it after exit.]' \
|
||||
'(--image -i)'{--image=,-i+}'[Disk image to mount the root directory for the container from.]:disk image: _files' \
|
||||
'(--boot -b)'{--boot,-b}'[Automatically search for an init binary and invoke it instead of a shell or a user supplied program.]' \
|
||||
'(--user -u)'{--user=,-u+}'[Run the command under specified user, create home directory and cd into it.]:user:_users' \
|
||||
'(--uid -u)'{--uid=,-u+}'[Run the command under specified user, create home directory and cd into it.]:user:_users' \
|
||||
'--user[Run in user service manager scope]' \
|
||||
'--system[Run in system service manager scope]' \
|
||||
'(--machine -M)'{--machine=,-M+}'[Sets the machine name for this container.]: : _message "container name"' \
|
||||
'--uuid=[Set the specified uuid for the container.]: : _message "container UUID"' \
|
||||
'(--slice -S)'{--slice=,-S+}'[Make the container part of the specified slice, instead of the default machine.slice.]: : _message slice' \
|
||||
|
||||
Reference in New Issue
Block a user