CVS: tmda-cgi Release.py,1.6,1.7 tmda-cgi.py,1.36,1.37
Gre7g Luterman <[email protected]>
| Newsgroups | gmane.mail.spam.tmda.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tmda/tmda-cgi
In directory sc8-pr-cvs1:/tmp/cvs-serv28508
Modified Files:
Release.py tmda-cgi.py
Log Message:
Fixed the URL confirmation code so it works with both short and long style
URL's (where possible).
Index: Release.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/Release.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Release.py 21 May 2003 19:01:44 -0000 1.6
+++ Release.py 26 May 2003 20:14:14 -0000 1.7
@@ -37,52 +37,49 @@
def Release(QueryString):
"""Release the message represented in the QueryString.
-QueryString is in the format <UID>&<recipient_address>&<confirm_cookie>
+QueryString is in one of two formats, real users MAY confirm with:
+
+<UID>.<confirm_cookie>
+
+Virtual users MUST confirm with:
+
+<UID>&<recipient_address>&<confirm_cookie>
Where <UID> is the UID of the TMDA account, <recipient_address> is the untagged
address of the original message recipient, and <confirm_cookie> is used to find
-and validate the pending email in question.
-
-(Old-style addresses of the format <UID>.<confirm_cookie> are still accepted)
-"""
+and validate the pending email in question."""
# Prepare the traceback in case of uncaught exception
MyCgiTb.ErrTemplate = "prog_err2.html"
CgiUtil.ErrTemplate = "error2.html"
- QueryStringError = 0
- oldStyle = 0
try:
UID, Recipient, Cookie = QueryString.split("&")
- except ValueError:
+ UID = int(UID)
+ GID = int(pwd.getpwuid(UID)[3])
+ OldStyle = 0
+
+ # Get base address from Recipient
+ RecipUser, RecipDomain = Recipient.split("@")
+ User = RecipUser.split('-')[0] + "@" + RecipDomain
+ except (ValueError, KeyError):
try:
# Check for old-style format
- ## WARNING -- DEPRECATED and may soon disappear ##
- UID, Timestamp, PID, HMAC = QueryString.split(".")
- oldStyle = 1
- except ValueError:
- QueryStringError = 1
+ UID, Cookie = QueryString.split(".", 1)
+ UID = int(UID)
+ UserRec = pwd.getpwuid(UID)
+ User = UserRec[0]
+ GID = int(UserRec[3])
+ OldStyle = 1
+ except (ValueError, KeyError):
+ CgiUtil.TermError("Unable to parse query string.",
+ "Program error / corrupted link.",
+ "locate pending e-mail", "", """Please check the link you followed and
+make sure that it is typed in exactly as it was sent to you.""")
try:
# Get real user from UID
- UID = int(UID)
- UserRec = pwd.getpwuid(UID)
- User = UserRec[0]
- GID = int(UserRec[3])
- if not oldStyle:
- # Get base address from Recipient
- RecipUser, RecipDomain = Recipient.split("@")
- Recipient = RecipUser.split('-')[0] + "@" + RecipDomain
- if not oldStyle:
- # Get message parts form Cookie
- Timestamp, PID, HMAC = Cookie.split(".")
+ Timestamp, PID, HMAC = Cookie.split(".")
except ValueError:
- # May be from any failed .split or int()
- QueryStringError = 1
- except KeyError:
- # May occur if UID is not found on the system.
- QueryStringError = 1
-
- if QueryStringError:
CgiUtil.TermError("Unable to parse query string.",
"Program error / corrupted link.",
"locate pending e-mail", "", """Please check the link you followed and
@@ -104,15 +101,7 @@
except OSError:
pass
try:
- if os.environ.has_key("TMDA_VLOOKUP"):
- if oldStyle:
- # Old style URLs are not allowed with virtual user setups.
- CgiUtil.TermError("Confirm Failed",
- "Old-style URL is not compatible with virtual users",
- "use incompatible URL", """Contact this message's sender by an
-alternate means and inform them of this error, or try confirming your message
-using an alternate method.""")
- User = Recipient
+ if os.environ.has_key("TMDA_VLOOKUP") and not OldStyle:
VLookup = \
CgiUtil.ParseString(os.environ["TMDA_VLOOKUP"], User )
List = Util.RunTask(VLookup[1:])
@@ -164,7 +153,14 @@
pass
# Now that we know who we are, get our defaults
- from TMDA import Defaults
+ try:
+ from TMDA import Defaults
+ except Errors.ConfigError:
+ CgiUtil.TermError("Confirm Failed",
+ "Old-style URL is not compatible with virtual users",
+ "use incompatible URL", "", """Contact this message's sender by an
+alternate means and inform them of this error, or try confirming your message
+using an alternate method.""")
from TMDA import Pending
from TMDA import Cookie
Index: tmda-cgi.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/tmda-cgi.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- tmda-cgi.py 21 May 2003 16:07:59 -0000 1.36
+++ tmda-cgi.py 26 May 2003 20:14:14 -0000 1.37
@@ -109,16 +109,15 @@
# First visit to any page?
if not Form.keys():
# Release an e-mail by URL?
- try:
- if os.environ["QUERY_STRING"]:
- import Release
- Release.Release(os.environ["QUERY_STRING"])
- sys.exit()
- except KeyError:
- pass
- # Initial login
- import Login
- Call(Login)
+ if os.environ["QUERY_STRING"]:
+ import Release
+ Release.Release(os.environ["QUERY_STRING"])
+ sys.exit()
+
+ else:
+ # Initial login
+ import Login
+ Call(Login)
# Logged in yet?
elif not PVars.Valid:
_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs