foo in bar").
* ud-mailgate: use subprocess.Popen instead of os.popen.
* Use "foo is None" instead of "foo == None".
+ * Use "foo is not None" instead of "foo != None".
-- Peter Palfrader <weasel@debian.org> Sat, 06 Apr 2019 22:04:34 +0200
# See if the group membership is OK
# Only if a group was given on the commandline
- if GroupMember != None:
+ if GroupMember is not None:
Hit = 0;
# Check primary group first
if GAttr[0][1]["gid"][0] == GroupMember:
try:
# Startup the replay cache
ErrType = EX_TEMPFAIL;
- if ReplayCacheFile != None:
+ if ReplayCacheFile is not None:
ErrMsg = "Failed to initialize the replay cache:";
RC = ReplayCache(ReplayCacheFile);
raise UDFormatError, "Null signature text"
# Check the signature against the replay cache
- if ReplayCacheFile != None:
+ if ReplayCacheFile is not None:
RC.process(pgp.sig_info)
# Do LDAP stuff
- if LDAPDn != None:
+ if LDAPDn is not None:
CheckLDAP(pgp.key_fpr)
ErrMsg = "Verifying message:";
- if Phrases != None:
+ if Phrases is not None:
F = open(Phrases,"r");
while 1:
Line = F.readline();
if not List: List = "-";
# Tada, write a log message
- if User != None:
+ if User is not None:
Msg = "[%s] \"%s\" \"%s\" \"%s\""%(Now,User[2],List,MsgID);
MainLog.write("%s %s %s\n"%(User[0],User[1],Msg));
Dn = "uid=" + User[0] + "," + BaseDn;
Split = Line.split(":")
if len(Split) >= 8 and Split[0] == "pub":
- if FingerPrint != None and UID != None:
+ if FingerPrint is not None and UID is not None:
for x in Emails:
Match = AddressSplit.match(x);
if Match is None:
return False
def Die(File, F, Fdb):
- if F != None:
+ if F is not None:
F.close()
- if Fdb != None:
+ if Fdb is not None:
Fdb.close()
try:
os.remove(File + ".tmp")
pass
def Done(File, F, Fdb):
- if F != None:
+ if F is not None:
F.close()
os.rename(File + ".tmp", File)
- if Fdb != None:
+ if Fdb is not None:
Fdb.close()
os.rename(File + ".tdb.tmp", File + ".tdb")
F.write(Line)
Host = Split[0] + DNSZone
- if BSMTPCheck.match(Line) != None:
+ if BSMTPCheck.match(Line) is not None:
F.write("; Has BSMTP\n")
# Write some identification information
Line = " ".join(Split) + "\n"
Host = Split[0] + DNSZone
- if BSMTPCheck.match(Line) != None:
+ if BSMTPCheck.match(Line) is not None:
F.write("%s: user=%s group=Debian file=%s%s/bsmtp/%s\n"%(Host,
a['uid'], HomePrefix, a['uid'], Host))
continue
keys[fingerprint] = pgp_uid
- if Keys.close() != None:
+ if Keys.close() is not None:
raise "Error","GPG failed"
return keys
UID = GetUID(l,SplitEmail(pgp_uid),UnknownMap);
if UID[0] is None:
print "Unassigned key in keyrings: %s, belonging to %s"%(fpr, pgp_uid)
- if UID[1] != None:
+ if UID[1] is not None:
for x in UID[1]: print x;
print "MISSING " + fpr;
continue;
(ldap.MOD_REPLACE,"shadowExpire","")];
if privsub != " ":
Rec.append((ldap.MOD_REPLACE,"privateSub",privsub));
- if Pass != None:
+ if Pass is not None:
Rec.append((ldap.MOD_REPLACE,"userPassword","{crypt}"+Pass));
# Do it
l.modify_s(Dn,Rec);
Child = os.popen("/usr/sbin/sendmail -t","w");
#Child = os.popen("cat","w");
Child.write(Reply);
-if Child.close() != None:
+if Child.close() is not None:
raise Error, "Sendmail gave a non-zero return code";
# vim:set et:
try:
# Startup the replay cache
ErrType = EX_TEMPFAIL;
- if ReplayCacheFile != None:
+ if ReplayCacheFile is not None:
ErrMsg = "Failed to initialize the replay cache:";
RC = ReplayCache(ReplayCacheFile);
RC.Clean();
ErrMsg = "Unable to check the signature or the signature was invalid:";
Res = GPGCheckSig(Msg[0]);
- if Res[0] != None:
+ if Res[0] is not None:
raise Error, Res[0];
if Res[3] is None:
PlainText = Res[3];
# Check the signature against the replay cache
- if ReplayCacheFile != None:
+ if ReplayCacheFile is not None:
ErrMsg = "The replay cache rejected your message. Check your clock!";
Rply = RC.Check(Res[1]);
- if Rply != None:
+ if Rply is not None:
raise Error, Rply;
RC.Add(Res[1]);
# Do LDAP stuff
- if LDAPDn != None:
+ if LDAPDn is not None:
CheckLDAP(Res[2][1]);
# Determine the sender address
# Invoke the child
Child = os.popen(" ".join(arguments),"w");
Child.write(PlainText);
- if Child.close() != None:
+ if Child.close() is not None:
raise Error, "Child gave a non-zero return code";
except:
# Try to send the bounce
try:
- if ErrorTemplate != None:
+ if ErrorTemplate is not None:
ErrReply = TemplateSubst(Subst,open(ErrorTemplate,"r").read());
else:
ErrReply = "\n"+str(Subst)+"\n";
Child = os.popen("/usr/sbin/sendmail -t","w");
Child.write(ErrReplyHead);
Child.write(ErrReply);
- if Child.close() != None:
+ if Child.close() is not None:
raise Error, "Sendmail gave a non-zero return code";
except:
sys.exit(EX_TEMPFAIL);
# original signed block [needs to convert to \r\n]
Output = "-----BEGIN PGP SIGNED MESSAGE-----\r\n";
# Semi-evil hack to get the proper hash type inserted in the message
- if Msg.get_param('micalg') != None:
+ if Msg.get_param('micalg') is not None:
Output = Output + "Hash: SHA1,%s\r\n"%(Msg.get_param('micalg')[4:].upper())
Output = Output + "\r\n";
Output = Output + Signed.as_string().replace("\n-","\n- -") + "\n" + Signature.get_payload(decode=True)
InPipe[0] = -1;
# Send the message
- if Message != None:
+ if Message is not None:
try:
os.write(InPipe[1],Message);
except:
Text = Res[2].read();
return Text;
finally:
- if Res != None:
+ if Res is not None:
Res[1].close();
Res[2].close();
else:
os.unlink(TmpName);
except:
pass;
- if Res != None:
+ if Res is not None:
Res[1].close();
Res[2].close();
# Try to decide if this message was sent using PGP2
PGP2Message = 0;
- if (re.search("-----[\n\r][\n\r]?Version: 2\\.",Message) != None):
+ if (re.search("-----[\n\r][\n\r]?Version: 2\\.",Message) is not None):
PGP2Message = 1;
return (Why,(SigId,Date,KeyFinger),(KeyID,KeyFinger,Owner,0,PGP2Message),Text);
finally:
- if Res != None:
+ if Res is not None:
Res[1].close();
Res[2].close();
continue
finally:
- if Strm != None:
+ if Strm is not None:
Strm.close()
return Result