Skip to content
Snippets Groups Projects
Commit 84bc4035 authored by Peter Hutterer's avatar Peter Hutterer Committed by Pekka Paalanen
Browse files

weston-launch: always run through all groups

If the user is in group 0, we'd exit the loop early with a failure. Make sure
we run through all groups.

#86



Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
[Pekka: fix one whitespace]
Reviewed-by: default avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
parent dcfb1958
No related branches found
No related tags found
No related merge requests found
...@@ -121,7 +121,7 @@ struct weston_launch { ...@@ -121,7 +121,7 @@ struct weston_launch {
union cmsg_data { unsigned char b[4]; int fd; }; union cmsg_data { unsigned char b[4]; int fd; };
static gid_t * static gid_t *
read_groups(void) read_groups(int *ngroups)
{ {
int n; int n;
gid_t *groups; gid_t *groups;
...@@ -142,6 +142,8 @@ read_groups(void) ...@@ -142,6 +142,8 @@ read_groups(void)
free(groups); free(groups);
return NULL; return NULL;
} }
*ngroups = n;
return groups; return groups;
} }
...@@ -150,7 +152,7 @@ weston_launch_allowed(struct weston_launch *wl) ...@@ -150,7 +152,7 @@ weston_launch_allowed(struct weston_launch *wl)
{ {
struct group *gr; struct group *gr;
gid_t *groups; gid_t *groups;
int i; int ngroups;
#ifdef HAVE_SYSTEMD_LOGIN #ifdef HAVE_SYSTEMD_LOGIN
char *session, *seat; char *session, *seat;
int err; int err;
...@@ -161,10 +163,10 @@ weston_launch_allowed(struct weston_launch *wl) ...@@ -161,10 +163,10 @@ weston_launch_allowed(struct weston_launch *wl)
gr = getgrnam("weston-launch"); gr = getgrnam("weston-launch");
if (gr) { if (gr) {
groups = read_groups(); groups = read_groups(&ngroups);
if (groups) { if (groups && ngroups > 0) {
for (i = 0; groups[i]; ++i) { while (ngroups--) {
if (groups[i] == gr->gr_gid) { if (groups[ngroups] == gr->gr_gid) {
free(groups); free(groups);
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment