Module Name: src Committed By: christos Date: Tue Jun 11 14:39:07 UTC 2013
Modified Files: src/usr.sbin/postinstall: postinstall Log Message: more thorough passwd/group checks. To generate a diff of this commit: cvs rdiff -u -r1.151 -r1.152 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.151 src/usr.sbin/postinstall/postinstall:1.152 --- src/usr.sbin/postinstall/postinstall:1.151 Mon Jun 10 16:33:31 2013 +++ src/usr.sbin/postinstall/postinstall Tue Jun 11 10:39:07 2013 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: postinstall,v 1.151 2013/06/10 20:33:31 mrg Exp $ +# $NetBSD: postinstall,v 1.152 2013/06/11 14:39:07 christos Exp $ # # Copyright (c) 2002-2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -172,17 +172,18 @@ check_dir() return 0 } -# check_ids op type file id [...] +# check_ids op type file start id [...] # Check if file of type "users" or "groups" contains the relevant IDs # Returns 0 if ok, 1 otherwise. # check_ids() { - [ $# -ge 4 ] || err 3 "USAGE: checks_ids op type file id [...]" + [ $# -ge 5 ] || err 3 "USAGE: checks_ids op type file start id [...]" _op="$1" _type="$2" _file="$3" - shift 3 + _start="$4" + shift 4 #_ids="$@" if [ ! -f "${_file}" ]; then @@ -197,24 +198,33 @@ check_ids() if [ "${_op}" = "fix" ]; then _notfixed="${NOT_FIXED}" fi - _missing="$(${AWK} -F: ' + _missing="$(${AWK} -v start=$_start -F: ' BEGIN { - for (x = 1; x < ARGC; x++) + for (x = 1; x < ARGC; x++) { + if (ARGV[x] = "SKIP") + continue; idlist[ARGV[x]]++ + value[ARGV[x]] = start + x - 1; + } ARGC=1 } { found[$1]++ + number[$1] = $3 } END { for (id in idlist) { - if (! (id in found)) - print id + if (!(id in found)) + printf("%s (missing)\n", id) + else if (number[id] != value[id]) + printf("%s (%d != %d)\n", id, + number[id], value[id]) + start++; } } ' "$@" < "${_file}")" || return 1 if [ -n "${_missing}" ]; then - msg "Missing ${_type}${_notfixed}:" $(echo ${_missing}) + msg "Error ${_type}${_notfixed}:" $(echo ${_missing}) return 1 fi return 0 @@ -897,8 +907,8 @@ do_gid() { [ -n "$1" ] || err 3 "USAGE: do_gid fix|check" - check_ids "$1" groups "${DEST_DIR}/etc/group" \ - named ntpd sshd authpf _pflogd _rwhod _proxy _timedc \ + check_ids "$1" groups "${DEST_DIR}/etc/group" 14 \ + named ntpd sshd _pflogd _rwhod staff _proxy _timedc \ _sdpd _httpd _mdnsd _tests _tcpdump _tss _gpio } @@ -1573,8 +1583,8 @@ do_uid() { [ -n "$1" ] || err 3 "USAGE: do_uid fix|check" - check_ids "$1" users "${DEST_DIR}/etc/master.passwd" \ - named ntpd postfix sshd _pflogd _rwhod _proxy _timedc \ + check_ids "$1" users "${DEST_DIR}/etc/master.passwd" 12 \ + postfix named ntpd sshd SKIP _pflogd _rwhod SKIP _proxy _timedc \ _sdpd _httpd _mdnsd _tests _tcpdump _tss }