diff options
-rwxr-xr-x | bin/debvm-create | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/bin/debvm-create b/bin/debvm-create index b93fa23..a8d5727 100755 --- a/bin/debvm-create +++ b/bin/debvm-create @@ -303,12 +303,17 @@ fi # construct mmdebstrap options as $@: set -- \ --verbose \ - --mode=unshare \ --variant=apt \ "--format=$MMFORMAT" \ '--customize-hook=echo "LABEL=debvm / ext4 defaults 0 0" >"$1/etc/fstab"' \ "$@" +if test "$(id -u)" = 0; then + set -- --mode=root "$@" +else + set -- --mode=unshare "$@" +fi + if test -n "$ARCHITECTURE"; then set -- "--architecture=$ARCHITECTURE" "$@" fi @@ -394,9 +399,15 @@ if ! check_skip autologin; then set -- "--customize-hook=$SHARE_DIR/customize-autologin.sh" "$@" fi -run_inside_userns() { - unshare --user --map-auto --map-user=65536 --map-group=65536 --keep-caps -- "$@" -} +if test "$(id -u)" = 0; then + run_inside_userns() { + "$@" + } +else + run_inside_userns() { + unshare --user --map-auto --map-user=65536 --map-group=65536 --keep-caps -- "$@" + } +fi TEMPROOT= cleanup() { |