Add support for sha1 hashing method
[snf-image] / snf-image-helper / tasks / 50ChangePassword.in
index f152e5a..46d1ab0 100644 (file)
@@ -103,9 +103,12 @@ unix_password() {
         linux|freebsd)
             hash=$("@scriptsdir@/snf-passtohash.py" "$password")
             ;;
-        openbsd|netbsd)
+        openbsd)
             hash=$("@scriptsdir@/snf-passtohash.py" -m blowfish "$password")
             ;;
+        netbsd)
+            hash=$("@scriptsdir@/snf-passtohash.py" -m sha1 "$password")
+            ;;
         *)
             log_error "Unknown unix flavor: \`$flavor'"
             ;;
@@ -173,10 +176,19 @@ else
     unix_password "$SNF_IMAGE_PROPERTY_OSFAMILY" "$SNF_IMAGE_TARGET" "$SNF_IMAGE_PASSWORD"
 fi
 
-# For FreeBSD, OpenBSD and NetBSD we need to recreate the password database too
+# For FreeBSD, OpenBSD and NetBSD we need to recreate the password databases too
 if [[ "$SNF_IMAGE_PROPERTY_OSFAMILY" == *bsd ]]; then
     rm -f "$SNF_IMAGE_TARGET/etc/spwd.db"
 
+    # NetBSD is very strict about the existence & non-existence of the db files
+    if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "netbsd" ]; then
+        rm -f "$SNF_IMAGE_TARGET/etc/pwd.db.tmp"
+        rm -f "$SNF_IMAGE_TARGET/etc/spwd.db.tmp"
+
+        touch "$SNF_IMAGE_TARGET/etc/spwd.db"
+    fi
+
+
     # Make sure /etc/spwd.db is recreated on first boot
     rc_local=$(cat <<EOF
 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin