Update of /cvsroot/tmda/tmda/contrib/cgi
In directory sc8-pr-cvs1:/tmp/cvs-serv9442
Modified Files:
Authenticate.py
Log Message:
Catch exception thrown in user tries to log in as a user who is not on the
system.
Index: Authenticate.py
===================================================================
RCS file: /cvsroot/tmda/tmda/contrib/cgi/Authenticate.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Authenticate.py 6 Dec 2002 17:05:49 -0000 1.5
+++ Authenticate.py 2 Jan 2003 22:23:23 -0000 1.6
@@ -78,28 +78,33 @@
def CheckPassword(Form):
"Checks a password against password files."
- # Find the requested home directory
- os.environ["HOME"] = pwd.getpwnam(Form["user"].value)[5]
+ try:
+ # Find the requested home directory
+ os.environ["HOME"] = pwd.getpwnam(Form["user"].value)[5]
- # Look in same directory as TMDARC file
- if os.environ.has_key("TMDARC"):
- # Given location?
- FN = os.path.join(os.path.split(os.environ["TMDARC"])[0], "tmda-cgi")
- else:
- # No given location, try ~/.tmda/tmda-cgi
- FN = os.path.expanduser("~/.tmda/tmda-cgi")
+ # Look in same directory as TMDARC file
+ if os.environ.has_key("TMDARC"):
+ # Given location?
+ FN = os.path.join(os.path.split(os.environ["TMDARC"])[0], "tmda-cgi")
+ else:
+ # No given location, try ~/.tmda/tmda-cgi
+ FN = os.path.expanduser("~/.tmda/tmda-cgi")
- # Login succeed?
- RetVal = ComparePassword(FN, Form["user"].value, Form["password"].value)
- if RetVal > 0:
- return RetVal
+ # Login succeed?
+ RetVal = ComparePassword(FN, Form["user"].value, Form["password"].value)
+ if RetVal > 0:
+ return RetVal
+ except KeyError:
+ RetVal = -4
+ FN = "<i>n/a</i>"
# Login help?
if int(Form["debug"].value):
Errors = ["Logins for user %(user)s have been deactivated in file
<tt>%(file)s</tt>",
"Password incorrect for user %(user)s in file <tt>%(file)s</tt>",
"User %(user)s was not found in file <tt>%(file)s</tt>",
- "Could not read file <tt>%(file)s</tt>"]
+ "Could not read file <tt>%(file)s</tt>",
+ "User %(user)s does not exist"]
Err = Errors[-RetVal] % {"user": Form["user"].value, "file": FN}
Err += "<br>" + CgiUtil.FileDetails("Local password", FN)
if RetVal > -2:
_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs