# HG changeset patch # User Yan Gao # Date 1260775668 -28800 # Node ID 268fb916123d9dfaaf5049cbb34a5d77c642e092 # Parent ab416ebb0734839d6e0e51e7f2fb9dac4832a50f Low: cib: Check also whether an user's primary group is matched diff -r ab416ebb0734 -r 268fb916123d cib/remote.c --- a/cib/remote.c Mon Dec 14 14:46:42 2009 +0800 +++ b/cib/remote.c Mon Dec 14 15:27:48 2009 +0800 @@ -153,10 +153,22 @@ check_group_membership(const char* usr, const char* grp) { int index = 0; + struct passwd *pwd = NULL; struct group *group = NULL; CRM_CHECK(usr != NULL, return FALSE); CRM_CHECK(grp != NULL, return FALSE); + + pwd = getpwnam(usr); + if (pwd == NULL) { + crm_err("No user named '%s' exists!", usr); + return FALSE; + } + + group = getgrgid(pwd->pw_gid); + if (group != NULL && crm_str_eq(grp, group->gr_name, TRUE)) { + return TRUE; + } group = getgrnam(grp); if (group == NULL) {