summaryrefslogtreecommitdiff
path: root/distrib/miniroot
diff options
context:
space:
mode:
authorAlexander Hall <halex@cvs.openbsd.org>2013-10-31 19:15:21 +0000
committerAlexander Hall <halex@cvs.openbsd.org>2013-10-31 19:15:21 +0000
commitf68a3b5c2c56c3f21f659573346495ad988c7bec (patch)
treedbc6e5d66e13548475e1b886280ac757a1c31e74 /distrib/miniroot
parent2d3d35a0136aa1d3a7276be1a3b4b616229a9263 (diff)
If if looks like a duck, swims like a duck, and quacks like a duck, then
it's probably is a pre-encrypted password hash. This means that the autoinstall configuration (and interactive password too) does not have to specify a cleartext password. reworked diff originating from krw@ no objections, specifically so from krw@
Diffstat (limited to 'distrib/miniroot')
-rw-r--r--distrib/miniroot/install.sh7
-rw-r--r--distrib/miniroot/install.sub13
2 files changed, 15 insertions, 5 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh
index 5498402e437..79d696d8a99 100644
--- a/distrib/miniroot/install.sh
+++ b/distrib/miniroot/install.sh
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: install.sh,v 1.233 2013/05/31 06:27:08 rpe Exp $
+# $OpenBSD: install.sh,v 1.234 2013/10/31 19:15:20 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
@@ -284,8 +284,7 @@ echo "done."
apply
if [[ -n $user ]]; then
- _encr="*"
- [[ -n "$userpass" ]] && _encr=$(/mnt/usr/bin/encrypt -b 8 -- "$userpass")
+ _encr=$(encr_pwd "$userpass")
uline="${user}:${_encr}:1000:1000:staff:0:0:${username}:/home/${user}:/bin/ksh"
echo "$uline" >> /mnt/etc/master.passwd
echo "${user}:*:1000:" >> /mnt/etc/group
@@ -303,7 +302,7 @@ q" | ed /mnt/etc/group 2>/dev/null
fi
if [[ -n "$_rootpass" ]]; then
- _encr=$(/mnt/usr/bin/encrypt -b 8 -- "$_rootpass")
+ _encr=$(encr_pwd "$_rootpass")
echo "1,s@^root::@root:${_encr}:@
w
q" | ed /mnt/etc/master.passwd 2>/dev/null
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 9950a35894c..4dafd1ebbbe 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.685 2013/10/27 22:36:06 uwe Exp $
+# $OpenBSD: install.sub,v 1.686 2013/10/31 19:15:20 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
@@ -323,6 +323,17 @@ askpassword() {
done
}
+encr_pwd() {
+ local _p=$1
+ if [[ -z $_p ]]; then
+ echo '*'
+ elif [[ $_p == \$2?\$[0-9][0-9]\$* && ${#_p} > 40 ]]; then
+ echo "$_p"
+ else
+ /mnt/usr/bin/encrypt -b 8 -- "$_p"
+ fi
+}
+
user_setup() {
local _q="Setup a user? (enter a lower-case loginname, or 'no')"