summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2013-08-01 22:23:18 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2013-08-01 22:23:18 +0000
commitf2534050299c6558a8c6346660e305b22904d1b6 (patch)
tree5f2363e77192c4acfc11cbc8263892b1d5c48ef2
parentf6008c81b92b998c8453fdb0e5fc9b0a0479fba1 (diff)
The scheduler did not respond using the hostname specified by the client
(<rdar://problem/14583574>) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11213 a1ca3aef-8c08-0410-bb20-df032aa958be
-rw-r--r--CHANGES.txt4
-rw-r--r--scheduler/client.c85
-rw-r--r--scheduler/client.h2
-rw-r--r--scheduler/ipp.c24
4 files changed, 60 insertions, 55 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index aaba117b1..5edabe67c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,8 +1,10 @@
-CHANGES.txt - 1.7.0 - 2013-07-26
+CHANGES.txt - 1.7.0 - 2013-08-01
--------------------------------
CHANGES IN CUPS V1.7.0
+ - The scheduler did not respond using the hostname specified by the
+ client (<rdar://problem/14583574>)
- Fax queues did not work when shared via Bonjour
(<rdar://problem/14498310>)
- Error messages from the scheduler were not localized using the
diff --git a/scheduler/client.c b/scheduler/client.c
index dd5eddef3..01d620f60 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -4139,11 +4139,27 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
{
cupsd_alias_t *a; /* Current alias */
cupsd_netif_t *netif; /* Current network interface */
- const char *host, /* Host field */
- *end; /* End character */
+ const char *end; /* End character */
+ char *ptr; /* Pointer into host value */
- host = con->http.fields[HTTP_FIELD_HOST];
+ /*
+ * Copy the Host: header for later use...
+ */
+
+ strlcpy(con->clientname, con->http.fields[HTTP_FIELD_HOST],
+ sizeof(con->clientname));
+ if ((ptr = strrchr(con->clientname, ':')) != NULL && !strchr(ptr, ']'))
+ {
+ *ptr++ = '\0';
+ con->clientport = atoi(ptr);
+ }
+ else
+ con->clientport = con->serverport;
+
+ /*
+ * Then validate...
+ */
if (httpAddrLocalhost(con->http.hostaddr))
{
@@ -4152,18 +4168,13 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
* addresses when accessing CUPS via the loopback interface...
*/
- return (!_cups_strcasecmp(host, "localhost") ||
- !_cups_strncasecmp(host, "localhost:", 10) ||
- !_cups_strcasecmp(host, "localhost.") ||
- !_cups_strncasecmp(host, "localhost.:", 11) ||
+ return (!_cups_strcasecmp(con->clientname, "localhost") ||
+ !_cups_strcasecmp(con->clientname, "localhost.") ||
#ifdef __linux
- !_cups_strcasecmp(host, "localhost.localdomain") ||
- !_cups_strncasecmp(host, "localhost.localdomain:", 22) ||
+ !_cups_strcasecmp(con->clientname, "localhost.localdomain") ||
#endif /* __linux */
- !strcmp(host, "127.0.0.1") ||
- !strncmp(host, "127.0.0.1:", 10) ||
- !strcmp(host, "[::1]") ||
- !strncmp(host, "[::1]:", 6));
+ !strcmp(con->clientname, "127.0.0.1") ||
+ !strcmp(con->clientname, "[::1]"));
}
#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
@@ -4171,19 +4182,18 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
* Check if the hostname is something.local (Bonjour); if so, allow it.
*/
- if ((end = strrchr(host, '.')) != NULL && end > host &&
- (!end[1] || end[1] == ':'))
+ if ((end = strrchr(con->clientname, '.')) != NULL && end > con->clientname &&
+ !end[1])
{
/*
* "." on end, work back to second-to-last "."...
*/
- for (end --; end > host && *end != '.'; end --);
+
+ for (end --; end > con->clientname && *end != '.'; end --);
}
if (end && (!_cups_strcasecmp(end, ".local") ||
- !_cups_strncasecmp(end, ".local:", 7) ||
- !_cups_strcasecmp(end, ".local.") ||
- !_cups_strncasecmp(end, ".local.:", 8)))
+ !_cups_strcasecmp(end, ".local.")))
return (1);
#endif /* HAVE_DNSSD || HAVE_AVAHI */
@@ -4191,22 +4201,16 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
* Check if the hostname is an IP address...
*/
- if (isdigit(*host & 255) || *host == '[')
+ if (isdigit(con->clientname[0] & 255) || con->clientname[0] == '[')
{
/*
* Possible IPv4/IPv6 address...
*/
- char temp[1024], /* Temporary string */
- *ptr; /* Pointer into temporary string */
http_addrlist_t *addrlist; /* List of addresses */
- strlcpy(temp, host, sizeof(temp));
- if ((ptr = strrchr(temp, ':')) != NULL && !strchr(ptr, ']'))
- *ptr = '\0'; /* Strip :port from host value */
-
- if ((addrlist = httpAddrGetList(temp, AF_UNSPEC, NULL)) != NULL)
+ if ((addrlist = httpAddrGetList(con->clientname, AF_UNSPEC, NULL)) != NULL)
{
/*
* Good IPv4/IPv6 address...
@@ -4232,16 +4236,15 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
if (!strcmp(a->name, "*"))
return (1);
- if (!_cups_strncasecmp(host, a->name, a->namelen))
+ if (!_cups_strncasecmp(con->clientname, a->name, a->namelen))
{
/*
- * Prefix matches; check the character at the end - it must be ":", ".",
- * ".:", or nul...
+ * Prefix matches; check the character at the end - it must be "." or nul.
*/
- end = host + a->namelen;
+ end = con->clientname + a->namelen;
- if (!*end || *end == ':' || (*end == '.' && (!end[1] || end[1] == ':')))
+ if (!*end || (*end == '.' && !end[1]))
return (1);
}
}
@@ -4258,16 +4261,15 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
if (!strcmp(a->name, "*"))
return (1);
- if (!_cups_strncasecmp(host, a->name, a->namelen))
+ if (!_cups_strncasecmp(con->clientname, a->name, a->namelen))
{
/*
- * Prefix matches; check the character at the end - it must be ":", ".",
- * ".:", or nul...
+ * Prefix matches; check the character at the end - it must be "." or nul.
*/
- end = host + a->namelen;
+ end = con->clientname + a->namelen;
- if (!*end || *end == ':' || (*end == '.' && (!end[1] || end[1] == ':')))
+ if (!*end || (*end == '.' && !end[1]))
return (1);
}
}
@@ -4281,16 +4283,15 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
netif;
netif = (cupsd_netif_t *)cupsArrayNext(NetIFList))
{
- if (!_cups_strncasecmp(host, netif->hostname, netif->hostlen))
+ if (!_cups_strncasecmp(con->clientname, netif->hostname, netif->hostlen))
{
/*
- * Prefix matches; check the character at the end - it must be ":", ".",
- * ".:", or nul...
+ * Prefix matches; check the character at the end - it must be "." or nul.
*/
- end = host + netif->hostlen;
+ end = con->clientname + netif->hostlen;
- if (!*end || *end == ':' || (*end == '.' && (!end[1] || end[1] == ':')))
+ if (!*end || (*end == '.' && !end[1]))
return (1);
}
}
diff --git a/scheduler/client.h b/scheduler/client.h
index 293597135..87e4505be 100644
--- a/scheduler/client.h
+++ b/scheduler/client.h
@@ -54,6 +54,8 @@ struct cupsd_client_s
int auto_ssl; /* Automatic test for SSL/TLS */
#endif /* HAVE_SSL */
http_addr_t clientaddr; /* Client address */
+ char clientname[256];/* Client's server name for connection */
+ int clientport; /* Client's server port for connection */
char servername[256];/* Server name for connection */
int serverport; /* Server port for connection */
#ifdef HAVE_GSSAPI
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index d04f8c4ff..5a5ed2e22 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -1992,7 +1992,7 @@ add_job(cupsd_client_t *con, /* I - Client connection */
*/
httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
- con->servername, con->serverport, "/jobs/%d", job->id);
+ con->clientname, con->clientport, "/jobs/%d", job->id);
ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL,
job_uri);
@@ -4064,7 +4064,7 @@ close_job(cupsd_client_t *con, /* I - Client connection */
*/
httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
- con->servername, con->serverport, "/jobs/%d", job->id);
+ con->clientname, con->clientport, "/jobs/%d", job->id);
ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL,
job_uri);
@@ -4816,7 +4816,7 @@ copy_job_attrs(cupsd_client_t *con, /* I - Client connection */
(!ra || cupsArrayFind(ra, "job-more-info")))
{
httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "http",
- NULL, con->servername, con->serverport, "/jobs/%d",
+ NULL, con->clientname, con->clientport, "/jobs/%d",
job->id);
ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI,
"job-more-info", NULL, job_uri);
@@ -4837,7 +4837,7 @@ copy_job_attrs(cupsd_client_t *con, /* I - Client connection */
if (!ra || cupsArrayFind(ra, "job-printer-uri"))
{
httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
- con->servername, con->serverport,
+ con->clientname, con->clientport,
(job->dtype & CUPS_PRINTER_CLASS) ? "/classes/%s" :
"/printers/%s",
job->dest);
@@ -4848,7 +4848,7 @@ copy_job_attrs(cupsd_client_t *con, /* I - Client connection */
if (!ra || cupsArrayFind(ra, "job-uri"))
{
httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
- con->servername, con->serverport, "/jobs/%d",
+ con->clientname, con->clientport, "/jobs/%d",
job->id);
ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI,
"job-uri", NULL, job_uri);
@@ -4911,8 +4911,8 @@ copy_printer_attrs(
else
{
httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri,
- sizeof(printer_uri), "ipp", NULL, con->servername,
- con->serverport,
+ sizeof(printer_uri), "ipp", NULL, con->clientname,
+ con->clientport,
(p2->type & CUPS_PRINTER_CLASS) ?
"/classes/%s" : "/printers/%s", p2->name);
member_uris->values[i].string.text = _cupsStrAlloc(printer_uri);
@@ -4973,7 +4973,7 @@ copy_printer_attrs(
if (!ra || cupsArrayFind(ra, "printer-icons"))
{
httpAssembleURIf(HTTP_URI_CODING_ALL, printer_icons, sizeof(printer_icons),
- "http", NULL, con->servername, con->serverport,
+ "http", NULL, con->clientname, con->clientport,
"/icons/%s.png", printer->name);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-icons",
NULL, printer_icons);
@@ -4991,7 +4991,7 @@ copy_printer_attrs(
if (!ra || cupsArrayFind(ra, "printer-more-info"))
{
httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
- "http", NULL, con->servername, con->serverport,
+ "http", NULL, con->clientname, con->clientport,
(printer->type & CUPS_PRINTER_CLASS) ?
"/classes/%s" : "/printers/%s", printer->name);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI,
@@ -5047,7 +5047,7 @@ copy_printer_attrs(
if (!ra || cupsArrayFind(ra, "printer-uri-supported"))
{
httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
- "ipp", NULL, con->servername, con->serverport,
+ "ipp", NULL, con->clientname, con->clientport,
(printer->type & CUPS_PRINTER_CLASS) ?
"/classes/%s" : "/printers/%s", printer->name);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI,
@@ -5174,7 +5174,7 @@ copy_subscription_attrs(
if (sub->dest && (!ra || cupsArrayFind(ra, "notify-printer-uri")))
{
httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
- "ipp", NULL, con->servername, con->serverport,
+ "ipp", NULL, con->clientname, con->clientport,
"/printers/%s", sub->dest->name);
ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI,
"notify-printer-uri", NULL, printer_uri);
@@ -9558,7 +9558,7 @@ send_document(cupsd_client_t *con, /* I - Client connection */
*/
httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
- con->servername, con->serverport, "/jobs/%d", jobid);
+ con->clientname, con->clientport, "/jobs/%d", jobid);
ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL,
job_uri);