Set root password to specified/generated ssh password.
[grml-autoconfig.git] / autoconfig.functions
index 6e0a6b8..46c5d43 100755 (executable)
@@ -40,6 +40,17 @@ if [ -z "$CMDLINE" ]; then
   CMDLINE="$(cat /proc/cmdline)"
   [ -d /cdrom/bootparams/ ]      && CMDLINE="$CMDLINE $(cat /cdrom/bootparams/* | tr '\n' ' ')"
   [ -d /live/image/bootparams/ ] && CMDLINE="$CMDLINE $(cat /live/image/bootparams/* | tr '\n' ' ')"
+  modprobe 9p 2>/dev/null || true
+  if grep -q 9p /proc/filesystems ; then
+      local TAG="grml-parameters"
+      if grep -q "$TAG" /sys/bus/virtio/devices/*/mount_tag 2>/dev/null ; then
+          local MOUNTDIR="$(mktemp -d)"
+          mount -t 9p -o trans=virtio,ro "$TAG" "$MOUNTDIR"
+          CMDLINE="$CMDLINE $(cat "$MOUNTDIR"/* 2>/dev/null | tr '\n' ' ')"
+          umount "$MOUNTDIR"
+          rmdir "$MOUNTDIR"
+      fi
+  fi
 fi
 # }}}
 
@@ -1042,7 +1053,7 @@ if checkbootparam 'ssh' ; then
    SSH_PASSWD=''
    SSH_PASSWD="$(getbootparam 'ssh' 2>>$DEBUG)"
    config_userlocal
-   einfo "Bootoption ssh found, trying to set password for user $localuser"
+   einfo "Bootoption ssh found, trying to set password for root and user $localuser"
    [ -z "$localuser" ] && eend 1
    eindent
    if [ -z "$SSH_PASSWD" ] ; then
@@ -1071,11 +1082,12 @@ if checkbootparam 'ssh' ; then
    # finally check if we have a password we can use:
    if [ -n "$SSH_PASSWD" ] ; then
       # chpasswd sucks, seriously.
+      chpass_options=""
       if chpasswd --help 2>&1 | grep -q -- '-m,' ; then
-        echo "$localuser:$SSH_PASSWD" | chpasswd -m
-      else
-        echo "$localuser:$SSH_PASSWD" | chpasswd
+        chpass_options="-m"
       fi
+      echo "$localuser:$SSH_PASSWD" | chpasswd $chpass_options
+      echo "root:$SSH_PASSWD" | chpasswd $chpass_options
    fi
 
    einfo "Starting secure shell server in background for user $localuser"