classify-users: determine type of Athena accounts
[user/alex/software/my-snippets.git] / lists-lint
1 #!/bin/bash
2 # Alex Dehnert --- 2009-04-24, 2009-06-27, and later
3 # Check the ownership and other properties of various mailing lists
4 # Takes a list-of-lists and allowed owners on the commandline
5
6 cont=$1
7 #ownerslist=$2
8 publicpat=${3:-"-listeners$"}
9
10 #owners=$(blanche $ownerslist -m | grep LIST | cut -d : -f 2)
11 owners=$2
12 echo Allowed owners: $owners
13 owners="GUARD $owners GUARD"
14
15 for list in $(blanche $cont | grep LIST | cut -d : -f 2); do
16     hidden=$(athrun ops qy -s -f hidden glin $list)
17     if [[ "x$hidden" == "x" ]]; then
18         echo $list is probably hidden
19     else
20     if [[ "$hidden" == 1 ]]; then
21         echo $list is definitely hidden, but I can see it, so continuing
22     fi
23     info=$(blanche $list -i)
24     public=$(athrun ops qy -s -f publicflg glin $list)
25     owner=$(athrun ops qy -s -f ace_name glin $list)
26     towner=$(athrun ops qy -s -f ace_type glin $list)
27     macl=$(athrun ops qy -s -f memace_name glin $list)
28     tmacl=$(athrun ops qy -s -f memace_type glin $list)
29     if [[ "$towner" == "USER" ]]; then
30         echo "$list is owned by a user ($owner)"
31     elif [[ "$tmacl" == "USER" ]]; then
32         echo "$list is memacl'd by a user ($macl)"
33     elif [[ "$towner" == "KERBEROS" || "$tmacl" == "KERBEROS" ]]; then
34         echo "$list is owned or memacl'd by a Kerberos principal"
35     elif [[ "$towner" == "LIST" && ( "$tmacl" == "LIST" || "$tmacl" == "NONE" ) ]]; then
36         true
37     else
38         echo "$list is owned or memacl'd by something funky"
39     fi
40     if [[ "$towner" == "LIST" ]]; then
41         if [[ "$owner" == "GUARD" ]]; then
42             echo "$list owned by GUARD, which shouldn't even exist"
43         elif ( echo $owners | grep -q -- " $owner " ); then
44             # Owned by standard owner
45             true
46         elif [[ "$owner" == "$list-chairs" || "$owner" == "$list-request" ]]; then
47             # Chair / request owned
48             true
49         #elif ( echo "$list" | sed -e 's/-\(listeners\|members\)$/-chairs/' | grep -q --fixed-strings --line-regexp -- "$owner" ); then
50         #    # Chair owned, for a listeners/members structure
51         #    true
52         else
53             echo $list owned by $owner, not one of the allowed owners
54         fi
55     fi
56     if [[ "$public" == "1" ]]; then
57         if ( echo $list | grep -q -- "$publicpat" ); then
58             # We're allowed to be public
59             true
60         else
61             echo $list is public
62         fi
63     fi
64     fi # hidden heuristic end
65 done