diff --git a/Lib/smtpd.py b/Lib/smtpd.py index e0544e4..5bfbb1c 100755 --- a/Lib/smtpd.py +++ b/Lib/smtpd.py @@ -523,6 +523,16 @@ def parseargs(): if __name__ == '__main__': options = parseargs() + 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)) # Become nobody if options.setuid: try: @@ -539,16 +549,6 @@ if __name__ == '__main__': print >> sys.stderr, \ 'Cannot setuid "nobody"; try running with -n option.' 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: