CVS: tmda/TMDA Auth.py,1.16,1.17
Jim Ramsay <[email protected]>
| Newsgroups | gmane.mail.spam.tmda.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tmda/tmda/TMDA
In directory sc8-pr-cvs1:/tmp/cvs-serv25896
Modified Files:
Auth.py
Log Message:
Moved "import hmac" to a less-global place and put it in a try block to see if it really exists...
Now Auth.py is compatible with Python 2.1 (I think), and only the methods supports_cram_md5() and authenticate_cram_md5() require Python 2.2.
Index: Auth.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/Auth.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Auth.py 14 May 2003 22:51:49 -0000 1.16
+++ Auth.py 16 May 2003 15:46:56 -0000 1.17
@@ -26,7 +26,6 @@
import sys
import socket
import base64
-import hmac
import md5
import popen2
import time
@@ -130,13 +129,6 @@
elif configdir is not None:
self.setup_configdir( configdir )
- # check whether we are running a recent enough Python
- if not Version.PYTHON >= '2.2':
- msg = 'Python 2.2 or greater is required to run ' + \
- self.__program + \
- ' -- Visit http://python.org/download/ to upgrade.'
- self.warning(msg)
-
def warning(self, msg='', exit=1):
delimiter = '*' * 70
if msg:
@@ -347,6 +339,13 @@
digestmod = md5):
"""Authenticates a cram_md5 response based on a ticket.
Expects a base-64 encoded "response" unless otherwise specified."""
+ try:
+ import hmac
+ except ImportError:
+ raise Errors.AuthError, \
+ ( "Cram MD5 authentication not supported.",\
+ "This authentication requires the \"hmac\" module, which is" + \
+ "only included with python version 2.2 and later" )
if not self.supports_cram_md5():
raise Errors.AuthError, \
( "Cram MD5 authentication not supported.",\
@@ -370,8 +369,13 @@
def supports_cram_md5(self):
"""Check if Cram MD5 authentication is supported.
- Requirements: File authentication, file allows cleartext passwords"""
+ Requirements: "hmac" module, File authentication,
+ and file allows cleartext passwords"""
retval = 0
+ try:
+ import hmac
+ except ImportError:
+ return 0
if self.__authtype == "file" and self.__authfile_allows_cleartext:
retval = 1
return retval
_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs