]> granicus.if.org Git - python/commitdiff
Issue #9168: now smtpd is able to bind privileged port.
authorFlorent Xicluna <florent.xicluna@gmail.com>
Thu, 20 Oct 2011 21:21:58 +0000 (23:21 +0200)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Thu, 20 Oct 2011 21:21:58 +0000 (23:21 +0200)
Lib/smtpd.py
Misc/NEWS

index e0544e4c526899f6f09facb254e7919bcd185a46..b4d208b2eeb9857e89fcc9df8ffdb6a0233e429f 100755 (executable)
@@ -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:
index 426a42dbf53534f46443b3266b04de39e21d86a2..dd2874b400159771c4b6b1a3c25ac050dea456e3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -66,6 +66,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.