summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2011-10-20 21:14:36 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2011-10-20 21:14:36 (GMT)
commit407cfd1a269845208786bb9e7074e9990fa96dd7 (patch)
treebb8743531200bb1d6bab38a2ca6f0e2b8f16ac85
parent0cc147e9a2e05544ff00a1383891a1da0ef2a894 (diff)
parent711f87ca7d8b455feb450b2fb66a3d264fd603ce (diff)
downloadcpython-407cfd1a269845208786bb9e7074e9990fa96dd7.zip
cpython-407cfd1a269845208786bb9e7074e9990fa96dd7.tar.gz
cpython-407cfd1a269845208786bb9e7074e9990fa96dd7.tar.bz2
Issue #9168: now smtpd is able to bind privileged port.
-rwxr-xr-xLib/smtpd.py20
-rw-r--r--Misc/NEWS2
2 files changed, 12 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:
diff --git a/Misc/NEWS b/Misc/NEWS
index 71be0af..bfd97cb 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -322,6 +322,8 @@ Core and Builtins
Library
-------
+- Issue #9168: now smtpd is able to bind privileged port.
+
- Issue #12529: fix cgi.parse_header issue on strings with double-quotes and
semicolons together. Patch by Ben Darnell and Petri Lehtinen.