1 | #!/bin/bash |
---|
2 | set -eu |
---|
3 | |
---|
4 | err() { |
---|
5 | ok= |
---|
6 | echo "$@" |
---|
7 | } |
---|
8 | |
---|
9 | if [ $# -eq 0 ]; then |
---|
10 | filter="objectClass=posixAccount" |
---|
11 | else |
---|
12 | filter= |
---|
13 | for user; do |
---|
14 | filter="$filter(uid=$user)" |
---|
15 | done |
---|
16 | filter="(&(objectClass=posixAccount)(|$filter))" |
---|
17 | fi |
---|
18 | |
---|
19 | unset "${!l_@}" |
---|
20 | while read attr value; do |
---|
21 | ok=t |
---|
22 | if [ -n "$attr" ]; then |
---|
23 | declare "l_${attr%:}=$value" |
---|
24 | continue |
---|
25 | fi |
---|
26 | |
---|
27 | read f_type f_data < <(hesinfo -- "$l_uid" filsys | sort -nk5,5) || : |
---|
28 | if [ -z "$f_type" ]; then |
---|
29 | err "$l_uid" "no_hesiod" |
---|
30 | elif [ "$f_type" = "ERR" ]; then |
---|
31 | err "$l_uid" "hesiod_err ERR $f_data" |
---|
32 | elif [ "$f_type" = "AFS" ]; then |
---|
33 | read f_path f_perm f_link z \ |
---|
34 | < <(echo "$f_data") |
---|
35 | [ "${l_homeDirectory#/disabled}" = "$f_path" ] || \ |
---|
36 | err "$l_uid" "hesiod_path $f_path (LDAP $l_homeDirectory)" |
---|
37 | else |
---|
38 | err "$l_uid" "wrong_hesiod $f_type" |
---|
39 | fi |
---|
40 | |
---|
41 | p_cell= |
---|
42 | case "$l_homeDirectory" in |
---|
43 | /afs/*) |
---|
44 | p_cell="${l_homeDirectory#/afs/}" |
---|
45 | p_cell="${p_cell%%/*}" |
---|
46 | ;; |
---|
47 | /disabled/afs/*) |
---|
48 | err "$l_uid" "disabled $l_homeDirectory" |
---|
49 | l_homeDirectory="${l_homeDirectory#/disabled}" |
---|
50 | p_cell="${l_homeDirectory#/afs/}" |
---|
51 | p_cell="${p_cell%%/*}" |
---|
52 | ;; |
---|
53 | /*) |
---|
54 | err "$l_uid" "not_afs $l_homeDirectory" |
---|
55 | ;; |
---|
56 | *) |
---|
57 | err "$l_uid" "relative_home $l_homeDirectory" |
---|
58 | ;; |
---|
59 | esac |
---|
60 | |
---|
61 | read v_vname v_vol v \ |
---|
62 | < <(vos examine -noauth -id "$l_uidNumber" -cell "${p_cell#.}" 2>/dev/null) || : |
---|
63 | [ "$v_vol" = "$l_uidNumber" ] || |
---|
64 | err "$l_uid" "no_vol ${p_cell#.} $l_uidNumber" |
---|
65 | |
---|
66 | if ! [ -d "$l_homeDirectory" ]; then |
---|
67 | if ! [ -e "$l_homeDirectory" ]; then |
---|
68 | err "$l_uid" "no_home $l_homeDirectory" |
---|
69 | else |
---|
70 | err "$l_uid" "not_dir $l_homeDirectory" |
---|
71 | fi |
---|
72 | else |
---|
73 | read c c_path c c c c_cell \ |
---|
74 | < <(fs whichcell -path "$l_homeDirectory" 2>/dev/null) || : |
---|
75 | [ "$c_path" = "$l_homeDirectory" ] || \ |
---|
76 | err "$l_uid" "no_cell $l_homeDirectory" |
---|
77 | [ "$c_cell" = "'${p_cell#.}'" ] || \ |
---|
78 | err "$l_uid" "wrong_cell $p_cell $l_homeDirectory $c_cell" |
---|
79 | |
---|
80 | read m_path m m m m m m m_vname \ |
---|
81 | < <(fs lsmount -dir "$l_homeDirectory" 2>/dev/null) || : |
---|
82 | [ "$m_path" = "'$l_homeDirectory'" ] || \ |
---|
83 | err "$l_uid" "no_mount $l_homeDirectory" |
---|
84 | |
---|
85 | case "$m_vname" in |
---|
86 | "'#$v_vname'" | "'%$v_vname'" | "'#${p_cell#.}:$v_vname'" | "'%{p_cell#.}:$v_vname'") |
---|
87 | ;; |
---|
88 | *) |
---|
89 | m_vname2="${m_vname#\'[#%]}" |
---|
90 | m_vname2="${m_vname2%\'}" |
---|
91 | m_cell="${m_vname2%%:*}" |
---|
92 | [ "$m_cell" != "$m_vname2" ] || m_cell="${p_cell#.}" |
---|
93 | m_vname2="${m_vname2#*:}" |
---|
94 | read m_vname2 m_vol m \ |
---|
95 | < <(vos examine -noauth -id "$m_vname2" -cell "$m_cell" 2>/dev/null) || : |
---|
96 | err "$l_uid" "wrong_mount ${m_cell} $m_vname = $m_vol (${p_cell#.} $l_uidNumber = $v_vname)" |
---|
97 | ;; |
---|
98 | esac |
---|
99 | fi |
---|
100 | |
---|
101 | if [ "$ok" = t ]; then |
---|
102 | err "$l_uid" "ok" |
---|
103 | fi |
---|
104 | |
---|
105 | unset "${!l_@}" |
---|
106 | done < <( |
---|
107 | ldapsearch -LLL -x -D 'cn=Directory Manager' -y /etc/signup-ldap-pw \ |
---|
108 | -b ou=People,dc=scripts,dc=mit,dc=edu "$filter" \ |
---|
109 | uid uidNumber homeDirectory loginShell | \ |
---|
110 | perl -0pe 's/\n //g;' |
---|
111 | ) |
---|