* Use "not in" operator in various places ("foo not in bar" instead of "not
foo in bar").
* ud-mailgate: use subprocess.Popen instead of os.popen.
+ * Use "foo is None" instead of "foo == None".
-- Peter Palfrader <weasel@debian.org> Sat, 06 Apr 2019 22:04:34 +0200
if Line != "":
# Glob similar lines
Split = re.split("[:\n]",Line);
- if User == None:
+ if User is None:
User = Split[0];
if Split[0] == User:
Set.append(Split[1].strip());
# Try to guess the name from the email address
def TryMatcher(mail):
Sender = mail["From"];
- if Sender == None:
+ if Sender is None:
return None;
# Split up the address and invoke the matcher routine
UID = GetUID(l,SplitEmail(Sender));
- if UID[0] == None:
- if UID[1] == None or len(UID[1]) == 0:
+ if UID[0] is None:
+ if UID[1] is None or len(UID[1]) == 0:
return None;
# Print out an error message
Debug = "";
# Open the log files
-if Debug == None:
+if Debug is None:
MainLog = open(Ech_MainLog,"a+",0);
ErrLog = open(Ech_ErrorLog,"a+",0);
else:
ErrMsg = "An error occured while performing the LDAP lookup";
global l;
l = connectLDAP()
- if Debug == None:
+ if Debug is None:
F = open(PassDir+"/pass-"+pwd.getpwuid(os.getuid())[0],"r");
AccessPass = F.readline().strip().split(" ")
l.simple_bind_s("uid="+AccessPass[0]+","+BaseDn,AccessPass[1]);
ErrType = EX_TEMPFAIL;
ErrMsg = "An error occured while trying GPG decoding";
User = TryGPG(mail);
- if User == None:
+ if User is None:
ErrMsg = "An error occured while trying Matcher decoding";
User = TryMatcher(mail);
MainLog.write("%s %s %s\n"%(User[0],User[1],Msg));
Dn = "uid=" + User[0] + "," + BaseDn;
Rec = [(ldap.MOD_REPLACE,"activity-%s"%(User[1]),Msg)];
- if Debug == None:
+ if Debug is None:
l.modify_s(Dn,Rec);
else:
print Rec;
if FingerPrint != None and UID != None:
for x in Emails:
Match = AddressSplit.match(x);
- if Match == None:
+ if Match is None:
continue;
Groups = Match.groups();
Email = Groups[1]+'@'+Groups[2];
if File == "":
break;
- # Attempt to determine the UID
+ # Attempt to determine the UID
try:
User = pwd.getpwuid(os.stat(File)[stat.ST_UID])[0];
except KeyError:
break;
if Line2[0] == '#' or Line2[0] == '\n':
continue;
- if Line == None:
+ if Line is None:
Line = Line2;
else:
break;
# If we got more than one line or no lines at all it is invalid
- if Line == None or Line == "" or Line2 != "":
+ if Line is None or Line == "" or Line2 != "":
print "Invalid1", File;
continue;
# Split off the address part
Address = AddressSplit.match(Line);
- if Address == None:
+ if Address is None:
# Or parse a qmail adddress..
Address = Line;
if Address[0] == '&':
if 'sudoPassword' in a:
for entry in a['sudoPassword']:
Match = re.compile('^('+UUID_FORMAT+') (confirmed:[0-9a-f]{40}|unconfirmed) ([a-z0-9.,*-]+) ([^ ]+)$').match(entry)
- if Match == None:
+ if Match is None:
continue
uuid = Match.group(1)
status = Match.group(2)
Algorithm = 2
if key_prefix == 'ssh-ed25519':
Algorithm = 4
- if Algorithm == None:
+ if Algorithm is None:
continue
# and more from the registry
sshfp_digest_codepoints = [ (1, 'sha1'), (2, 'sha256') ]
"mXRecord", "ipHostNumber", "dnsTTL", "machine", "architecture",
"sshfpHostname"])
- if HostAttrs == None:
+ if HostAttrs is None:
raise UDEmptyList, "No Hosts"
HostAttrs.sort(lambda x, y: cmp((GetAttr(x, "hostname")).lower(), (GetAttr(y, "hostname")).lower()))
continue;
UID = GetUID(l,SplitEmail(pgp_uid),UnknownMap);
- if UID[0] == None:
+ if UID[0] is None:
print "Unassigned key in keyrings: %s, belonging to %s"%(fpr, pgp_uid)
if UID[1] != None:
for x in UID[1]: print x;
break;
if Line[0] == '#' or Line[0] == '\n':
continue;
- if SSHAuthSplit.match(Line) == None:
+ if SSHAuthSplit.match(Line) is None:
print "Bad line", File;
else:
Lines.append(Line);
cn = GetAttr(Attrs[0],"cn");
sn = GetAttr(Attrs[0],"sn");
mn = GetAttr(Attrs[0],"mn");
- if privsub == None or privsub == "":
+ if privsub is None or privsub == "":
privsub = " ";
break;
else:
CryptedPass = GPGEncrypt("Your new password is '" + Password + "'\n",\
"0x"+Keys[0][1],UsePGP2);
Password = None;
- if CryptedPass == None:
+ if CryptedPass is None:
raise "Error","Password Encryption failed"
else:
Pass = HashPass(Password);
if Res[0] != None:
raise Error, Res[0];
- if Res[3] == None:
+ if Res[3] is None:
raise Error, "Null signature text";
# Extract the plain message text in the event of mime encoding
ErrType = EX_PERMFAIL;
ErrMsg = "A problem occured while trying to formulate the reply";
Sender = Email.getheader("Reply-To");
- if Sender == None:
+ if Sender is None:
Sender = Email.getheader("From");
- if Sender == None:
+ if Sender is None:
raise Error, "Unable to determine the sender's address";
# Setup the environment
# Good signature response
if Split[1] == "GOODSIG":
# Just in case GPG returned a bad signal before this (bug?)
- if Why == None:
+ if Why is None:
GoodSig = 1;
KeyID = Split[2];
Owner = ' '.join(Split[3:])
Text = Res[2].read();
# A gpg failure is an automatic bad signature
- if Exit[1] != 0 and Why == None:
+ if Exit[1] != 0 and Why is None:
GoodSig = 0;
Why = "GPG execution returned non-zero exit status: " + str(Exit[1]);
- if GoodSig == 0 and (Why == None or len(Why) == 0):
+ if GoodSig == 0 and (Why is None or len(Why) == 0):
Why = "Checking Failed";
# Try to decide if this message was sent using PGP2
# Check a signature. 'sig' is a 3 tuple that has the sigId, date and
# key ID
def Check(self,Sig):
- if Sig[0] == None or Sig[1] == None or Sig[2] == None:
+ if Sig[0] is None or Sig[1] is None or Sig[2] is None:
return "Invalid signature";
if int(Sig[1]) > time.time() + self.FutureCutOff:
return "Signature has a time too far in the future";
# Add a signature, the sig is the same as is given to Check
def Add(self,Sig):
- if Sig[0] == None or Sig[1] == None:
+ if Sig[0] is None or Sig[1] is None:
raise RuntimeError,"Invalid signature";
if Sig[1] < time.time() - self.CleanCutOff:
return;