Probably about time we did this, really.
import os as OS; ENV = OS.environ
import shlex as SL
import sys as SYS
import os as OS; ENV = OS.environ
import shlex as SL
import sys as SYS
from auto import HOME, VERSION
import cgi as CGI
from auto import HOME, VERSION
import cgi as CGI
if __name__ == '__main__':
if __name__ == '__main__':
+ L.openlog(OS.path.basename(SYS.argv[0]), 0, L.LOG_AUTH)
+
if 'REQUEST_METHOD' in ENV:
## This looks like a CGI request. The heavy lifting for authentication
## over HTTP is done in `dispatch_cgi'.
if 'REQUEST_METHOD' in ENV:
## This looks like a CGI request. The heavy lifting for authentication
## over HTTP is done in `dispatch_cgi'.
### <http://www.gnu.org/licenses/>.
import os as OS
### <http://www.gnu.org/licenses/>.
import os as OS
import config as CONF; CFG = CONF.CFG
import util as U
import config as CONF; CFG = CONF.CFG
import util as U
"""
return optype(svc, user, **kw)
"""
return optype(svc, user, **kw)
+ def describe(me):
+ return me.OP
+
def perform(me):
"""
Perform the queued-up operations.
def perform(me):
"""
Perform the queued-up operations.
* a list of the individual operation objects.
"""
rq = getattr(CFG.RQCLASS, op)(accts, *args, **kw)
* a list of the individual operation objects.
"""
rq = getattr(CFG.RQCLASS, op)(accts, *args, **kw)
+ desc = rq.describe()
+ try:
+ rq.check()
+ except U.ExpectedError, e:
+ L.syslog('REFUSE %s %s: %s' %
+ (desc,
+ ', '.join(['%s@%s' % (o.user, o.svc.name) for o in rq.ops]),
+ e))
+ raise
ops = rq.perform()
nwin = nlose = 0
for o in ops:
ops = rq.perform()
nwin = nlose = 0
for o in ops:
else:
if nlose: rc = outcome.FAIL
else: rc = outcome.NOTHING
else:
if nlose: rc = outcome.FAIL
else: rc = outcome.NOTHING
+ L.syslog('%s %s: %s' % (['OK', 'PARTIAL', 'FAIL', 'NOTHING'][rc],
+ desc,
+ '; '.join(['%s@%s %s' % (o.user, o.svc.name,
+ not o.error and 'OK' or
+ 'ERR %s' % o.error)
+ for o in ops])))
ii = [info(v, getattr(rq, k)) for k, v in rq.INFO.iteritems()]
return outcome(rc, nwin, nlose), ii, rq, ops
ii = [info(v, getattr(rq, k)) for k, v in rq.INFO.iteritems()]
return outcome(rc, nwin, nlose), ii, rq, ops