Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/postinstall Add "pwd_mkdb" item, which checks wheth...



details:   https://anonhg.NetBSD.org/src/rev/afd426b79548
branches:  trunk
changeset: 777386:afd426b79548
user:      apb <apb%NetBSD.org@localhost>
date:      Fri Feb 17 07:51:20 2012 +0000

description:
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.

diffstat:

 usr.sbin/postinstall/postinstall |  41 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 40 insertions(+), 1 deletions(-)

diffs (68 lines):

diff -r be88d953afc9 -r afd426b79548 usr.sbin/postinstall/postinstall
--- a/usr.sbin/postinstall/postinstall  Fri Feb 17 07:46:54 2012 +0000
+++ b/usr.sbin/postinstall/postinstall  Fri Feb 17 07:51:20 2012 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.129 2012/02/15 13:01:00 joerg Exp $
+# $NetBSD: postinstall,v 1.130 2012/02/17 07:51:20 apb 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 @@
 }
 
 #
+#      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"



Home | Main Index | Thread Index | Old Index