Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e09851f

Browse filesBrowse files
committed
Bring groups -> extra_groups from the main
1 parent 6822d10 commit e09851f
Copy full SHA for e09851f

File tree

Expand file treeCollapse file tree

2 files changed

+38
-38
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+38
-38
lines changed

‎Modules/_posixsubprocess.c

Copy file name to clipboardExpand all lines: Modules/_posixsubprocess.c
+30-30Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ child_exec(char *const exec_array[],
541541
int close_fds, int restore_signals,
542542
int call_setsid, pid_t pgid_to_set,
543543
gid_t gid,
544-
Py_ssize_t groups_size, const gid_t *groups,
544+
Py_ssize_t extra_group_size, const gid_t *extra_groups,
545545
uid_t uid, int child_umask,
546546
const void *child_sigmask,
547547
PyObject *py_fds_to_keep,
@@ -641,8 +641,8 @@ child_exec(char *const exec_array[],
641641
#endif
642642

643643
#ifdef HAVE_SETGROUPS
644-
if (groups_size > 0)
645-
POSIX_CALL(setgroups(groups_size, groups));
644+
if (extra_group_size > 0)
645+
POSIX_CALL(setgroups(extra_group_size, extra_groups));
646646
#endif /* HAVE_SETGROUPS */
647647

648648
#ifdef HAVE_SETREGID
@@ -747,7 +747,7 @@ do_fork_exec(char *const exec_array[],
747747
int close_fds, int restore_signals,
748748
int call_setsid, pid_t pgid_to_set,
749749
gid_t gid,
750-
Py_ssize_t groups_size, const gid_t *groups,
750+
Py_ssize_t extra_group_size, const gid_t *extra_groups,
751751
uid_t uid, int child_umask,
752752
const void *child_sigmask,
753753
PyObject *py_fds_to_keep,
@@ -762,7 +762,7 @@ do_fork_exec(char *const exec_array[],
762762
/* These are checked by our caller; verify them in debug builds. */
763763
assert(uid == (uid_t)-1);
764764
assert(gid == (gid_t)-1);
765-
assert(groups_size < 0);
765+
assert(extra_group_size < 0);
766766
assert(preexec_fn == Py_None);
767767

768768
pid = vfork();
@@ -799,7 +799,7 @@ do_fork_exec(char *const exec_array[],
799799
p2cread, p2cwrite, c2pread, c2pwrite,
800800
errread, errwrite, errpipe_read, errpipe_write,
801801
close_fds, restore_signals, call_setsid, pgid_to_set,
802-
gid, groups_size, groups,
802+
gid, extra_group_size, extra_groups,
803803
uid, child_umask, child_sigmask,
804804
py_fds_to_keep, preexec_fn, preexec_fn_args_tuple);
805805
_exit(255);
@@ -826,7 +826,7 @@ _posixsubprocess.fork_exec as subprocess_fork_exec
826826
call_setsid: bool
827827
pgid_to_set: pid_t
828828
gid as gid_object: object
829-
groups_list: object
829+
extra_groups as extra_groups_packed: object
830830
uid as uid_object: object
831831
child_umask: int
832832
preexec_fn: object
@@ -865,19 +865,19 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
865865
int errwrite, int errpipe_read, int errpipe_write,
866866
int restore_signals, int call_setsid,
867867
pid_t pgid_to_set, PyObject *gid_object,
868-
PyObject *groups_list, PyObject *uid_object,
869-
int child_umask, PyObject *preexec_fn,
870-
int allow_vfork)
871-
/*[clinic end generated code: output=7c8ff5a6dc92af1b input=c59d1152ecdffcf9]*/
868+
PyObject *extra_groups_packed,
869+
PyObject *uid_object, int child_umask,
870+
PyObject *preexec_fn, int allow_vfork)
871+
/*[clinic end generated code: output=7ee4f6ee5cf22b5b input=51757287ef266ffa]*/
872872
{
873873
PyObject *converted_args = NULL, *fast_args = NULL;
874874
PyObject *preexec_fn_args_tuple = NULL;
875-
gid_t *groups = NULL;
875+
gid_t *extra_groups = NULL;
876876
PyObject *cwd_obj2 = NULL;
877877
const char *cwd = NULL;
878878
int need_to_reenable_gc = 0;
879879
char *const *argv = NULL, *const *envp = NULL;
880-
Py_ssize_t num_groups = 0;
880+
Py_ssize_t extra_group_size = 0;
881881
int need_after_fork = 0;
882882
int saved_errno = 0;
883883

@@ -951,41 +951,41 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
951951
cwd = PyBytes_AsString(cwd_obj2);
952952
}
953953

954-
if (groups_list != Py_None) {
954+
if (extra_groups_packed != Py_None) {
955955
#ifdef HAVE_SETGROUPS
956-
if (!PyList_Check(groups_list)) {
956+
if (!PyList_Check(extra_groups_packed)) {
957957
PyErr_SetString(PyExc_TypeError,
958958
"setgroups argument must be a list");
959959
goto cleanup;
960960
}
961-
num_groups = PySequence_Size(groups_list);
961+
extra_group_size = PySequence_Size(extra_groups_packed);
962962

963-
if (num_groups < 0)
963+
if (extra_group_size < 0)
964964
goto cleanup;
965965

966-
if (num_groups > MAX_GROUPS) {
967-
PyErr_SetString(PyExc_ValueError, "too many groups");
966+
if (extra_group_size > MAX_GROUPS) {
967+
PyErr_SetString(PyExc_ValueError, "too many extra_groups");
968968
goto cleanup;
969969
}
970970

971-
/* Deliberately keep groups == NULL for num_groups == 0 */
972-
if (num_groups > 0) {
973-
groups = PyMem_RawMalloc(num_groups * sizeof(gid_t));
974-
if (groups == NULL) {
971+
/* Deliberately keep extra_groups == NULL for extra_group_size == 0 */
972+
if (extra_group_size > 0) {
973+
extra_groups = PyMem_RawMalloc(extra_group_size * sizeof(gid_t));
974+
if (extra_groups == NULL) {
975975
PyErr_SetString(PyExc_MemoryError,
976976
"failed to allocate memory for group list");
977977
goto cleanup;
978978
}
979979
}
980980

981-
for (Py_ssize_t i = 0; i < num_groups; i++) {
981+
for (Py_ssize_t i = 0; i < extra_group_size; i++) {
982982
PyObject *elem;
983-
elem = PySequence_GetItem(groups_list, i);
983+
elem = PySequence_GetItem(extra_groups_packed, i);
984984
if (!elem)
985985
goto cleanup;
986986
if (!PyLong_Check(elem)) {
987987
PyErr_SetString(PyExc_TypeError,
988-
"groups must be integers");
988+
"extra_groups must be integers");
989989
Py_DECREF(elem);
990990
goto cleanup;
991991
} else {
@@ -995,7 +995,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
995995
PyErr_SetString(PyExc_ValueError, "invalid group id");
996996
goto cleanup;
997997
}
998-
groups[i] = gid;
998+
extra_groups[i] = gid;
999999
}
10001000
Py_DECREF(elem);
10011001
}
@@ -1047,7 +1047,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
10471047
/* Use vfork() only if it's safe. See the comment above child_exec(). */
10481048
sigset_t old_sigs;
10491049
if (preexec_fn == Py_None && allow_vfork &&
1050-
uid == (uid_t)-1 && gid == (gid_t)-1 && num_groups < 0) {
1050+
uid == (uid_t)-1 && gid == (gid_t)-1 && extra_group_size < 0) {
10511051
/* Block all signals to ensure that no signal handlers are run in the
10521052
* child process while it shares memory with us. Note that signals
10531053
* used internally by C libraries won't be blocked by
@@ -1070,7 +1070,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
10701070
p2cread, p2cwrite, c2pread, c2pwrite,
10711071
errread, errwrite, errpipe_read, errpipe_write,
10721072
close_fds, restore_signals, call_setsid, pgid_to_set,
1073-
gid, num_groups, groups,
1073+
gid, extra_group_size, extra_groups,
10741074
uid, child_umask, old_sigmask,
10751075
py_fds_to_keep, preexec_fn, preexec_fn_args_tuple);
10761076

@@ -1110,7 +1110,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
11101110
}
11111111

11121112
Py_XDECREF(preexec_fn_args_tuple);
1113-
PyMem_RawFree(groups);
1113+
PyMem_RawFree(extra_groups);
11141114
Py_XDECREF(cwd_obj2);
11151115
if (envp)
11161116
_Py_FreeCharPArray(envp);

‎Modules/clinic/_posixsubprocess.c.h

Copy file name to clipboardExpand all lines: Modules/clinic/_posixsubprocess.c.h
+8-8Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.