This is an automated email from the git hooks/post-receive script. l a n d r y p u s h e d a c o m m i t t o b r a n c h m a s t e r in repository xfce/xfce4-session.
commit 207954303e3510aac0d51567f10cf1bd0b9f3fda Author: Landry Breuil <[email protected]> Date: Sat Apr 27 17:41:37 2019 +0200 Use sysconf(_SC_NGROUPS_MAX) instead of #defining an arbitrary MAX_USER_GROUPS (bug #14722) --- xfce4-session/xfsm-shutdown-fallback.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/xfce4-session/xfsm-shutdown-fallback.c b/xfce4-session/xfsm-shutdown-fallback.c index 28df8f8..c3444da 100644 --- a/xfce4-session/xfsm-shutdown-fallback.c +++ b/xfce4-session/xfsm-shutdown-fallback.c @@ -69,8 +69,6 @@ #include <pwd.h> #include <grp.h> -#define MAX_USER_GROUPS 100 - #include <libxfsm/xfsm-util.h> #include <libxfsm/xfsm-shutdown-common.h> #include <xfce4-session/xfsm-shutdown-fallback.h> @@ -206,8 +204,8 @@ static gboolean xfsm_shutdown_fallback_user_is_operator (void) { struct passwd *pw; - gid_t groups[MAX_USER_GROUPS]; - int max_grp = MAX_USER_GROUPS; + int max_grp = sysconf(_SC_NGROUPS_MAX); + gid_t *groups; int i = 0; int ret; static gboolean is_operator = FALSE; @@ -217,6 +215,19 @@ xfsm_shutdown_fallback_user_is_operator (void) if (once == TRUE) goto out; + if (max_grp == -1) + { + fprintf (stderr, "sysconf(_SC_NGROUPS_MAX) failed"); + return FALSE; + } + + groups = malloc(sizeof(gid_t) * max_grp); + if (groups == NULL) + { + fprintf (stderr, "malloc(sizeof(gid_t) * max_grp) failed"); + return FALSE; + } + pw = getpwuid (getuid()); ret = getgrouplist (pw->pw_name, pw->pw_gid, groups, &max_grp); @@ -225,7 +236,8 @@ xfsm_shutdown_fallback_user_is_operator (void) { fprintf (stderr, "Failed to get user group list, user belongs to more than %u groups?\n", - MAX_USER_GROUPS); + max_grp); + free(groups); goto out; } @@ -242,6 +254,7 @@ xfsm_shutdown_fallback_user_is_operator (void) break; } } + free(groups); out: return is_operator; } -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list [email protected] https://mail.xfce.org/mailman/listinfo/xfce4-commits
