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

index 599e79b7eddf91e0f433af2d5ddcaf7f98345b0a..8cd405c5f6c3a25f0c0c8566ae2f243bf8301f3c 100755 (executable)
@@ -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:
index 6e49b43ac18f0318abcbcf5acdfaf43218197763..fbf3b8d619982fc3dd73a16e555ce13ae7863348 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -54,6 +54,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.