cups/http.h:
- Add httpAddrLength() function.
cups/http-addr.c:
- httpAddrLength(): Added.
scheduler/conf.c:
- get_address(): Return immediately if we have a domain
socket address.
- read_configuration(): Only default to IPv6 if the local
system supports it and we are not using OpenBSD.
scheduler/listen.c:
- StartListening(): Use httpAddrLength() for bind calls,
and revamp the logging to be more useful.
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@4697
7a7537e8-13f0-0310-91df-
b6672ffda945
}
+/*
+ * 'httpAddrLength()' - Return the length of the address in bytes.
+ */
+
+int /* O - Length in bytes */
+httpAddrLength(const http_addr_t *addr) /* I - Address */
+{
+#ifdef AF_INET6
+ if (addr->addr.sa_family == AF_INET6)
+ return (sizeof(addr->ipv6));
+ else
+#endif /* AF_INET6 */
+#ifdef AF_LOCAL
+ if (addr->addr.sa_family == AF_LOCAL)
+ return (sizeof(addr->un.sun_family) + strlen(addr->un.sun_path));
+ else
+#endif /* AF_LOCAL */
+ if (addr->addr.sa_family == AF_INET)
+ return (sizeof(addr->ipv4));
+ else
+ return (0);
+
+}
+
+
/*
* 'httpAddrLoad()' - Load a host entry address into an HTTP address.
*/
extern int httpAddrAny(const http_addr_t *addr);
extern int httpAddrEqual(const http_addr_t *addr1,
const http_addr_t *addr2);
+extern int httpAddrLength(const http_addr_t *addr);
extern void httpAddrLoad(const struct hostent *host, int port,
int n, http_addr_t *addr);
extern int httpAddrLocalhost(const http_addr_t *addr);
address->un.sun_family = AF_LOCAL;
strcpy(address->un.sun_path, value);
+
+ return (1);
}
- else
#endif /* AF_LOCAL */
/*
memset(lis, 0, sizeof(listener_t));
-#ifdef AF_INET6
+#if defined(AF_INET6) && !defined(__OpenBSD__)
if (get_address(value, INADDR_ANY, IPP_PORT, AF_INET6, &(lis->address)))
#else
if (get_address(value, INADDR_ANY, IPP_PORT, AF_INET, &(lis->address)))
-#endif /* AF_INET6 */
+#endif /* AF_INET6 && !__OpenBSD__ */
{
httpAddrString(&(lis->address), temp, sizeof(temp));
#endif /* AF_LOCAL */
p = ntohs(lis->address.ipv4.sin_port);
- LogMessage(L_DEBUG, "StartListening: address=%s port=%d", s, p);
-
/*
* Save the first port that is bound to the local loopback or
* "any" address...
exit(errno);
}
- LogMessage(L_DEBUG2, "StartListening: fd=%d", lis->fd);
-
fcntl(lis->fd, F_SETFD, fcntl(lis->fd, F_GETFD) | FD_CLOEXEC);
/*
if (lis->address.addr.sa_family == AF_INET6)
{
status = bind(lis->fd, (struct sockaddr *)&(lis->address),
- sizeof(lis->address.ipv6));
+ httpAddrLength(&(lis->address)));
#ifdef IPV6_V6ONLY
if (status >= 0 &&
/*
* Make sure that wildcard and loopback addresses accept
* connections from both IPv6 and IPv4 clients.
+ *
+ * NOTE: This DOES NOT WORK for OpenBSD, since they adopted a
+ * stricter behavior in the name of security. For OpenBSD,
+ * you must list IPv4 and IPv6 listen addresses separately.
*/
val = 0;
*/
status = bind(lis->fd, (struct sockaddr *)&(lis->address),
- SUN_LEN(&(lis->address.un)));
+ httpAddrLength(&(lis->address)));
/*
* Restore the umask...
s, p, strerror(errno));
exit(errno);
}
+
+ if (p)
+ LogMessage(L_INFO, "StartListening: Listening to %s:%d on fd %d...",
+ s, p, lis->fd);
+ else
+ LogMessage(L_INFO, "StartListening: Listening to %s on fd %d...",
+ s, lis->fd);
}
/*