source: trunk/locker/sbin/check-users @ 1497

Last change on this file since 1497 was 981, checked in by andersk, 14 years ago
Script for finding deactivated users and other inconsistencies.
  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#!/bin/bash
2set -e
3
4err() {
5    echo "$@"
6}
7
8if [ -z "$1" ]; then
9    filter="objectClass=posixAccount"
10else
11    filter=
12    for user; do
13        filter="$filter(uid=$user)"
14    done
15    filter="(&(objectClass=posixAccount)(|$filter))"
16fi
17
18unset "${!l_@}"
19while read attr value; do
20    if [ -n "$attr" ]; then
21        declare "l_${attr%:}=$value"
22        continue
23    fi
24
25    read f_type f_data < <(hesinfo "$l_uid" filsys) || :
26    if [ -z "$f_type" ]; then
27        err "$l_uid" "no_hesiod"
28    elif [ "$f_type" = "ERR" ]; then
29        err "$l_uid" "hesiod_err ERR $f_data"
30    elif [ "$f_type" = "AFS" ]; then
31        read f_path f_perm f_link z \
32            < <(echo "$f_data")
33        [ "$l_homeDirectory" = "$f_path" ] || \
34            err "$l_uid" "hesiod_path $f_path"
35    else
36        err "$l_uid" "wrong_hesiod $f_type"
37    fi
38
39    IFS=/ read p_empty p_top p_cell p \
40        < <(echo "$l_homeDirectory")
41    [ -z "${p_empty}" ] || \
42        err "$l_uid" "relative_home $l_homeDirectory"
43    [ "${p_top}" = "afs" ] || \
44        err "$l_uid" "not_afs $l_homeDirectory"
45
46    read v_vname v_vol v \
47        < <(vos exa -noauth "$l_uidNumber" -cell "$p_cell" 2>/dev/null) || :
48    [ "$v_vol" = "$l_uidNumber" ] ||
49        err "$l_uid" "no_vol $l_uidNumber"
50
51    if ! [ -d "$l_homeDirectory" ]; then
52        if ! [ -e "$l_homeDirectory" ]; then
53            err "$l_uid" "deleted $l_homeDirectory"
54        else
55            err "$l_uid" "not_dir $l_homeDirectory"
56        fi
57    else
58        read c c_path c c c c_cell \
59            < <(fs whichcell "$l_homeDirectory" 2>/dev/null) || :
60        [ "$c_path" = "$l_homeDirectory" ] || \
61            err "$l_uid" "no_cell $l_homeDirectory"
62        [ "$c_cell" = "'$p_cell'" ] || \
63            err "$l_uid" "wrong_cell $l_homeDirectory"
64
65        read m_path m m m m m m m_vname \
66            < <(fs lsmount "$l_homeDirectory" 2>/dev/null) || :
67        [ "$m_path" = "'$l_homeDirectory'" ] || \
68            err "$l_uid" "no_mount $l_homeDirectory"
69        [ "$m_vname" = "'#$v_vname'" ] || [ "$m_vname" = "'%$v_vname'" ] || \
70            err "$l_uid" "wrong_mount $m_vname ($l_uidNumber = $v_vname)"
71    fi
72
73    unset "${!l_@}"
74done < <(
75    ldapsearch -LLL -x -D 'cn=Directory Manager' -y /etc/signup-ldap-pw \
76        -b ou=People,dc=scripts,dc=mit,dc=edu "$filter" \
77        uid uidNumber homeDirectory loginShell | \
78        perl -0pe 's/\n //g;'
79    )
Note: See TracBrowser for help on using the repository browser.