summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2011-10-20 21:21:58 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2011-10-20 21:21:58 (GMT)
commit47fb192ddafa48e3408c054c4ac1b1dc976164db (patch)
tree54d3cf8cb55552a7723b3cceb673e5f904b73a6d /Lib
parent5e30fa5f56387279455c5ce62b10cd262cf4bcca (diff)
downloadcpython-47fb192ddafa48e3408c054c4ac1b1dc976164db.zip
cpython-47fb192ddafa48e3408c054c4ac1b1dc976164db.tar.gz
cpython-47fb192ddafa48e3408c054c4ac1b1dc976164db.tar.bz2
Issue #9168: now smtpd is able to bind privileged port.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/smtpd.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index e0544e4..b4d208b 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -524,6 +524,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
@@ -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: