11/*
22 * Authorization routines for the CUPS scheduler.
33 *
4- * Copyright © 2020-2024 by OpenPrinting.
4+ * Copyright © 2020-2026 by OpenPrinting.
55 * Copyright © 2007-2019 by Apple Inc.
66 * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
77 *
@@ -1184,7 +1184,7 @@ cupsdCheckGroup(
11841184 group = getgrnam (groupname );
11851185 endgrent ();
11861186
1187- if (group != NULL )
1187+ if (user && group )
11881188 {
11891189 /*
11901190 * Group exists, check it...
@@ -1198,7 +1198,7 @@ cupsdCheckGroup(
11981198 * User appears in the group membership...
11991199 */
12001200
1201- if (!_cups_strcasecmp ( username , group -> gr_mem [i ]))
1201+ if (!strcmp ( user -> pw_name , group -> gr_mem [i ]))
12021202 return (1 );
12031203 }
12041204
@@ -1209,25 +1209,24 @@ cupsdCheckGroup(
12091209 * belongs to...
12101210 */
12111211
1212- if (user )
1213- {
1214- int ngroups ; /* Number of groups */
1212+ int ngroups ; /* Number of groups */
12151213# ifdef __APPLE__
1216- int groups [2048 ]; /* Groups that user belongs to */
1214+ int groups [2048 ]; /* Groups that user belongs to */
12171215# else
1218- gid_t groups [2048 ]; /* Groups that user belongs to */
1216+ gid_t groups [2048 ]; /* Groups that user belongs to */
12191217# endif /* __APPLE__ */
12201218
1221- ngroups = (int )(sizeof (groups ) / sizeof (groups [0 ]));
1219+ ngroups = (int )(sizeof (groups ) / sizeof (groups [0 ]));
12221220# ifdef __APPLE__
1223- getgrouplist (username , (int )user -> pw_gid , groups , & ngroups );
1221+ getgrouplist (user -> pw_name , (int )user -> pw_gid , groups , & ngroups );
12241222# else
1225- getgrouplist (username , user -> pw_gid , groups , & ngroups );
1223+ getgrouplist (user -> pw_name , user -> pw_gid , groups , & ngroups );
12261224#endif /* __APPLE__ */
12271225
1228- for (i = 0 ; i < ngroups ; i ++ )
1229- if ((int )groupid == (int )groups [i ])
1230- return (1 );
1226+ for (i = 0 ; i < ngroups ; i ++ )
1227+ {
1228+ if ((int )groupid == (int )groups [i ])
1229+ return (1 );
12311230 }
12321231#endif /* HAVE_GETGROUPLIST */
12331232 }
@@ -1837,7 +1836,7 @@ cupsdIsAuthorized(cupsd_client_t *con, /* I - Connection */
18371836 name = (char * )cupsArrayNext (best -> names ))
18381837 {
18391838 if (!_cups_strcasecmp (name , "@OWNER" ) && owner &&
1840- !_cups_strcasecmp ( username , ownername ))
1839+ !strcmp ( pw -> pw_name , ownername ))
18411840 return (HTTP_OK );
18421841 else if (!_cups_strcasecmp (name , "@SYSTEM" ))
18431842 {
@@ -1849,7 +1848,7 @@ cupsdIsAuthorized(cupsd_client_t *con, /* I - Connection */
18491848 if (cupsdCheckGroup (username , pw , name + 1 ))
18501849 return (HTTP_OK );
18511850 }
1852- else if (! _cups_strcasecmp ( username , name ))
1851+ else if (pw && ! strcmp ( pw -> pw_name , name ))
18531852 return (HTTP_OK );
18541853 }
18551854
0 commit comments