summaryrefslogtreecommitdiffstats
path: root/Lib/smtpd.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2011-10-20 21:03:43 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2011-10-20 21:03:43 (GMT)
commit711f87ca7d8b455feb450b2fb66a3d264fd603ce (patch)
tree5117ff895eafcb0c07b99ed37560fc518406a300 /Lib/smtpd.py
parentcd1d3ef77bb4385ba59c76986eca75f8d4df8fd7 (diff)
downloadcpython-711f87ca7d8b455feb450b2fb66a3d264fd603ce.zip
cpython-711f87ca7d8b455feb450b2fb66a3d264fd603ce.tar.gz
cpython-711f87ca7d8b455feb450b2fb66a3d264fd603ce.tar.bz2
Issue #9168: now smtpd is able to bind privileged port.
Diffstat (limited to 'Lib/smtpd.py')
-rwxr-xr-xLib/smtpd.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index 599e79b..8cd405c 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: