python, python2: disable setuid in servers (#6548)

This commit is contained in:
Leonid Pliushch
2021-03-20 16:41:35 +02:00
committed by GitHub
parent 8d447cb1b4
commit f775bdb9c1
4 changed files with 74 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
diff -uNr Python-2.7.18/Lib/CGIHTTPServer.py Python-2.7.18.mod/Lib/CGIHTTPServer.py
--- Python-2.7.18/Lib/CGIHTTPServer.py 2020-04-20 00:13:39.000000000 +0300
+++ Python-2.7.18.mod/Lib/CGIHTTPServer.py 2021-03-20 16:17:50.802196841 +0200
@@ -239,10 +239,6 @@
return
# Child
try:
- try:
- os.setuid(nobody)
- except os.error:
- pass
os.dup2(self.rfile.fileno(), 0)
os.dup2(self.wfile.fileno(), 1)
os.execve(scriptfile, args, env)
diff -uNr Python-2.7.18/Lib/smtpd.py Python-2.7.18.mod/Lib/smtpd.py
--- Python-2.7.18/Lib/smtpd.py 2020-04-20 00:13:39.000000000 +0300
+++ Python-2.7.18.mod/Lib/smtpd.py 2021-03-20 16:17:42.182179072 +0200
@@ -9,7 +9,8 @@
-n
This program generally tries to setuid `nobody', unless this flag is
set. The setuid call will fail if this program is not run as root (in
- which case, use this flag).
+ which case, use this flag). Ignored in Termux as no setuid done on this
+ platform.
--version
-V
@@ -461,7 +462,7 @@
class Options:
- setuid = 1
+ setuid = 0
classname = 'PureProxy'