CVS: tmda/bin ChangeLog,1.284,1.285 tmda-ofmipd,1.38,1.39
"Jason R. Mastaler" <[email protected]>
| Newsgroups | gmane.mail.spam.tmda.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tmda/tmda/bin In directory sc8-pr-cvs1:/tmp/cvs-serv7826/bin Modified Files: ChangeLog tmda-ofmipd Log Message: Bugfix. tmda-ofmipd was not able to send mail to addresses which contained apostrophes (e.g, sinead.o'[email protected]) because it was escaping them with \\. This was originally done to to prevent shell exploits when the tmda-inject command-line was expanded. We can now avoid the shell completely by passing a sequence to Util.pipecmd() instead of a string, and thus we no longer need to escape the apostrophes. Thanks to David Collantes for reporting this on tmda-users. Index: ChangeLog =================================================================== RCS file: /cvsroot/tmda/tmda/bin/ChangeLog,v retrieving revision 1.284 retrieving revision 1.285 diff -u -r1.284 -r1.285 --- ChangeLog 20 Aug 2003 00:28:03 -0000 1.284 +++ ChangeLog 16 Oct 2003 23:52:12 -0000 1.285 @@ -1,3 +1,12 @@ +2003-10-16 Jason R. Mastaler <[email protected]> + + * tmda-ofmipd (quote_rcpts): Remove. + + (VDomainProxy.process_message): Pass a sequence rather than a + string to Util.pipecmd() to avoid the shell. + + (TMDAProxy.process_message): Ditto. + 2003-08-19 Jason R. Mastaler <[email protected]> * tmda-rfilter (main): Support confirm=template FILTER_INCOMING Index: tmda-ofmipd =================================================================== RCS file: /cvsroot/tmda/tmda/bin/tmda-ofmipd,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- tmda-ofmipd 15 Jun 2003 17:27:24 -0000 1.38 +++ tmda-ofmipd 16 Oct 2003 23:52:12 -0000 1.39 @@ -462,17 +462,6 @@ return pipecmd(cmd, '%s\0%s\0' % (username, password)) -def quote_rcpts(rcpttos): - """Each address should be properly quoted to prevent malicious - users from executing code by passing args to tmda-inject.""" - rcpttos_quoted = [] - for rcptto in rcpttos: - rcpttos_quoted.append("'%s'" % - rcptto.replace - ("\\", "\\\\").replace("'", "'\\\\\\''")) - return rcpttos_quoted - - def run_remoteauth(username, password, localip): """Authenticate username/password combination against a remote resource. Return 1 upon successful authentication, and 0 @@ -1120,7 +1109,7 @@ os.environ['TCPLOCALIP'] = self._localip # Set up partial tmda-inject command line. execdir = os.path.dirname(os.path.abspath(program)) - inject_cmd = os.path.join(execdir, 'tmda-inject') + inject_cmd = [os.path.join(execdir, 'tmda-inject')] + rcpttos userinfo = auth_username.split('@', 1) user = userinfo[0] if len(userinfo) > 1: @@ -1160,9 +1149,7 @@ # This is so "~" will work in the .tmda/* files. os.environ['HOME'] = vhomedir try: - Util.pipecmd('%s %s' % - (inject_cmd, ' '.join - (quote_rcpts(rcpttos))), data) + Util.pipecmd(inject_cmd, data) except Exception, err: print >> DEBUGSTREAM, 'Error:', err if running_as_root: @@ -1186,7 +1173,7 @@ 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 = '%s --config-file %s' % (inject_path, tmda_configfile) + 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 @@ -1199,9 +1186,7 @@ os.setgroups(Util.getgrouplist(auth_username)) os.setuid(Util.getuid(auth_username)) try: - Util.pipecmd('%s %s' % - (inject_cmd, ' '.join - (quote_rcpts(rcpttos))), data) + Util.pipecmd(inject_cmd, data) except Exception, err: print >> DEBUGSTREAM, 'Error:', err os._exit(-1) @@ -1213,9 +1198,8 @@ raise IOError, 'tmda-inject failed!' else: # no need to fork - Util.pipecmd('%s %s' % (inject_cmd, ' '.join - (quote_rcpts(rcpttos))), data) - + Util.pipecmd(inject_cmd, data) + def main(): # check permissions of authfile if using only remote