summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorKeerthi Kondaka <Keerthi.Kondaka@Sun.COM>2009-04-21 16:35:55 -0700
committerKeerthi Kondaka <Keerthi.Kondaka@Sun.COM>2009-04-21 16:35:55 -0700
commite059026e2da8f12ef0ebea9d686d67f32660cfc0 (patch)
tree695c417c9f8a1526c7ea7dc3a93dde1f25b41ab7 /usr/src
parent37c30c18a30adf1c89f3e563208e93e6c7501ded (diff)
downloadillumos-gate-e059026e2da8f12ef0ebea9d686d67f32660cfc0.tar.gz
6783023 lpstat -v dumps core without printer name
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/lpstat.c2
-rw-r--r--usr/src/lib/print/libpapi-common/common/uri.c39
-rw-r--r--usr/src/lib/print/libpapi-dynamic/common/nss.c14
-rw-r--r--usr/src/lib/print/libpapi-ipp/common/ipp-support.c2
-rw-r--r--usr/src/lib/print/libpapi-lpd/common/lpd-misc.c16
5 files changed, 42 insertions, 31 deletions
diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c
index 789661b2e0..c66dd15720 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c
@@ -234,7 +234,7 @@ report_device(papi_service_t svc, char *name, papi_printer_t printer,
return (0);
} else if (uri != NULL) {
printf(gettext("system for %s: %s (as %s)\n"), name,
- u->host, uri);
+ u->host?u->host:"localhost", uri);
return (0);
}
diff --git a/usr/src/lib/print/libpapi-common/common/uri.c b/usr/src/lib/print/libpapi-common/common/uri.c
index ee45af9592..303005ab94 100644
--- a/usr/src/lib/print/libpapi-common/common/uri.c
+++ b/usr/src/lib/print/libpapi-common/common/uri.c
@@ -20,15 +20,13 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: uri.c 146 2006-03-24 00:26:54Z njacobs $ */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*LINTLIBRARY*/
#include <stdio.h>
@@ -179,6 +177,8 @@ uri_from_string(char *string, uri_t **uri)
int
uri_to_string(uri_t *uri, char *buffer, size_t buflen)
{
+ char *uri_ppfix;
+
if ((uri == NULL) || (buffer == NULL) || (buflen == 0) ||
(uri->scheme == NULL) ||
((uri->password != NULL) && (uri->user == NULL)) ||
@@ -189,25 +189,30 @@ uri_to_string(uri_t *uri, char *buffer, size_t buflen)
errno = EINVAL;
return (-1);
}
+ if (uri->path == NULL || uri->path[0] == '/')
+ uri_ppfix = "";
+ else
+ uri_ppfix = "/";
(void) memset(buffer, 0, buflen);
if (uri->scheme_part == NULL) {
(void) snprintf(buffer, buflen,
- "%s://%s%s%s%s%s%s%s%s%s%s%s%s%s",
- uri->scheme,
- (uri->user ? uri->user : ""),
- (uri->password ? ":" : ""),
- (uri->password ? uri->password : ""),
- (uri->user ? "@": ""),
- (uri->host ? uri->host : ""),
- (uri->port ? ":" : ""),
- (uri->port ? uri->port : ""),
- (uri->path[0] != '/' ? "/" : ""), uri->path,
- (uri->fragment ? "#" : ""),
- (uri->fragment ? uri->fragment : ""),
- (uri->query ? "?" : ""),
- (uri->query ? uri->query : ""));
+ "%s://%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ uri->scheme,
+ (uri->user ? uri->user : ""),
+ (uri->password ? ":" : ""),
+ (uri->password ? uri->password : ""),
+ (uri->user ? "@": ""),
+ (uri->host ? uri->host : ""),
+ (uri->port ? ":" : ""),
+ (uri->port ? uri->port : ""),
+ uri_ppfix,
+ (uri->path ? uri->path : ""),
+ (uri->fragment ? "#" : ""),
+ (uri->fragment ? uri->fragment : ""),
+ (uri->query ? "?" : ""),
+ (uri->query ? uri->query : ""));
} else {
(void) snprintf(buffer, buflen, "%s:%s", uri->scheme,
uri->scheme_part);
diff --git a/usr/src/lib/print/libpapi-dynamic/common/nss.c b/usr/src/lib/print/libpapi-dynamic/common/nss.c
index ab26d41d89..02d74b17e7 100644
--- a/usr/src/lib/print/libpapi-dynamic/common/nss.c
+++ b/usr/src/lib/print/libpapi-dynamic/common/nss.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
@@ -116,10 +116,14 @@ solaris_lpsched_shortcircuit_hack(papi_attribute_t ***list)
return;
}
- if ((printer = strrchr(uri->path, '/')) == NULL)
- printer = uri->path;
- else
- printer++;
+ if (uri->path == NULL) {
+ printer = "";
+ } else {
+ if ((printer = strrchr(uri->path, '/')) == NULL)
+ printer = uri->path;
+ else
+ printer++;
+ }
/* is there an lpsched queue (printer/class) */
snprintf(buf, sizeof (buf), "/etc/lp/interfaces/%s", printer);
diff --git a/usr/src/lib/print/libpapi-ipp/common/ipp-support.c b/usr/src/lib/print/libpapi-ipp/common/ipp-support.c
index bbdf867b12..b2caff84ac 100644
--- a/usr/src/lib/print/libpapi-ipp/common/ipp-support.c
+++ b/usr/src/lib/print/libpapi-ipp/common/ipp-support.c
@@ -379,7 +379,7 @@ ipp_send_initial_request_block(service_t *svc, papi_attribute_t **request,
httpFlush(svc->connection);
/* if we have don't have a POST path, use the service uri path */
- if (svc->post == NULL)
+ if ((svc->post == NULL) && (svc->uri->path))
svc->post = strdup(svc->uri->path);
/* send the HTTP POST message for the IPP request */
/* if the POST fails, return the error */
diff --git a/usr/src/lib/print/libpapi-lpd/common/lpd-misc.c b/usr/src/lib/print/libpapi-lpd/common/lpd-misc.c
index 9d0688c3a6..1dc9589d25 100644
--- a/usr/src/lib/print/libpapi-lpd/common/lpd-misc.c
+++ b/usr/src/lib/print/libpapi-lpd/common/lpd-misc.c
@@ -20,15 +20,13 @@
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: lpd-misc.c 155 2006-04-26 02:34:54Z ktou $ */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#define __EXTENSIONS__ /* for strtok_r() */
#include <stdio.h>
#include <stdlib.h>
@@ -156,10 +154,14 @@ lpd_open(service_t *svc, char type, char **args, int timeout)
av[ac++] = buf;
/* queue */
- if ((tmp = strrchr(svc->uri->path, '/')) == NULL)
- tmp = svc->uri->path;
- else
- tmp++;
+ if (svc->uri->path == NULL) {
+ tmp = "";
+ } else {
+ if ((tmp = strrchr(svc->uri->path, '/')) == NULL)
+ tmp = svc->uri->path;
+ else
+ tmp++;
+ }
av[ac++] = tmp;
/* args */