- if (user && group && group->gr_gid == user->pw_gid)
- return (1);
-
- /*
- * Username not found, group not found, or user is not part of the
- * system group... Check for a user and group in the MD5 password
- * file...
- */
-
- if (cupsdGetMD5Passwd(username, groupname, junk) != NULL)
- return (1);
-
- /*
- * If we get this far, then the user isn't part of the named group...
- */
-
- return (0);
-}
-
-
-/*
- * 'cupsdCopyLocation()' - Make a copy of a location...
- */
-
-cupsd_location_t * /* O - New location */
-cupsdCopyLocation(
- cupsd_location_t **loc) /* IO - Original location */
-{
- int i; /* Looping var */
- int locindex; /* Index into Locations array */
- cupsd_location_t *temp; /* New location */
- char location[HTTP_MAX_URI];
- /* Location of resource */
-
-
- /*
- * Add the new location, updating the original location
- * pointer as needed...
- */
-
- locindex = *loc - Locations;
-
- /*
- * Use a local copy of location because cupsdAddLocation may cause
- * this memory to be moved...
- */
-
- strlcpy(location, (*loc)->location, sizeof(location));
-
- if ((temp = cupsdAddLocation(location)) == NULL)
- return (NULL);
-
- *loc = Locations + locindex;
-
- /*
- * Copy the information from the original location to the new one.
- */
-
- temp->limit = (*loc)->limit;
- temp->order_type = (*loc)->order_type;
- temp->type = (*loc)->type;
- temp->level = (*loc)->level;
- temp->satisfy = (*loc)->satisfy;
- temp->encryption = (*loc)->encryption;
-
- if ((temp->num_names = (*loc)->num_names) > 0)
- {
- /*
- * Copy the names array...
- */
-
- if ((temp->names = calloc(temp->num_names, sizeof(char *))) == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdCopyLocation: Unable to allocate memory for %d names: %s",
- temp->num_names, strerror(errno));
- NumLocations --;
- return (NULL);
- }
-
- for (i = 0; i < temp->num_names; i ++)
- if ((temp->names[i] = strdup((*loc)->names[i])) == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdCopyLocation: Unable to copy name \"%s\": %s",
- (*loc)->names[i], strerror(errno));
-
- NumLocations --;
- return (NULL);
- }
- }
-
- if ((temp->num_allow = (*loc)->num_allow) > 0)
- {
- /*
- * Copy allow rules...
- */
-
- if ((temp->allow = calloc(temp->num_allow, sizeof(cupsd_authmask_t))) == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdCopyLocation: Unable to allocate memory for %d allow rules: %s",
- temp->num_allow, strerror(errno));
- NumLocations --;
- return (NULL);
- }
-
- for (i = 0; i < temp->num_allow; i ++)
- switch (temp->allow[i].type = (*loc)->allow[i].type)
- {
- case AUTH_NAME :
- temp->allow[i].mask.name.length = (*loc)->allow[i].mask.name.length;
- temp->allow[i].mask.name.name = strdup((*loc)->allow[i].mask.name.name);
-
- if (temp->allow[i].mask.name.name == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdCopyLocation: Unable to copy allow name \"%s\": %s",
- (*loc)->allow[i].mask.name.name, strerror(errno));
- NumLocations --;
- return (NULL);
- }
- break;
- case AUTH_IP :
- memcpy(&(temp->allow[i].mask.ip), &((*loc)->allow[i].mask.ip),
- sizeof(cupsd_ipmask_t));
- break;
- }
- }
-
- if ((temp->num_deny = (*loc)->num_deny) > 0)
- {
- /*
- * Copy deny rules...
- */
-
- if ((temp->deny = calloc(temp->num_deny, sizeof(cupsd_authmask_t))) == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdCopyLocation: Unable to allocate memory for %d deny rules: %s",
- temp->num_deny, strerror(errno));
- NumLocations --;
- return (NULL);
- }
-
- for (i = 0; i < temp->num_deny; i ++)
- switch (temp->deny[i].type = (*loc)->deny[i].type)
- {
- case AUTH_NAME :
- temp->deny[i].mask.name.length = (*loc)->deny[i].mask.name.length;
- temp->deny[i].mask.name.name = strdup((*loc)->deny[i].mask.name.name);
-
- if (temp->deny[i].mask.name.name == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdCopyLocation: Unable to copy deny name \"%s\": %s",
- (*loc)->deny[i].mask.name.name, strerror(errno));
- NumLocations --;
- return (NULL);
- }
- break;
- case AUTH_IP :
- memcpy(&(temp->deny[i].mask.ip), &((*loc)->deny[i].mask.ip),
- sizeof(cupsd_ipmask_t));
- break;
- }
- }
-
- return (temp);
-}
-
-
-/*
- * 'cupsdDeleteAllLocations()' - Free all memory used for location authorization.
- */
-
-void
-cupsdDeleteAllLocations(void)
-{
- int i; /* Looping var */
- cupsd_location_t *loc; /* Current location */
-