| 972 | */ |
| 973 | |
| 974 | int /* O - 1 if mask matches, 0 otherwise */ |
| 975 | cupsdCheckAuth(unsigned ip[4], /* I - Client address */ |
| 976 | const char *name, /* I - Client hostname */ |
| 977 | size_t name_len, /* I - Length of hostname */ |
| 978 | cups_array_t *masks) /* I - Masks */ |
| 979 | { |
| 980 | int i; /* Looping var */ |
| 981 | cupsd_authmask_t *mask; /* Current mask */ |
| 982 | cupsd_netif_t *iface; /* Network interface */ |
| 983 | unsigned netip4; /* IPv4 network address */ |
| 984 | #ifdef AF_INET6 |
| 985 | unsigned netip6[4]; /* IPv6 network address */ |
| 986 | #endif /* AF_INET6 */ |
| 987 | |
| 988 | |
| 989 | for (mask = (cupsd_authmask_t *)cupsArrayFirst(masks); |
| 990 | mask; |
| 991 | mask = (cupsd_authmask_t *)cupsArrayNext(masks)) |
| 992 | { |
| 993 | switch (mask->type) |
| 994 | { |
| 995 | case CUPSD_AUTH_INTERFACE : |
| 996 | /* |
| 997 | * Check for a match with a network interface... |
| 998 | */ |
| 999 | |
| 1000 | netip4 = htonl(ip[3]); |
| 1001 | |
| 1002 | #ifdef AF_INET6 |
| 1003 | netip6[0] = htonl(ip[0]); |
| 1004 | netip6[1] = htonl(ip[1]); |
| 1005 | netip6[2] = htonl(ip[2]); |
| 1006 | netip6[3] = htonl(ip[3]); |
| 1007 | #endif /* AF_INET6 */ |
| 1008 | |
| 1009 | cupsdNetIFUpdate(); |
| 1010 | |
| 1011 | if (!strcmp(mask->mask.name.name, "*")) |
| 1012 | { |
| 1013 | #ifdef __APPLE__ |
| 1014 | /* |
| 1015 | * Allow Back-to-My-Mac addresses... |
| 1016 | */ |
| 1017 | |
| 1018 | if ((ip[0] & 0xff000000) == 0xfd000000) |
| 1019 | return (1); |
| 1020 | #endif /* __APPLE__ */ |
| 1021 | |
| 1022 | /* |
| 1023 | * Check against all local interfaces... |
| 1024 | */ |
| 1025 | |
| 1026 | for (iface = (cupsd_netif_t *)cupsArrayFirst(NetIFList); |
| 1027 | iface; |
| 1028 | iface = (cupsd_netif_t *)cupsArrayNext(NetIFList)) |
| 1029 | { |
| 1030 | /* |
| 1031 | * Only check local interfaces... |
no test coverage detected