summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhalex <halex@openbsd.org>2013-12-18 08:04:16 +0000
committerhalex <halex@openbsd.org>2013-12-18 08:04:16 +0000
commit825836e3985c6e8d259a0bf0ed00cf0744368ba3 (patch)
treeec567dd05d27210e65ecd970ab6751c3c6bbd703
parentCode existed to print non-printable characters in strings written (diff)
downloadwireguard-openbsd-825836e3985c6e8d259a0bf0ed00cf0744368ba3.tar.xz
wireguard-openbsd-825836e3985c6e8d259a0bf0ed00cf0744368ba3.zip
change password prompts (for the good of install.conf)
add autoinstall question for root ssh pubkey make pubkey prompts appear in autoinstall log ideas from and ok deraaddt@, ok rpe@
-rw-r--r--distrib/miniroot/install.sh9
-rw-r--r--distrib/miniroot/install.sub23
2 files changed, 22 insertions, 10 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh
index f49bea0ea56..c83cd9ba309 100644
--- a/distrib/miniroot/install.sh
+++ b/distrib/miniroot/install.sh
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: install.sh,v 1.238 2013/12/06 00:42:45 rpe Exp $
+# $OpenBSD: install.sh,v 1.239 2013/12/18 08:04:16 halex 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
@@ -314,6 +314,13 @@ q" | ed /mnt/etc/master.passwd 2>/dev/null
fi
/mnt/usr/sbin/pwd_mkdb -p -d /mnt/etc /etc/master.passwd
+# Add public ssh key to authorized_keys
+[[ -n "$rootkey" ]] && (
+ umask 077
+ mkdir /mnt/root/.ssh
+ print -r -- "$rootkey" >> /mnt/root/.ssh/authorized_keys
+)
+
if grep -qs '^rtsol' /mnt/etc/hostname.*; then
sed -e "/^#\(net\.inet6\.ip6\.accept_rtadv\)/s//\1/" \
-e "/^#\(net\.inet6\.icmp6\.rediraccept\)/s//\1/" \
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 93abc1cf626..57ecede9333 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.721 2013/12/16 16:58:22 halex Exp $
+# $OpenBSD: install.sub,v 1.722 2013/12/18 08:04:16 halex Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
@@ -331,19 +331,20 @@ ask() {
# Ask for a password twice, saving the input in $_password
askpassword() {
+ local _q=$1
if $auto; then
- echo -n "Password for $1 account? "
- _autorespond "Password for $1 account?"
+ echo -n "$_q "
+ _autorespond "$_q"
echo '<provided>'
_password=$resp
return
fi
while :; do
- askpass "Password for $1 account? (will not echo)"
+ askpass "$_q (will not echo)"
_password=$resp
- askpass "Password for $1 account? (again)"
+ askpass "$_q (again)"
[[ $resp == "$_password" ]] && break
echo "Passwords do not match, try again."
@@ -379,7 +380,7 @@ user_setup() {
done
user=$resp
while :; do
- ask "Full user name for $user?" $user
+ ask "Full name for user $user?" $user
case $resp in
*[:\&,]*)
echo "':', '&' or ',' are not allowed." ;;
@@ -390,11 +391,11 @@ user_setup() {
done
username=$resp
- askpassword $user
+ askpassword "Password for user $user?"
userpass=$_password
userkey=
- _autorespond "Public ssh key for $user" none &&
+ $auto && ask "Public ssh key for user $user" none &&
[[ $resp != none ]] && userkey=$resp
if [[ $sshd == y ]]; then
@@ -2225,12 +2226,16 @@ if [[ $MODE == install ]]; then
echo
while :; do
- askpassword root
+ askpassword "Password for root account?"
_rootpass="$_password"
[[ -n "$_password" ]] && break
echo "The root password must be set."
done
+ rootkey=
+ $auto && ask "Public ssh key for root account?" none &&
+ [[ $resp != none ]] && rootkey=$resp
+
questions
user_setup