mailWhitelist = {}
SeenList = {}
DNS = {}
-SudoPasswd = {}
ValidHostNames = [] # will be initialized in later
SSHFingerprint = re.compile('^(\d+) ([0-9a-f\:]{47}) (.+)$')
return "%s replaced with %s" % (Key,Host)
# Handle a ConfirmSudoPassword request
-def DoConfirmSudopassword(Str):
- Match = re.compile('^confirm sudopassword ('+UUID_FORMAT+') ([a-z0-9.,*]+) ([0-9a-f]{40})$').match(Str)
+def DoConfirmSudopassword(Str, SudoPasswd):
+ Match = re.compile('^confirm sudopassword ('+UUID_FORMAT+') ([a-z0-9.,*-]+) ([0-9a-f]{40})$').match(Str)
if Match == None:
return None
hosts = Match.group(2)
hmac = Match.group(3)
- global SudoPasswd
SudoPasswd[uuid] = (hosts, hmac)
return "got confirm for sudo password %s on host(s) %s, auth code %s" % (uuid,hosts, hmac)
-def FinishConfirmSudopassword(l, uid, Attrs):
- global SudoPasswd
+def FinishConfirmSudopassword(l, uid, Attrs, SudoPasswd):
result = "\n"
if len(SudoPasswd) == 0:
newldap = []
for entry in inldap:
- Match = re.compile('^('+UUID_FORMAT+') (confirmed:[0-9a-f]{40}|unconfirmed) ([a-z0-9.,*]+) ([^ ]+)$').match(entry)
+ Match = re.compile('^('+UUID_FORMAT+') (confirmed:[0-9a-f]{40}|unconfirmed) ([a-z0-9.,*-]+) ([^ ]+)$').match(entry)
if Match == None:
raise UDFormatError, "Could not parse existing sudopasswd entry"
uuid = Match.group(1)
Result = "";
Attrs = [];
+ SudoPasswd = {}
Show = 0;
CommitChanges = 1
for Line in Lines:
badkeys = LoadBadSSH()
Res = DoPosition(Line,Attrs) or DoDNS(Line,Attrs,DnRecord) or \
DoArbChange(Line,Attrs) or DoSSH(Line,Attrs,badkeys,GetAttr(DnRecord,"uid")) or \
- DoDel(Line,Attrs) or DoRBL(Line,Attrs) or DoConfirmSudopassword(Line)
+ DoDel(Line,Attrs) or DoRBL(Line,Attrs) or DoConfirmSudopassword(Line, SudoPasswd)
except:
Res = None;
Result = Result + "==> %s: %s\n" %(sys.exc_type,sys.exc_value);
# Connect to the ldap server
l = connect_to_ldap_and_check_if_locked(DnRecord)
- if CommitChanges == 1 and len(Attrs) > 0: # only if we are still good to go
+ if CommitChanges == 1 and len(SudoPasswd) > 0: # only if we are still good to go
try:
- Res = FinishConfirmSudopassword(l, GetAttr(DnRecord,"uid"), Attrs)
+ Res = FinishConfirmSudopassword(l, GetAttr(DnRecord,"uid"), Attrs, SudoPasswd)
if not Res is None:
Result = Result + Res + "\n";
except Error, e: