diff options
Diffstat (limited to 'Lib/smtpd.py')
-rwxr-xr-x | Lib/smtpd.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/smtpd.py b/Lib/smtpd.py index 32f45ae..df835b2 100755 --- a/Lib/smtpd.py +++ b/Lib/smtpd.py @@ -678,6 +678,16 @@ def parseargs(): if __name__ == '__main__': options = parseargs() # Become nobody + classname = options.classname + if "." in classname: + lastdot = classname.rfind(".") + mod = __import__(classname[:lastdot], globals(), locals(), [""]) + classname = classname[lastdot+1:] + else: + import __main__ as mod + class_ = getattr(mod, classname) + proxy = class_((options.localhost, options.localport), + (options.remotehost, options.remoteport)) if options.setuid: try: import pwd @@ -691,16 +701,6 @@ if __name__ == '__main__': if e.errno != errno.EPERM: raise print('Cannot setuid "nobody"; try running with -n option.', file=sys.stderr) sys.exit(1) - classname = options.classname - if "." in classname: - lastdot = classname.rfind(".") - mod = __import__(classname[:lastdot], globals(), locals(), [""]) - classname = classname[lastdot+1:] - else: - import __main__ as mod - class_ = getattr(mod, classname) - proxy = class_((options.localhost, options.localport), - (options.remotehost, options.remoteport)) try: asyncore.loop() except KeyboardInterrupt: |