diff --git a/src/slurmd/slurmstepd/mgr.c b/src/slurmd/slurmstepd/mgr.c index 06527926cefb6592ffb7a50afc2c6a65d9cbd9bd..6b00e4ae20c3c7477164bb12f13be3c7ef61058e 100644 --- a/src/slurmd/slurmstepd/mgr.c +++ b/src/slurmd/slurmstepd/mgr.c @@ -1141,6 +1141,7 @@ _pre_task_privileged(slurmd_job_t *job, int taskid, struct priv_state *sp) if (pre_launch_priv(job) < 0) return error("pre_launch_priv failed"); + /* sp->get_list should already be initialized */ return(_drop_privileges (job, true, sp, false)); } @@ -1444,7 +1445,9 @@ _fork_all_tasks(slurmd_job_t *job, bool *io_initialized) /* * Reclaim privileges and call any plugin hooks - * that may require elevated privs + * that may require elevated privs + * sprivs.get_list is already set from the + * _drop_privileges call above, no not reinitialize. */ if (_pre_task_privileged(job, i, &sprivs) < 0) exit(1); @@ -2127,7 +2130,9 @@ _send_complete_batch_script_msg(slurmd_job_t *job, int err, int status) return SLURM_SUCCESS; } - +/* If get_list is false make sure ps->gid_list is initialized before + * hand to prevent xfree. + */ static int _drop_privileges(slurmd_job_t *job, bool do_setuid, struct priv_state *ps, bool get_list) @@ -2150,8 +2155,6 @@ _drop_privileges(slurmd_job_t *job, bool do_setuid, xfree(ps->gid_list); return -1; } - } else { - ps->gid_list = NULL; /* initialize to prevent xfree */ } /* @@ -2443,6 +2446,7 @@ _run_script_as_user(const char *name, const char *path, slurmd_job_t *job, argv[0] = (char *)xstrdup(path); argv[1] = NULL; + sprivs.gid_list = NULL; /* initialize to prevent xfree */ if (_drop_privileges(job, true, &sprivs, false) < 0) { error("run_script_as_user _drop_privileges: %m"); /* child process, should not return */