Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/postinstall more thorough passwd/group checks.



details:   https://anonhg.NetBSD.org/src/rev/1954461f46a1
branches:  trunk
changeset: 787331:1954461f46a1
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jun 11 14:39:07 2013 +0000

description:
more thorough passwd/group checks.

diffstat:

 usr.sbin/postinstall/postinstall |  36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diffs (94 lines):

diff -r 0885258790b9 -r 1954461f46a1 usr.sbin/postinstall/postinstall
--- a/usr.sbin/postinstall/postinstall  Tue Jun 11 13:30:20 2013 +0000
+++ b/usr.sbin/postinstall/postinstall  Tue Jun 11 14:39:07 2013 +0000
@@ -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 @@
        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 @@
        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 @@
 {
        [ -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 @@
 {
        [ -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
 }
 



Home | Main Index | Thread Index | Old Index