From 254fa75190e9c67d337df275763f27ff749aac53 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Thu, 14 Jan 2016 09:09:05 -0800 Subject: [PATCH] Fix for leak in gid cache logic --- doc/html/faq.shtml | 2 +- src/slurmctld/partition_mgr.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/html/faq.shtml b/doc/html/faq.shtml index 2c7451ba899..094826494e8 100644 --- a/doc/html/faq.shtml +++ b/doc/html/faq.shtml @@ -1145,7 +1145,7 @@ chmod 600 /etc/ssh/allowed_users <p><b>NOTE:</b> root is not necessarily listed on the allowed_users, but I feel somewhat safe if it's on the list.</p> -<p><b>Step 3.</b> On /etc/pam.d/sshd, add pam_listfile.so with sufficient flag +<p><b>Step 3.</b> On /etc/pam.d/sshd, add pam_listfile.so with sufficient flag before pam_slurm.so (e.g. my /etc/pam.d/sshd looks like this):</p> <pre> #%PAM-1.0 diff --git a/src/slurmctld/partition_mgr.c b/src/slurmctld/partition_mgr.c index 74b50dd6d3e..6256e96383e 100644 --- a/src/slurmctld/partition_mgr.c +++ b/src/slurmctld/partition_mgr.c @@ -1767,6 +1767,7 @@ extern int validate_group(struct part_record *part_ptr, uid_t run_uid) ii = sysconf(_SC_GETGR_R_SIZE_MAX); buflen = MAX(PW_BUF_SIZE, ii); #endif + grp_buffer = xmalloc(buflen); while (1) { slurm_seterrno(0); res = getgrgid_r(pwd.pw_gid, &grp, grp_buffer, buflen, @@ -1784,6 +1785,7 @@ extern int validate_group(struct part_record *part_ptr, uid_t run_uid) } error("%s: Could not find group with gid %ld", __func__, (long) pwd.pw_gid); + xfree(buf); xfree(grp_buffer); return 0; } @@ -1793,7 +1795,6 @@ extern int validate_group(struct part_record *part_ptr, uid_t run_uid) /* And finally check the name of the primary group against the * list of allowed group names. */ groups = xstrdup(part_ptr->allow_groups); - saveptr; one_group_name = strtok_r(groups, ",", &saveptr); while (one_group_name) { if (strcmp (one_group_name, grp.gr_name) == 0) { -- GitLab