CVS: tmda/TMDA Defaults.py,1.203,1.204 Util.py,1.117,1.118
"Jason R. Mastaler" <[email protected]> Fri, 05 Mar 2004 17:18:54 -0800
| Newsgroups | gmane.mail.spam.tmda.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tmda/tmda/TMDA
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12292/TMDA
Modified Files:
Defaults.py Util.py
Log Message:
Platform-agnostic changes. Don't use forward-slashes in Defaults.py
for default values; instead use os.path.join() to combine components
since it does it correctly for each platform.
Skip file permission checks for CRYPT_KEY_FILE when the platform is
not POSIX.
Move import of 'pwd' into function bodies.
These changes allow some of the tmda-* programs to run on native
MS-Windows (tmda-address, tmda-check-address, tmda-pending,
and tmda-keygen).
Index: Defaults.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/Defaults.py,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -r1.203 -r1.204
--- Defaults.py 2 Mar 2004 02:26:42 -0000 1.203
+++ Defaults.py 6 Mar 2004 01:18:52 -0000 1.204
@@ -54,6 +54,8 @@
EX_OK = 0
EX_TEMPFAIL = 75
+HOMEDIR = os.path.expanduser('~')
+
# TMDA parent directory.
progpath = os.path.abspath(sys.argv[0])
if os.path.islink(progpath):
@@ -81,7 +83,7 @@
if _tmdarc:
TMDARC = _tmdarc
elif not vars().has_key('TMDARC'):
- TMDARC = os.path.expanduser('~/.tmda/config')
+ TMDARC = os.path.join(HOMEDIR, '.tmda', 'config')
# CONFIG_EXEC
# If set to False in GLOBAL_TMDARC, the user's TMDARC file will be parsed
@@ -126,16 +128,16 @@
# DATADIR
# Top-level directory which TMDA uses to store its files and
# directories. TMDA should be free to create files and directories
-# under DATADIR if need be. Make sure to include a trailing "/".
+# under DATADIR if need be.
#
# Examples:
#
-# DATADIR = "/full/path/to/.tmda/"
-# DATADIR = "~/.tmda/"
+# DATADIR = "/full/path/to/.tmda"
+# DATADIR = "~/.tmda"
#
-# Default is ~/.tmda/
+# Default is ~/.tmda
if not vars().has_key('DATADIR'):
- DATADIR = "~/.tmda/"
+ DATADIR = os.path.join(HOMEDIR, '.tmda')
# MAIL_TRANSFER_AGENT
# Defines which mail transfer agent (MTA) software you are running.
@@ -1548,16 +1550,16 @@
if _defaults.has_key(var) and isinstance(_defaults[var], str):
_defaults[var] = os.path.expanduser(_defaults[var])
-
# Finish processing CRYPT_KEY_FILE/CRYPT_KEY
if os.path.exists(CRYPT_KEY_FILE):
- crypt_key_filemode = Util.getfilemode(CRYPT_KEY_FILE)
- if crypt_key_filemode not in (400, 600):
- if ALLOW_MODE_640 and crypt_key_filemode == 640:
- pass
- else:
- raise Errors.ConfigError, \
- CRYPT_KEY_FILE + " must be chmod 400 or 600!"
+ if os.name == 'posix':
+ crypt_key_filemode = Util.getfilemode(CRYPT_KEY_FILE)
+ if crypt_key_filemode not in (400, 600):
+ if ALLOW_MODE_640 and crypt_key_filemode == 640:
+ pass
+ else:
+ raise Errors.ConfigError, \
+ CRYPT_KEY_FILE + " must be chmod 400 or 600!"
else:
if os.environ.has_key('TMDA_CGI_MODE') and \
os.environ['TMDA_CGI_MODE'] == 'no-su':
Index: Util.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/Util.py,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- Util.py 5 Mar 2004 19:26:35 -0000 1.117
+++ Util.py 6 Mar 2004 01:18:52 -0000 1.118
@@ -30,7 +30,6 @@
import fnmatch
import os
import popen2
-import pwd
import re
import socket
import stat
@@ -65,6 +64,7 @@
os.environ.get('NAME') or \
os.environ.get('MAILNAME')
if not fullname:
+ import pwd
fullname = pwd.getpwuid(os.getuid())[4]
if fullname:
fullname = fullname.split(',')[0]
@@ -78,6 +78,7 @@
os.environ.get('USER') or \
os.environ.get('LOGNAME')
if not username:
+ import pwd
username = pwd.getpwuid(os.getuid())[0]
if not username:
username = '<unknown>'
@@ -86,16 +87,19 @@
def getuid(username):
"""Return username's numerical user ID."""
+ import pwd
return pwd.getpwnam(username)[2]
def getgid(username):
"""Return username's numerical group ID."""
+ import pwd
return pwd.getpwnam(username)[3]
def gethomedir(username):
"""Return the home directory of username."""
+ import pwd
return pwd.getpwnam(username)[5]
@@ -180,7 +184,7 @@
def getuserparams(login):
"Return a user's home directory, UID, & GID."
-
+ import pwd
stats = pwd.getpwnam(login)
return (stats[5], stats[2], stats[3])