--- cups-pdf-3.0.1/src/cups-pdf.c.1 2018-05-05 09:12:47.326242438 +0000 +++ cups-pdf-3.0.1/src/cups-pdf.c 2018-05-05 09:13:03.182785706 +0000 @@ -62,6 +62,55 @@ #include "cups-pdf.h" +#ifdef __sun +// Solaris does not have getgrouplist +#include +int +getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt) +{ + const struct group *grp; + int i, maxgroups, ngroups, ret; + + ret = 0; + ngroups = 0; + maxgroups = *grpcnt; + /* + * When installing primary group, duplicate it; + * the first element of groups is the effective gid + * and will be overwritten when a setgid file is executed. + */ + groups ? groups[ngroups++] = agroup : ngroups++; + if (maxgroups > 1) + groups ? groups[ngroups++] = agroup : ngroups++; + /* + * Scan the group file to find additional groups. + */ + setgrent(); + while ((grp = getgrent()) != NULL) { + if (groups) { + for (i = 0; i < ngroups; i++) { + if (grp->gr_gid == groups[i]) + goto skip; + } + } + for (i = 0; grp->gr_mem[i]; i++) { + if (!strcmp(grp->gr_mem[i], uname)) { + if (ngroups >= maxgroups) { + ret = -1; + break; + } + groups ? groups[ngroups++] = grp->gr_gid : ngroups++; + break; + } + } +skip: + ; + } + endgrent(); + *grpcnt = ngroups; + return (ret); +} +#endif static FILE *logfp=NULL;