grml-chroot: use shell of target's root user
authorChristian Hofstaedtler <ch@grml.org>
Mon, 6 Dec 2010 17:35:50 +0000 (18:35 +0100)
committerChristian Hofstaedtler <ch@grml.org>
Mon, 6 Dec 2010 17:35:50 +0000 (18:35 +0100)
grml-chroot is commonly used with fresh installations which might not
have the shell of the current user, or it may be badly configured.
default to the shell of the target's root user, in the hope that it
will be more useful.

doc/grml-chroot.8.txt
usr_sbin/grml-chroot

index 2c6ec0d..659ab44 100644 (file)
@@ -19,6 +19,8 @@ DESCRIPTION
 around plain chroot with integrated proc/sys/pts/dev filesystem handling.
 After _COMMAND_ exits, mounts are cleaned up properly.
 
+If _COMMAND_ is omitted, the shell of user *root* of the target filesystem is used.
+
 
 OPTIONS
 -------
index b3d1184..bdd6bc9 100755 (executable)
@@ -89,7 +89,8 @@ mountit "proc"  "proc"
 mountit "sysfs" "sys"
 mountit "/dev"   "dev"   "--bind"
 if (( $# < 1 )); then
-    chroot "$DEST_"
+    shell=$(awk '/^root:/{ split($0,a,":"); print a[7] }' < "$DEST_/etc/passwd")
+    chroot "$DEST_" "$shell"
     RC=$?
 else
     chroot "$DEST_" "$@"