mirror of
https://github.com/python/cpython.git
synced 2025-11-11 22:55:08 +00:00
Issue #9168: now smtpd is able to bind privileged port.
This commit is contained in:
parent
cd1d3ef77b
commit
711f87ca7d
2 changed files with 12 additions and 10 deletions
20
Lib/smtpd.py
20
Lib/smtpd.py
|
|
@ -678,6 +678,16 @@ def parseargs():
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
options = parseargs()
|
options = parseargs()
|
||||||
# Become nobody
|
# 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:
|
if options.setuid:
|
||||||
try:
|
try:
|
||||||
import pwd
|
import pwd
|
||||||
|
|
@ -691,16 +701,6 @@ if __name__ == '__main__':
|
||||||
if e.errno != errno.EPERM: raise
|
if e.errno != errno.EPERM: raise
|
||||||
print('Cannot setuid "nobody"; try running with -n option.', file=sys.stderr)
|
print('Cannot setuid "nobody"; try running with -n option.', file=sys.stderr)
|
||||||
sys.exit(1)
|
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:
|
try:
|
||||||
asyncore.loop()
|
asyncore.loop()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #9168: now smtpd is able to bind privileged port.
|
||||||
|
|
||||||
- Issue #12529: fix cgi.parse_header issue on strings with double-quotes and
|
- Issue #12529: fix cgi.parse_header issue on strings with double-quotes and
|
||||||
semicolons together. Patch by Ben Darnell and Petri Lehtinen.
|
semicolons together. Patch by Ben Darnell and Petri Lehtinen.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue