initial commit
[glibc.git] / debian / patches / kfreebsd / local-initgroups-order.diff
1
2 setgroups(size, groups) changes egid on kfreebsd,
3 precisely groups[0] is the new egid
4
5 initgroups(user, gid) prepares the "groups" list
6 via internal_getgrouplist().
7 It puts supplied gid as the first entry in all but NSCD cases.
8 Fix the remaining NSCD case, see #698102, #699593.
9
10
11 --- a/nscd/nscd_initgroups.c
12 +++ b/nscd/nscd_initgroups.c
13 @@ -145,15 +145,23 @@
14 }
15
16 /* Check whether GROUP is part of the mix. If not, add it. */
17 + /* The GROUP have to be in the first entry */
18 if (retval >= 0)
19 {
20 int cnt;
21 + gid_t sg, tg;
22 + sg = group;
23 for (cnt = 0; cnt < retval; ++cnt)
24 - if ((*groupsp)[cnt] == group)
25 + {
26 + tg = (*groupsp)[cnt];
27 + (*groupsp)[cnt] = sg;
28 + if (tg == group)
29 break;
30 + sg = tg;
31 + }
32
33 if (cnt == retval)
34 - (*groupsp)[retval++] = group;
35 + (*groupsp)[retval++] = sg;
36 }
37
38 out_close: