MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsdCheckAccess

Function cupsdCheckAccess

scheduler/auth.c:914–967  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

912 */
913
914int /* O - 1 if allowed, 0 otherwise */
915cupsdCheckAccess(
916 unsigned ip[4], /* I - Client address */
917 const char *name, /* I - Client hostname */
918 size_t namelen, /* I - Length of hostname */
919 cupsd_location_t *loc) /* I - Location to check */
920{
921 int allow; /* 1 if allowed, 0 otherwise */
922
923
924 if (!_cups_strcasecmp(name, "localhost"))
925 {
926 /*
927 * Access from localhost (127.0.0.1 or ::1) is always allowed...
928 */
929
930 return (1);
931 }
932 else
933 {
934 /*
935 * Do authorization checks on the domain/address...
936 */
937
938 switch (loc->order_type)
939 {
940 default :
941 allow = 0; /* anti-compiler-warning-code */
942 break;
943
944 case CUPSD_AUTH_ALLOW : /* Order Deny,Allow */
945 allow = 1;
946
947 if (cupsdCheckAuth(ip, name, namelen, loc->deny))
948 allow = 0;
949
950 if (cupsdCheckAuth(ip, name, namelen, loc->allow))
951 allow = 1;
952 break;
953
954 case CUPSD_AUTH_DENY : /* Order Allow,Deny */
955 allow = 0;
956
957 if (cupsdCheckAuth(ip, name, namelen, loc->allow))
958 allow = 1;
959
960 if (cupsdCheckAuth(ip, name, namelen, loc->deny))
961 allow = 0;
962 break;
963 }
964 }
965
966 return (allow);
967}
968
969
970/*

Callers 1

cupsdIsAuthorizedFunction · 0.85

Calls 2

_cups_strcasecmpFunction · 0.85
cupsdCheckAuthFunction · 0.85

Tested by

no test coverage detected