File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,14 +95,36 @@ remote_auth_timeout_cb(gpointer data)
9595static bool
9696is_daemon_group_member (const char * user )
9797{
98- const struct group * group = getgrnam (CRM_DAEMON_GROUP );
98+ int rc = pcmk_rc_ok ;
99+ gid_t gid = 0 ;
100+ const struct group * group = NULL ;
99101
102+ /* group->gr_mem only contains those users that are listed in /etc/group.
103+ * It won't list the user if the group is their primary (that is, it's in
104+ * the GID field in /etc/passwd (or passwd->pw_gid as returned by getpwent).
105+ * So, we first need to perform a primary group check.
106+ */
107+ rc = pcmk__lookup_user (user , NULL , & gid );
108+ if (rc != pcmk_rc_ok ) {
109+ pcmk__notice ("Rejecting remote client: could not find user '%s': %s" ,
110+ user , pcmk_rc_str (rc ));
111+ return false;
112+ }
113+
114+ group = getgrnam (CRM_DAEMON_GROUP );
100115 if (group == NULL ) {
101116 pcmk__err ("Rejecting remote client: " CRM_DAEMON_GROUP " is not a "
102117 "valid group" );
103118 return false;
104119 }
105120
121+ if (group -> gr_gid == gid ) {
122+ return true;
123+ }
124+
125+ /* If that didn't work, check if CRM_DAEMON_GROUP is a secondary group for
126+ * the user.
127+ */
106128 for (const char * const * member = (const char * const * ) group -> gr_mem ;
107129 * member != NULL ; member ++ ) {
108130
You can’t perform that action at this time.
0 commit comments