fmt: update to 11.1.3
[oi-userland.git] / components / print / cups-pdf / patches / 01-getgrouplist.patch
blobe74aa6b4ad023b5d216957c5c121d2fe37546a12
1 --- cups-pdf-3.0.1/src/cups-pdf.c.1 2018-05-05 09:12:47.326242438 +0000
2 +++ cups-pdf-3.0.1/src/cups-pdf.c 2018-05-05 09:13:03.182785706 +0000
3 @@ -62,6 +62,55 @@
5 #include "cups-pdf.h"
7 +#ifdef __sun
8 +// Solaris does not have getgrouplist
9 +#include <string.h>
10 +int
11 +getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
13 + const struct group *grp;
14 + int i, maxgroups, ngroups, ret;
16 + ret = 0;
17 + ngroups = 0;
18 + maxgroups = *grpcnt;
19 + /*
20 + * When installing primary group, duplicate it;
21 + * the first element of groups is the effective gid
22 + * and will be overwritten when a setgid file is executed.
23 + */
24 + groups ? groups[ngroups++] = agroup : ngroups++;
25 + if (maxgroups > 1)
26 + groups ? groups[ngroups++] = agroup : ngroups++;
27 + /*
28 + * Scan the group file to find additional groups.
29 + */
30 + setgrent();
31 + while ((grp = getgrent()) != NULL) {
32 + if (groups) {
33 + for (i = 0; i < ngroups; i++) {
34 + if (grp->gr_gid == groups[i])
35 + goto skip;
36 + }
37 + }
38 + for (i = 0; grp->gr_mem[i]; i++) {
39 + if (!strcmp(grp->gr_mem[i], uname)) {
40 + if (ngroups >= maxgroups) {
41 + ret = -1;
42 + break;
43 + }
44 + groups ? groups[ngroups++] = grp->gr_gid : ngroups++;
45 + break;
46 + }
47 + }
48 +skip:
49 + ;
50 + }
51 + endgrent();
52 + *grpcnt = ngroups;
53 + return (ret);
55 +#endif
57 static FILE *logfp=NULL;