summaryrefslogtreecommitdiff
path: root/usr/src/lib/print
diff options
context:
space:
mode:
authorsonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM>2009-05-28 04:36:53 -0700
committersonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM>2009-05-28 04:36:53 -0700
commitf4a94ada79e5d2be49a574fa7fba9364c57b05d9 (patch)
tree363b5cdfaa6d23ab20cf1dfc6fa5a2be88acd0fd /usr/src/lib/print
parentbda1f129971950880940a17bab0bf096d5744b0c (diff)
downloadillumos-gate-f4a94ada79e5d2be49a574fa7fba9364c57b05d9.tar.gz
6827166 A request submitted from client to server using "ipp" service cannot be canceled using "lpd" service
Diffstat (limited to 'usr/src/lib/print')
-rw-r--r--usr/src/lib/print/libipp-listener/common/print-job.c68
1 files changed, 36 insertions, 32 deletions
diff --git a/usr/src/lib/print/libipp-listener/common/print-job.c b/usr/src/lib/print/libipp-listener/common/print-job.c
index 59e00322ad..29d6b5c5be 100644
--- a/usr/src/lib/print/libipp-listener/common/print-job.c
+++ b/usr/src/lib/print/libipp-listener/common/print-job.c
@@ -51,6 +51,7 @@ ipp_print_job(papi_service_t svc, papi_attribute_t **request,
ssize_t rc;
char buf[BUFSIZ];
char *host = NULL;
+ int fp = -1;
char *keys[] = { "attributes-natural-language", "attributes-charset",
"printer-uri", NULL };
@@ -99,46 +100,49 @@ ipp_print_job(papi_service_t svc, papi_attribute_t **request,
}
}
- /* Set "job-originating-host-name" attribute if not set */
- papiAttributeListGetString(job_attributes, NULL,
- "job-originating-host-name", &host);
-
- if (host == NULL) {
- int fd = -1;
- (void) papiAttributeListGetInteger(request, NULL,
- "peer-socket", &fd);
-
- if (fd != -1) {
- struct sockaddr_in peer;
- int peer_len;
-
- peer_len = sizeof (peer);
- if (getpeername(fd, (struct sockaddr *)&peer,
- &peer_len) == 0) {
- struct hostent *he;
- int error_num;
-
- he = getipnodebyaddr(&peer.sin_addr,
- sizeof (peer.sin_addr),
- peer.sin_family, &error_num);
-
- if ((he != NULL) && (he->h_name != NULL)) {
+ /* Set "job-originating-host-name" in next block */
+ (void) papiAttributeListGetInteger(request, NULL,
+ "peer-socket", &fp);
+
+ if (fp != -1) {
+ struct sockaddr_in peer;
+ socklen_t peer_len = sizeof (peer);
+
+ /* who is our peer ? */
+ if (getpeername(fp, (struct sockaddr *)&peer,
+ &peer_len) == 0) {
+ struct hostent *he;
+ int error_num;
+
+ /*
+ * get their name or return a string containing
+ * their address
+ */
+ if ((he = getipnodebyaddr((const char *)&peer.sin_addr,
+ sizeof (peer.sin_addr), peer.sin_family,
+ &error_num)) == NULL) {
+ char tmp_buf[INET6_ADDRSTRLEN];
+ papiAttributeListAddString(
+ &job_attributes,
+ PAPI_ATTR_REPLACE,
+ "job-originating-host-name",
+ (char *)inet_ntop(peer.sin_family,
+ &peer.sin_addr, tmp_buf,
+ sizeof (tmp_buf)));
+
+ } else {
+ if (is_localhost(he->h_name) != 0)
papiAttributeListAddString(
&job_attributes,
PAPI_ATTR_REPLACE,
"job-originating-host-name",
- he->h_name);
- } else {
- /*
- * Node-name could not be read
- * so set the ip-address
- */
+ "localhost");
+ else if (he->h_name != NULL)
papiAttributeListAddString(
&job_attributes,
PAPI_ATTR_REPLACE,
"job-originating-host-name",
- inet_ntoa(peer.sin_addr));
- }
+ he->h_name);
}
}
}