summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2019-10-12 20:24:56 (GMT)
committerGitHub <noreply@github.com>2019-10-12 20:24:56 (GMT)
commitf3751efb5c8b53b37efbbf75d9422c1d11c01646 (patch)
tree2e650d45ee4a530df31c2b66d9457d11e6996f33 /Lib/subprocess.py
parent8177404d520e81f16324a900f093adf3856d33f8 (diff)
downloadcpython-f3751efb5c8b53b37efbbf75d9422c1d11c01646.zip
cpython-f3751efb5c8b53b37efbbf75d9422c1d11c01646.tar.gz
cpython-f3751efb5c8b53b37efbbf75d9422c1d11c01646.tar.bz2
bpo-38417: Add umask support to subprocess (GH-16726)
On POSIX systems, allow the umask to be set in the child process before we exec.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 1016874..b5a45d9 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -733,6 +733,8 @@ class Popen(object):
user (POSIX only)
+ umask (POSIX only)
+
pass_fds (POSIX only)
encoding and errors: Text mode encoding and error handling to use for
@@ -750,7 +752,7 @@ class Popen(object):
startupinfo=None, creationflags=0,
restore_signals=True, start_new_session=False,
pass_fds=(), *, user=None, group=None, extra_groups=None,
- encoding=None, errors=None, text=None):
+ encoding=None, errors=None, text=None, umask=-1):
"""Create new Popen instance."""
_cleanup()
# Held while anything is calling waitpid before returncode has been
@@ -945,7 +947,7 @@ class Popen(object):
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
- gid, gids, uid,
+ gid, gids, uid, umask,
start_new_session)
except:
# Cleanup if the child failed starting.
@@ -1318,6 +1320,7 @@ class Popen(object):
errread, errwrite,
unused_restore_signals,
unused_gid, unused_gids, unused_uid,
+ unused_umask,
unused_start_new_session):
"""Execute program (MS Windows version)"""
@@ -1645,7 +1648,7 @@ class Popen(object):
c2pread, c2pwrite,
errread, errwrite,
restore_signals,
- gid, gids, uid,
+ gid, gids, uid, umask,
start_new_session):
"""Execute program (POSIX version)"""
@@ -1684,7 +1687,8 @@ class Popen(object):
and not start_new_session
and gid is None
and gids is None
- and uid is None):
+ and uid is None
+ and umask < 0):
self._posix_spawn(args, executable, env, restore_signals,
p2cread, p2cwrite,
c2pread, c2pwrite,
@@ -1738,7 +1742,7 @@ class Popen(object):
errread, errwrite,
errpipe_read, errpipe_write,
restore_signals, start_new_session,
- gid, gids, uid,
+ gid, gids, uid, umask,
preexec_fn)
self._child_created = True
finally: