diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-04-23 18:26:15 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-04-23 18:26:15 +0000 |
commit | 454f059ca9aff1996dada6de0ac40ab21e53b4f2 (patch) | |
tree | 07b90c3ceacc073f798357f55eed9e7fe1711e8d /distrib/miniroot | |
parent | 0246695ed347ba71399b3da90a46e82b8f966fe0 (diff) |
Near the end of the installation, prompt for the setup of an initial
user, who will also be placed in wheel. The setup of that user is
expected to be mostly compatible with what useradd(8) would have done.
krw will probably improve the ksh code in here after this :)
Diffstat (limited to 'distrib/miniroot')
-rw-r--r-- | distrib/miniroot/install.sh | 32 | ||||
-rw-r--r-- | distrib/miniroot/install.sub | 46 |
2 files changed, 56 insertions, 22 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh index c3843d22739..3e63dcbde2f 100644 --- a/distrib/miniroot/install.sh +++ b/distrib/miniroot/install.sh @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: install.sh,v 1.168 2009/04/19 17:56:01 deraadt Exp $ +# $OpenBSD: install.sh,v 1.169 2009/04/23 18:26:14 deraadt Exp $ # $NetBSD: install.sh,v 1.5.2.8 1996/08/27 18:15:05 gwr Exp $ # # Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback @@ -331,20 +331,8 @@ THESETS="$THESETS site$VERSION-$(hostname -s).tgz" ask_yn "Configure the network?" yes [[ $resp == y ]] && donetconfig -_oifs=$IFS -IFS= -while :; do - askpass "Password for root account? (will not echo)" - _password=$resp - - askpass "Password for root account? (again)" - # N.B.: Need quotes around $resp and $_password to preserve leading - # or trailing spaces. - [[ "$resp" == "$_password" ]] && break - - echo "Passwords do not match, try again." -done -IFS=$_oifs +askpassword root +_rootpass="$_password" install_sets @@ -372,6 +360,8 @@ mv /tmp/ttys /mnt/etc/ttys # Handle questions... questions +user_setup + echo -n "Saving configuration files..." # Save any leases obtained during install. @@ -409,18 +399,18 @@ for _f in fstab hostname* kbdtype my* ttys *.conf *.tail; do [[ -f $_f && -s $_f ]] && mv $_f /mnt/etc/. done ) -_encr=`/mnt/usr/bin/encrypt -b 8 -- "$_password"` -echo "1,s@^root::@root:${_encr}:@ -w -q" | /mnt/bin/ed /mnt/etc/master.passwd 2>/dev/null -/mnt/usr/sbin/pwd_mkdb -p -d /mnt/etc /etc/master.passwd - echo -n "done.\nGenerating initial host.random file..." ( cd /mnt/var/db /mnt/bin/dd if=/mnt/dev/urandom of=host.random bs=1024 count=64 >/dev/null 2>&1 chmod 600 host.random >/dev/null 2>&1 ) echo "done." +_encr=`/mnt/usr/bin/encrypt -b 8 -- "$_rootpass"` +echo "1,s@^root::@root:${_encr}:@ +w +q" | /mnt/bin/ed /mnt/etc/master.passwd 2>/dev/null +/mnt/usr/sbin/pwd_mkdb -p -d /mnt/etc /etc/master.passwd + set_timezone # Perform final steps common to both an install and an upgrade. diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index b7d5ddeac13..23e2d878d7b 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,4 +1,4 @@ -# $OpenBSD: install.sub,v 1.466 2009/04/19 21:42:00 krw Exp $ +# $OpenBSD: install.sub,v 1.467 2009/04/23 18:26:14 deraadt Exp $ # $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $ # # Copyright (c) 1997-2007 Todd Miller, Theo de Raadt, Ken Westerback @@ -282,6 +282,50 @@ ask() { set +o noglob } +# Ask for a password twice, saving the input in $_password +askpassword() { + _oifs=$IFS + IFS= + while :; do + askpass "Password for $1 account? (will not echo)" + _password=$resp + + askpass "Password for $1 account? (again)" + # N.B.: Need quotes around $resp and $_password to preserve leading + # or trailing spaces. + [[ "$resp" == "$_password" ]] && break + + echo "Passwords do not match, try again." + done + IFS=$_oifs +} + +user_setup() { + local _u _n _encr + + ask "Setup a user? (enter a lower-case loginname, or 'no')" no + + case $resp in + n|no) return ;; + esac + + _u=$resp + ask "Full user name for $_u?" $_u + _n=$resp + + askpassword $_u + _encr=`/mnt/usr/bin/encrypt -b 8 -- "$_password"` + echo "${_u}:${_encr}:1000:10::0:0:${_n}:/home/${_u}:/bin/ksh" \ + >> /mnt/etc/master.passwd + + mkdir -p /mnt/home/$_u + (cd /mnt/etc/skel; cp -pR . /mnt/home/$_u) + chown -R 1000.10 /mnt/home/$_u + echo "1,s@wheel:.:0:root\$@wheel:\*:0:root,${_u}@ +w +q" | /mnt/bin/ed /mnt/etc/group 2>/dev/null +} + # Ask for user input until a non-empty reply is entered. # # $1 = the question to ask the user |