Hello,
Right now tofmipd chokes if someone submits a message but the auth_user
doesn't actually have TMDA set up. Unfortunately, from the user's perspective
they have no idea why trying to send mail failed to work. Attached is a patch
that adds a new command line option, -z/--pure_proxy_fallback. If the
auth_user doesn't have a tmdaconfigdir the message will be processed by a
PureProxy instance running on a random port number listening only on
127.0.0.1. I don't particularly care if this patch per se isn't accepted but
it would be nice if tofmipd gracefully handled users who don't have TMDA
installed.
--
Justus
--- tmda-ofmipd 2003-11-13 12:28:08.000000000 -0700
+++ /usr/bin/tmda-ofmipd 2003-12-29 02:45:44.000000000 -0700
@@ -196,6 +196,7 @@
authprog = None
fallback = 0
foreground = None
+pure_proxy = None
remoteauth = { 'proto': None,
'host': 'localhost',
'port': None,
@@ -261,7 +262,7 @@
try:
opts, args = getopt.getopt(sys.argv[1:],
- 'p:u:a:R:A:Fc:C:dVhfbS:v:t:', ['proxyport=',
+ 'p:u:a:R:A:Fc:C:dVhfbS:v:t:z', ['proxyport=',
'username=',
'authfile=',
'remoteauth=',
@@ -276,7 +277,8 @@
'background',
'vhome-script=',
'vdomains-path=',
- 'throttle-script='])
+ 'throttle-script=',
+ 'pure_proxy_fallback'])
except getopt.error, msg:
usage(1, msg)
@@ -293,6 +295,8 @@
DEBUGSTREAM = sys.stderr
elif opt in ('-F', '--fallback'):
fallback = 1
+ elif opt in ('-z', '--pure_proxy_fallback'):
+ pure_proxy = 1
elif opt in ('-f', '--foreground'):
foreground = 1
elif opt in ('-b', '--background'):
@@ -1171,36 +1175,49 @@
else:
tmda_configdir = os.path.join(os.path.expanduser
(configdir), auth_username)
- tmda_configfile = os.path.join(tmda_configdir, 'config')
- execdir = os.path.dirname(os.path.abspath(program))
- inject_path = os.path.join(execdir, 'tmda-inject')
- inject_cmd = [inject_path, '-c', tmda_configfile] + rcpttos
- # This is so "~" will always work in the .tmda/* files.
- os.environ['HOME'] = Util.gethomedir(auth_username)
- # If running as uid 0, fork the tmda-inject process, and
- # then change UID and GID to the authenticated user.
- if running_as_root:
- pid = os.fork()
- if pid == 0:
- os.seteuid(0)
- os.setgid(Util.getgid(auth_username))
- os.setgroups(Util.getgrouplist(auth_username))
- os.setuid(Util.getuid(auth_username))
- try:
- Util.pipecmd(inject_cmd, data)
- except Exception, err:
- print >> DEBUGSTREAM, 'Error:', err
- os._exit(-1)
- os._exit(0)
+ if not os.path.exists (tmda_configdir) and pure_proxy:
+ print >> DEBUGSTREAM, "No tmda configdir found for %s...falling back
to pure_proxy" % (auth_username)
+ pure_proxy.process_message (peer, mailfrom, rcpttos, data)
+ else:
+ tmda_configfile = os.path.join(tmda_configdir, 'config')
+ execdir = os.path.dirname(os.path.abspath(program))
+ inject_path = os.path.join(execdir, 'tmda-inject')
+ inject_cmd = [inject_path, '-c', tmda_configfile] + rcpttos
+ # This is so "~" will always work in the .tmda/* files.
+ os.environ['HOME'] = Util.gethomedir(auth_username)
+ # If running as uid 0, fork the tmda-inject process, and
+ # then change UID and GID to the authenticated user.
+ if running_as_root:
+ pid = os.fork()
+ if pid == 0:
+ os.seteuid(0)
+ os.setgid(Util.getgid(auth_username))
+ os.setgroups(Util.getgrouplist(auth_username))
+ os.setuid(Util.getuid(auth_username))
+ try:
+ Util.pipecmd(inject_cmd, data)
+ except Exception, err:
+ print >> DEBUGSTREAM, 'Error:', err
+ os._exit(-1)
+ os._exit(0)
+ else:
+ rpid, status = os.wait()
+ # Did tmda-inject succeed?
+ if status != 0:
+ raise IOError, 'tmda-inject failed!'
else:
- rpid, status = os.wait()
- # Did tmda-inject succeed?
- if status != 0:
- raise IOError, 'tmda-inject failed!'
- else:
- # no need to fork
- Util.pipecmd(inject_cmd, data)
-
+ # no need to fork
+ Util.pipecmd(inject_cmd, data)
+
+
+if pure_proxy:
+ import socket
+ sock = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
+ sock.bind (('localhost', 0))
+ pure_port = sock.getsockname()[1]
+ sock.close()
+ pure_proxy = PureProxy (('localhost', pure_port),
+ ('localhost', 25))
def main():
# check permissions of authfile if using only remote
_________________________________________________
tmda-workers mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-workers