Added "ceoquery", a utility to retrieve lists of members and users.
authorMichael Spang <mspang@uwaterloo.ca>
Sat, 3 Feb 2007 02:45:24 +0000 (21:45 -0500)
committerMichael Spang <mike@freyr.utgard.net>
Sat, 3 Feb 2007 02:45:24 +0000 (21:45 -0500)
bin/ceoquery [new file with mode: 0755]
debian/postinst
debian/postrm
debian/rules

diff --git a/bin/ceoquery b/bin/ceoquery
new file mode 100755 (executable)
index 0000000..9da0dd7
--- /dev/null
@@ -0,0 +1,76 @@
+#!/usr/bin/python2.4 --
+"""
+ceoquery - a script to lookup member and account information
+"""
+import os, sys
+
+safe_environment = ['LOGNAME', 'USERNAME', 'USER', 'HOME', 'TERM', 'LANG'
+    'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MESSAGE', 'LC_MONETARY',
+    'LC_NUMERIC', 'LC_TIME', 'UID', 'GID', 'SSH_CONNECTION', 'SSH_AUTH_SOCK',
+    'SSH_CLIENT']
+
+for key in os.environ.keys():
+    if key not in safe_environment:
+        del os.environ[key]
+
+os.environ['PATH'] = '/bin:/usr/bin'
+
+for dir in sys.path[:]:
+    if not dir.find('/usr') == 0:
+        while dir in sys.path:
+            sys.path.remove(dir)
+
+from csc.adm import members, terms
+
+try:
+    members.connect()
+except Exception, e:
+    print "ceoquery: %s" % e
+    sys.exit(1)
+
+def usage():
+    print "Usage: ceoquery memberlist|booklist|allmembers|allusers|termusers"
+
+if len(sys.argv) < 2:
+    usage()
+
+elif sys.argv[1] == 'memberlist':
+    
+    current_term = terms.current()
+    members = members.list_term(current_term)
+    for member in members:
+        print "%(memberid)s|%(name)s|%(program)s|%(userid)s" % member
+
+elif sys.argv[1] == 'allmembers':
+
+    members = members.list_all()
+    for member in members:
+        print "%(memberid)s|%(name)s|%(program)s|%(userid)s" % member
+
+elif sys.argv[1] == 'booklist':
+
+    pass
+
+elif sys.argv[1] == 'allusers':
+
+    members = members.list_all()
+    for member in members:
+        if member['userid']:
+            print member['userid']
+
+elif sys.argv[1] == 'termusers':
+
+    if len(sys.argv) > 2:
+        term = sys.argv[2]
+    else:
+        term = terms.current()
+
+    members = members.list_term(term)
+    for member in members:
+        if member['userid']:
+            print member['userid']
+
+else:
+
+    usage()
+
index 0a28f7b..70ccce1 100644 (file)
@@ -6,9 +6,11 @@ case "$1" in
         if getent passwd ceo > /dev/null; then
             CEO=ceo
             SUID=4750
+            SUIDALL=4755
         else
             CEO=root
             SUID=755
+            SUIDALL=755
         fi
 
         if getent group office > /dev/null; then
@@ -25,6 +27,10 @@ case "$1" in
             dpkg-statoverride --add --update root $OFFICE $SUID /usr/bin/addhomedir
         fi
 
+        if ! dpkg-statoverride --list /usr/bin/ceoquery > /dev/null; then
+            dpkg-statoverride --add --update $CEO $OFFICE $SUIDALL /usr/bin/ceoquery
+        fi
+
         if [ -f /etc/csc/ldap.cf ] && ! dpkg-statoverride --list /etc/csc/ldap.cf > /dev/null; then
             dpkg-statoverride --add --update $CEO staff 640 /etc/csc/ldap.cf
         fi
index b5f7228..9a6b87c 100644 (file)
@@ -11,6 +11,10 @@ case "$1" in
             dpkg-statoverride --remove /usr/bin/addhomedir || true
         fi
 
+        if dpkg-statoverride --list /usr/bin/ceoquery > /dev/null; then
+            dpkg-statoverride --remove /usr/bin/ceoquery || true
+        fi
+
         if dpkg-statoverride --list /etc/csc/ldap.cf > /dev/null; then
             dpkg-statoverride --remove /etc/csc/ldap.cf || true
         fi
index 160348a..eb7c520 100755 (executable)
@@ -8,6 +8,7 @@ build-stamp:
        mkdir build
        $(CC) -DFULL_PATH='"/usr/lib/csc/ceo"' -o build/ceo misc/setuid-prog.c
        $(CC) -DFULL_PATH='"/usr/lib/csc/addhomedir"' -o build/addhomedir misc/setuid-prog.c
+       $(CC) -DFULL_PATH='"/usr/lib/csc/ceoquery"' -o build/ceoquery misc/setuid-prog.c
        touch build-stamp
 
 clean:
@@ -28,8 +29,8 @@ install: build
        dh_install etc/* etc/csc/
        dh_install sql/* usr/share/csc/
        
-       dh_install bin/ceo bin/addhomedir usr/lib/csc/
-       dh_install build/ceo build/addhomedir usr/bin/
+       dh_install bin/ceo bin/addhomedir bin/ceoquery usr/lib/csc/
+       dh_install build/ceo build/addhomedir build/ceoquery usr/bin/
        
 binary-arch: build install
        dh_testdir