From 0f71c41e756cd0588aa8cc825126bb9c62100f7e Mon Sep 17 00:00:00 2001 From: mike Date: Sun, 20 Jul 2003 03:13:10 +0000 Subject: [PATCH] Mirror 1.1.x changes. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3812 7a7537e8-13f0-0310-91df-b6672ffda945 --- CHANGES-1.1.txt | 4 ++++ cups/http-addr.c | 31 +++++++++++++++++++++++++++---- cups/http.h | 5 +++-- scheduler/client.c | 15 +++------------ scheduler/client.h | 9 ++++++--- scheduler/conf.c | 6 +++--- scheduler/listen.c | 24 ++++++++++++++++++++++-- 7 files changed, 68 insertions(+), 26 deletions(-) diff --git a/CHANGES-1.1.txt b/CHANGES-1.1.txt index 3842a29d0..77e5ee1a4 100644 --- a/CHANGES-1.1.txt +++ b/CHANGES-1.1.txt @@ -3,6 +3,10 @@ CHANGES-1.1.txt CHANGES IN CUPS V1.1.20rc1 + - The scheduler now passes the first port that is bound + to the local loopback or "any" addresses to the CGI + programs rather than the port that the browser + connected to (STR #103) - The cupstestppd program now checks for bad JobPatchFile attributes and incorrect versions of the Manufacturer attribute for HP printers (STR #155) diff --git a/cups/http-addr.c b/cups/http-addr.c index 12c5e7f5d..754ba16c8 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -1,5 +1,5 @@ /* - * "$Id: http-addr.c,v 1.1.2.10 2003/01/24 20:45:11 mike Exp $" + * "$Id: http-addr.c,v 1.1.2.11 2003/07/20 03:13:07 mike Exp $" * * HTTP address routines for the Common UNIX Printing System (CUPS). * @@ -23,6 +23,7 @@ * * Contents: * + * httpAddrAny() - Check for the "any" address. * httpAddrEqual() - Compare two addresses. * httpAddrLoad() - Load a host entry address into an HTTP address. * httpAddrLocalhost() - Check for the local loopback address. @@ -41,6 +42,27 @@ #include "string.h" +/* + * 'httpAddrAny()' - Check for the "any" address. + */ + +int /* O - 1 if "any", 0 otherwise */ +httpAddrAny(const http_addr_t *addr) /* I - Address to check */ +{ +#ifdef AF_INET6 + if (addr->addr.sa_family == AF_INET6 && + IN6_IS_ADDR_UNSPECIFIED(&(addr->ipv6.sin6_addr))) + return (1); +#endif /* AF_INET6 */ + + if (addr->addr.sa_family == AF_INET && + ntohl(addr->ipv4.sin_addr.s_addr) == 0x00000000) + return (1); + + return (0); +} + + /* * 'httpAddrEqual()' - Compare two addresses. */ @@ -104,8 +126,9 @@ httpAddrLoad(const struct hostent *host, /* I - Host entry */ * 'httpAddrLocalhost()' - Check for the local loopback address. */ -int /* O - 1 if local host, 1 otherwise */ -httpAddrLocalhost(const http_addr_t *addr) /* I - Address to check */ +int /* O - 1 if local host, 0 otherwise */ +httpAddrLocalhost(const http_addr_t *addr) + /* I - Address to check */ { #ifdef AF_INET6 if (addr->addr.sa_family == AF_INET6 && @@ -277,5 +300,5 @@ httpGetHostByName(const char *name) /* I - Hostname or IP address */ /* - * End of "$Id: http-addr.c,v 1.1.2.10 2003/01/24 20:45:11 mike Exp $". + * End of "$Id: http-addr.c,v 1.1.2.11 2003/07/20 03:13:07 mike Exp $". */ diff --git a/cups/http.h b/cups/http.h index 0c3d77518..13c37fe9a 100644 --- a/cups/http.h +++ b/cups/http.h @@ -1,5 +1,5 @@ /* - * "$Id: http.h,v 1.33.2.18 2003/05/09 18:35:38 mike Exp $" + * "$Id: http.h,v 1.33.2.19 2003/07/20 03:13:07 mike Exp $" * * Hyper-Text Transport Protocol definitions for the Common UNIX Printing * System (CUPS). @@ -388,6 +388,7 @@ extern void httpSetCookie(http_t *http, const char *cookie); extern int httpWait(http_t *http, int msec); /**** New in CUPS 1.2 ****/ +extern int httpAddrAny(const http_addr_t *addr); extern int httpAddrEqual(const http_addr_t *addr1, const http_addr_t *addr2); extern void httpAddrLoad(const struct hostent *host, int port, @@ -409,5 +410,5 @@ extern char *httpAddrString(const http_addr_t *addr, #endif /* !_IPP_HTTP_H_ */ /* - * End of "$Id: http.h,v 1.33.2.18 2003/05/09 18:35:38 mike Exp $". + * End of "$Id: http.h,v 1.33.2.19 2003/07/20 03:13:07 mike Exp $". */ diff --git a/scheduler/client.c b/scheduler/client.c index 4c6ffccd1..27a3331b8 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -1,5 +1,5 @@ /* - * "$Id: client.c,v 1.91.2.63 2003/07/20 01:36:50 mike Exp $" + * "$Id: client.c,v 1.91.2.64 2003/07/20 03:13:08 mike Exp $" * * Client routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -356,7 +356,6 @@ CloseAllClients(void) void CloseClient(client_t *con) /* I - Client to close */ { - int status; /* Exit status of pipe command */ #if defined(HAVE_LIBSSL) SSL_CTX *context; /* Context for encryption */ SSL *conn; /* Connection for encryption */ @@ -464,10 +463,7 @@ CloseClient(client_t *con) /* I - Client to close */ */ if (con->pipe_pid) - { kill(con->pipe_pid, SIGKILL); - waitpid(con->pipe_pid, &status, WNOHANG); - } LogMessage(L_DEBUG2, "CloseClient() %d Closing data file %d.", con->http.fd, con->file); @@ -3008,20 +3004,15 @@ pipe_command(client_t *con, /* I - Client connection */ snprintf(lang, sizeof(lang), "LANG=%s", con->language ? con->language->language : "C"); + sprintf(ipp_port, "IPP_PORT=%d", LocalPort); #ifdef AF_INET6 if (con->http.hostaddr.addr.sa_family == AF_INET6) - { - sprintf(ipp_port, "IPP_PORT=%d", ntohs(con->http.hostaddr.ipv6.sin6_port)); sprintf(server_port, "SERVER_PORT=%d", ntohs(con->http.hostaddr.ipv6.sin6_port)); - } else #endif /* AF_INET6 */ - { - sprintf(ipp_port, "IPP_PORT=%d", ntohs(con->http.hostaddr.ipv4.sin_port)); sprintf(server_port, "SERVER_PORT=%d", ntohs(con->http.hostaddr.ipv4.sin_port)); - } if (strcmp(con->http.hostname, "localhost") == 0) strlcpy(server_name, "SERVER_NAME=localhost", sizeof(server_name)); @@ -3356,5 +3347,5 @@ CDSAWriteFunc(SSLConnectionRef connection, /* I - SSL/TLS connection */ /* - * End of "$Id: client.c,v 1.91.2.63 2003/07/20 01:36:50 mike Exp $". + * End of "$Id: client.c,v 1.91.2.64 2003/07/20 03:13:08 mike Exp $". */ diff --git a/scheduler/client.h b/scheduler/client.h index df2fb3a0b..c91ba4c86 100644 --- a/scheduler/client.h +++ b/scheduler/client.h @@ -1,5 +1,5 @@ /* - * "$Id: client.h,v 1.17.2.9 2003/03/31 16:48:26 mike Exp $" + * "$Id: client.h,v 1.17.2.10 2003/07/20 03:13:09 mike Exp $" * * Client definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -66,7 +66,10 @@ typedef struct * Globals... */ -VAR int ListenBackLog VALUE(SOMAXCONN); +VAR int ListenBackLog VALUE(SOMAXCONN), + /* Max backlog of pending connections */ + LocalPort VALUE(631); + /* Local port to use */ VAR int NumListeners VALUE(0); /* Number of listening sockets */ VAR listener_t *Listeners VALUE(NULL); @@ -107,5 +110,5 @@ extern int WriteClient(client_t *con); /* - * End of "$Id: client.h,v 1.17.2.9 2003/03/31 16:48:26 mike Exp $". + * End of "$Id: client.h,v 1.17.2.10 2003/07/20 03:13:09 mike Exp $". */ diff --git a/scheduler/conf.c b/scheduler/conf.c index 4dd7c318c..05c51eb0d 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -1,5 +1,5 @@ /* - * "$Id: conf.c,v 1.77.2.40 2003/04/23 18:55:28 mike Exp $" + * "$Id: conf.c,v 1.77.2.41 2003/07/20 03:13:09 mike Exp $" * * Configuration routines for the Common UNIX Printing System (CUPS). * @@ -2026,7 +2026,7 @@ get_address(const char *value, /* I - Value string */ * Decode the hostname and port number as needed... */ - if (hostname[0] && strcmp(hostname, "*") != 0) + if (hostname[0] && strcmp(hostname, "*")) { if ((host = httpGetHostByName(hostname)) == NULL) { @@ -2293,5 +2293,5 @@ CDSAGetServerCerts(void) /* - * End of "$Id: conf.c,v 1.77.2.40 2003/04/23 18:55:28 mike Exp $". + * End of "$Id: conf.c,v 1.77.2.41 2003/07/20 03:13:09 mike Exp $". */ diff --git a/scheduler/listen.c b/scheduler/listen.c index cbb696655..35dad7ba6 100644 --- a/scheduler/listen.c +++ b/scheduler/listen.c @@ -1,5 +1,5 @@ /* - * "$Id: listen.c,v 1.9.2.10 2003/03/31 19:20:16 mike Exp $" + * "$Id: listen.c,v 1.9.2.11 2003/07/20 03:13:10 mike Exp $" * * Server listening routines for the Common UNIX Printing System (CUPS) * scheduler. @@ -153,6 +153,26 @@ StartListening(void) LogMessage(L_DEBUG, "StartListening: address=%s port=%d", s, ntohs(lis->address.ipv4.sin_port)); + /* + * Save the first port that is bound to the local loopback or + * "any" address... + */ + + if (httpAddrLocalhost(&(lis->address)) || + httpAddrAny(&(lis->address))) + { +#ifdef AF_INET6 + if (lis->address.addr.sa_family == AF_INET6) + LocalPort = ntohs(lis->address.ipv6.sin6_port); + else +#endif /* AF_INET6 */ + LocalPort = ntohs(lis->address.ipv4.sin_port); + } + + /* + * Create a socket for listening... + */ + if ((lis->fd = socket(lis->address.addr.sa_family, SOCK_STREAM, 0)) == -1) { LogMessage(L_ERROR, "StartListening: Unable to open listen socket - %s.", @@ -235,5 +255,5 @@ StopListening(void) /* - * End of "$Id: listen.c,v 1.9.2.10 2003/03/31 19:20:16 mike Exp $". + * End of "$Id: listen.c,v 1.9.2.11 2003/07/20 03:13:10 mike Exp $". */ -- 2.39.5