[Pkg-shadow-commits] r569 - trunk/debian
Christian Perrier
bubulle at costa.debian.org
Fri Oct 7 09:40:46 UTC 2005
Author: bubulle
Date: 2005-10-07 09:40:46 +0000 (Fri, 07 Oct 2005)
New Revision: 569
Modified:
trunk/debian/passwd.config
trunk/debian/passwd.templates
Log:
Change the debconf variable names to fit what Ubuntu already does
Also adapt the code to be closer to Ubuntu code
Modified: trunk/debian/passwd.config
===================================================================
--- trunk/debian/passwd.config 2005-10-06 18:59:45 UTC (rev 568)
+++ trunk/debian/passwd.config 2005-10-07 09:40:46 UTC (rev 569)
@@ -57,10 +57,8 @@
# only called when first booting the system, when root has no
# password at all, so that should be an unnecessary precaution).
#
-# Arguments:
-# 1) (mandatory) username
-# 2) (mandatory) password
-# 3) (optional) 1 for meaning "the passed password is a MD5 hash"
+# Pass in three arguments: the user, the password, and 'true' if the
+# password has been pre-crypted (by preseeding).
setpassword () {
SETPASSWD_PW="$2"
export SETPASSWD_PW
@@ -71,10 +69,13 @@
USE_MD5=1
export USE_MD5
- if test "$3" ; then
- echo $1:${SETPASSWD_PW} | chpasswd -e
- else
- perl -e '
+ if [ "$3" = true ]; then
+ PRECRYPTED=1
+ else
+ PRECRYPTED=''
+ fi
+ export PRECRYPTED
+ perl -e '
sub CreateCryptSalt {
my $md5 = shift;
@@ -93,14 +94,19 @@
}
open(P,"| chpasswd -e");
- print P shift().":".
- crypt($ENV{SETPASSWD_PW}, CreateCryptSalt($ENV{USE_MD5})).
- "\n";
+ if ($ENV{PRECRYPTED}) {
+ print P shift().":$ENV{SETPASSWD_PW}\n";
+ } else {
+ print P shift().":".
+ crypt($ENV{SETPASSWD_PW}, CreateCryptSalt($ENV{USE_MD5})).
+ "\n";
+ }
close P;
- ' "$1"
+ ' "$1"
fi
SETPASSWD_PW=''
USE_MD5=''
+ PRECRYPTED=''
}
# Main loop starts here. Use a state machine to allow jumping back to
@@ -128,8 +134,8 @@
3)
# Prompt for a root password if there is none.
if ! root_password; then
- # First check whether the root password hash was preseeded
- db_get passwd/root-password-hash || true
+ # First check whether the root password was preseeded crypted
+ db_get passwd/root-password-crypted || true
if ! test $RET ; then
# No preseed of the root password hash
# we will prompt the user
@@ -146,8 +152,8 @@
4)
# Verify and set a root password.
if ! root_password; then
- # First check whether the root password hash was preseeded
- db_get passwd/root-password-hash || true
+ # First check whether the root password was preseeded crypted
+ db_get passwd/root-password-crypted || true
if ! test $RET ; then
# Compare the two passwords, loop back if not
# identical, or if empty.
@@ -171,12 +177,14 @@
# password.
db_set passwd/root-password ""
db_set passwd/root-password-again ""
- setpassword root "$ROOT_PW"
+ setpassword root "$ROOT_PW" false
ROOT_PW=''
else
- # The hash for the root password was preseeded
+ # The root password was preseeded encrypted
+ # Clear it from the db, then set it
+ db_set passwd/root-password-crypted ""
ROOT_PW=$RET
- setpassword root "$ROOT_PW" 1
+ setpassword root "$ROOT_PW" true
ROOT_PW=''
fi
# Loop back to state #2 to make sure that there
@@ -239,7 +247,7 @@
continue
fi
- db_get passwd/user-password-hash || true
+ db_get passwd/user-password-crypted || true
if ! test $RET ; then
db_input critical passwd/user-password || true
COMPARE_PW=''
@@ -251,7 +259,7 @@
9)
db_get passwd/make-user
if [ "$RET" = true ] && ! is_system_user; then
- db_get passwd/user-password-hash || true
+ db_get passwd/user-password-crypted || true
if ! test $RET ; then
# Compare the two passwords, loop with message if not
# identical, or if empty.
@@ -291,16 +299,16 @@
useradd -c "$RET" -m "$USER" >/dev/null || true
fi
- db_get passwd/user-password-hash || true
+ db_get passwd/user-password-crypted || true
if ! test $RET ; then
# Clear password from the db, and set the password.
db_set passwd/user-password ""
db_set passwd/user-password-again ""
db_get passwd/username
- setpassword "$USER" "$USER_PW"
+ setpassword "$USER" "$USER_PW" false
USER_PW=''
else
- setpassword "$USER" "$USER_PW" 1
+ setpassword "$USER" "$USER_PW" true
USER_PW=''
fi
Modified: trunk/debian/passwd.templates
===================================================================
--- trunk/debian/passwd.templates 2005-10-06 18:59:45 UTC (rev 568)
+++ trunk/debian/passwd.templates 2005-10-07 09:40:46 UTC (rev 569)
@@ -1,12 +1,12 @@
# This template is for D-I purposes and should allow
-# preseeding the root password with a MD5 hash rather than cleartext
-Template: passwd/root-password-hash
+# preseeding the root password with a crypted password rather than cleartext
+Template: passwd/root-password-crypted
Type: password
Description: For internal use only
# This template is for D-I purposes and should allow
-# preseeding the user password with a MD5 hash rather than cleartext
-Template: passwd/user-password-hash
+# preseeding the user password with a crypted password rather than cleartext
+Template: passwd/user-password-crypted
Type: password
Description: For internal use only
More information about the Pkg-shadow-commits
mailing list