chpwd, operation.py: Allow administrative override of policy.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 22 Dec 2014 20:32:58 +0000 (20:32 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 7 Apr 2015 18:54:56 +0000 (19:54 +0100)
chpwd
operation.py

diff --git a/chpwd b/chpwd
index 0e0de39..2d6c75c 100755 (executable)
--- a/chpwd
+++ b/chpwd
@@ -76,6 +76,9 @@ for short, long, props in [
     'default': ENV.get('CHPWD_CONFIG',
                        OS.path.join(HOME, 'chpwd.conf')),
     'help': 'read configuration from FILE.' }),
+  ('-i', '--ignore-policy', {
+    'dest': 'ignpol', 'default': False, 'action': 'store_true',
+    'help': 'ignore the operation policy (for administrators)' }),
   ('-s', '--ssl', {
     'dest': 'sslp', 'action': 'store_true',
     'help': 'pretend CGI connection is carried over SSL/TLS' }),
index bf17b05..fccd172 100644 (file)
@@ -343,14 +343,15 @@ def operate(op, accts, *args, **kw):
   """
   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
+  if not CFG.OPTS.ignpol:
+    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: