Module Name:    src
Committed By:   riz
Date:           Sun Feb 19 18:35:57 UTC 2012

Modified Files:
        src/usr.sbin/postinstall [netbsd-6]: postinstall

Log Message:
Pull up following revision(s) (requested by apb in ticket #9):
        usr.sbin/postinstall/postinstall: revision 1.130
Add "pwd_mkdb" item, which checks whether /etc/pwd.db is in the
new format, and runs "pwd_mkdb -V 1 /etc/master.passwd" to fix it.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.129.2.1 src/usr.sbin/postinstall/postinstall

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/postinstall/postinstall
diff -u src/usr.sbin/postinstall/postinstall:1.129 src/usr.sbin/postinstall/postinstall:1.129.2.1
--- src/usr.sbin/postinstall/postinstall:1.129	Wed Feb 15 13:01:00 2012
+++ src/usr.sbin/postinstall/postinstall	Sun Feb 19 18:35:55 2012
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.129 2012/02/15 13:01:00 joerg Exp $
+# $NetBSD: postinstall,v 1.129.2.1 2012/02/19 18:35:55 riz Exp $
 #
 # Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -53,10 +53,12 @@
 # This script is executed as part of a cross build.  Allow the build
 # environment to override the locations of some tools.
 : ${AWK:=awk}
+: ${DB:=db}
 : ${EGREP:=egrep}
 : ${FGREP:=fgrep}
 : ${GREP:=grep}
 : ${MAKE:=make}
+: ${PWD_MKDB:=/usr/sbin/pwd_mkdb}
 
 #
 #	helper functions
@@ -1107,6 +1109,43 @@ do_pf()
 }
 
 #
+#	pwd_mkdb
+#
+additem pwd_mkdb "passwd database version"
+do_pwd_mkdb()
+{
+	[ -n "$1" ] || err 3 "USAGE: do_pwd_mkdb  fix|check"
+	op="$1"
+	failed=0
+
+	# XXX Ideally, we should figure out the endianness of the
+	# target machine, and add "-E B"/"-E L" to the db(1) flags,
+	# and "-B"/"-L" to the pwd_mkdb(8) flags if the target is not
+	# the same as the host machine.  It probably doesn't matter,
+	# because we don't expect "postinstall fix pwd_mkdb" to be
+	# invoked during a cross build.
+
+	set -- $(${DB} -q -Sb -Ub -To -N hash ${DEST_DIR}/etc/pwd.db \
+		'VERSION\0')
+	case "$2" in
+	'\001\000\000\000') return 0 ;; # version 1, little-endian
+	'\000\000\000\001') return 0 ;; # version 1, big-endian
+	esac
+
+	if [ "${op}" = "check" ]; then
+		msg "Update format of passwd database"
+		failed=1
+	elif ! ${PWD_MKDB} -V 1 ${DEST_DIR}/etc/master.passwd; then
+		msg "Can't update format of passwd database"
+		failed=1
+	else
+		msg "Updated format of passwd database"
+	fi
+
+	return ${failed}
+}
+
+#
 #	rc
 #
 additem rc "/etc/rc* and /etc/rc.d/ being up to date"

Reply via email to