From 1ac0b894ab02aeff8bdedef36cd0056e0846d2a9 Mon Sep 17 00:00:00 2001 From: Michael Gebetsroither Date: Wed, 24 Mar 2010 19:59:07 +0100 Subject: [PATCH] implement bootparameter rootpw= to set root password --- autoconfig | 1 + autoconfig.functions | 25 +++++++++++++++++++++++++ grml-autoconfig | 2 ++ 3 files changed, 28 insertions(+) diff --git a/autoconfig b/autoconfig index 229a7c5..56c8fbc 100644 --- a/autoconfig +++ b/autoconfig @@ -113,6 +113,7 @@ CONFIG_SERVICES='yes' # check for services to run, provided via bootpara CONFIG_SETKEYCODES='yes' # run setkeycodes when bootoption setkeycodes found CONFIG_SMALL='yes' # use a less "bloat" /etc/inittab for small computer with less RAM CONFIG_SSH='yes' # check for bootparam ssh +CONFIG_ROOTPW='yes' # check for bootparam rootpw CONFIG_SWRAID='yes' # check for software raid devices [only in live-mode] CONFIG_SWSPEAK='yes' # run software synthesizer via speakup CONFIG_TESTCD='yes' # CD checker diff --git a/autoconfig.functions b/autoconfig.functions index c0c1111..1571255 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -1444,6 +1444,31 @@ fi } # }}} +# {{{ configure root password +config_rootpw(){ +if checkbootparam 'rootpw' ; then + ROOT_PASSWD='' + ROOT_PASSWD="$(getbootparam 'rootpw' 2>>$DEBUG)" + einfo "Bootoption rootpw found, trying to set password for user root." + + if [ -z "$ROOT_PASSWD" ] ; then + ewarn "No password given for user root. Please set one with rootpw=" ; eend 0 + else + # chpasswd sucks, seriously. + if chpasswd --help 2>&1 | grep -q -- '-m,' ; then + echo "root:$ROOT_PASSWD" | chpasswd -m + else + echo "root:$ROOT_PASSWD" | chpasswd + fi + fi + + eindent + ewarn 'Warning: please change the password for user root as soon as possible!' + eoutdent +fi +} +# }}} + # {{{ autostart of x11vnc config_vnc(){ diff --git a/grml-autoconfig b/grml-autoconfig index c50062a..3c533e6 100755 --- a/grml-autoconfig +++ b/grml-autoconfig @@ -196,6 +196,8 @@ checkvalue $CONFIG_CPU && config_cpu checkvalue $CONFIG_SSH && config_ssh +checkvalue $CONFIG_ROOTPW && config_rootpw + checkvalue $CONFIG_VNC && config_vnc checkvalue $CONFIG_PASSWD && config_passwd -- 2.1.4