diff options
Diffstat (limited to 'usr/src')
29 files changed, 227 insertions, 1866 deletions
diff --git a/usr/src/cmd/lp/lib/papi/job.c b/usr/src/cmd/lp/lib/papi/job.c index 4ee09858ce..dd46165bde 100644 --- a/usr/src/cmd/lp/lib/papi/job.c +++ b/usr/src/cmd/lp/lib/papi/job.c @@ -118,14 +118,15 @@ papiJobGetId(papi_job_t job) static REQUEST * create_request(papi_service_t svc, char *printer, papi_attribute_t **attributes) { - static REQUEST r; + REQUEST *r; - memset(&r, 0, sizeof (r)); - r.priority = -1; - r.destination = printer_name_from_uri_id(printer, -1); - job_attributes_to_lpsched_request(svc, &r, attributes); + if ((r = calloc(1, sizeof (*r))) != NULL) { + r->priority = -1; + r->destination = printer_name_from_uri_id(printer, -1); + job_attributes_to_lpsched_request(svc, r, attributes); + } - return (&r); + return (r); } static papi_status_t @@ -756,6 +757,7 @@ papiJobStreamClose(papi_service_t handle, "job-uri", tmp); free(s->meta_data_file); } + freerequest(s->request); free(s); return (PAPI_OK); diff --git a/usr/src/cmd/lp/model/netpr/Makefile b/usr/src/cmd/lp/model/netpr/Makefile index f9c5455147..e5e1c1394d 100644 --- a/usr/src/cmd/lp/model/netpr/Makefile +++ b/usr/src/cmd/lp/model/netpr/Makefile @@ -2,9 +2,8 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. @@ -22,7 +21,7 @@ # # ident "%Z%%M% %I% %E% SMI" # -# Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # cmd/lp/model/netpr @@ -35,9 +34,6 @@ include ../../Makefile.lp PURIFYOPTS = -logfile=/tmp/errs.%p PURIFY = purify $(PURIFYOPTS) -LIBNPRT = -L$(ROOT)/usr/lib -lprint $(LIBINTL) - - CPPFLAGS = -I. -I$(LPINC) \ $(CPPFLAGS.master) @@ -67,8 +63,7 @@ LPLIBS = \ $(LIBOAM) \ $(LIBLP) \ $(LIBSEC) \ - $(LIBSYS) \ - $(LIBNPRT) + $(LIBSYS) SYSLIBS= -lnsl -lsocket @@ -116,7 +111,7 @@ strip: cstyle: cstyle $(SRCS) -LINTFLAGS += -L ../../../../lib/print -lprint -lnsl -lsocket +LINTFLAGS += -lnsl -lsocket lint: $(LINT.c) $(SRCS) $(LDLIBS) diff --git a/usr/src/cmd/lp/model/netpr/netpr.c b/usr/src/cmd/lp/model/netpr/netpr.c index ee2614b8f6..bdce543aa5 100644 --- a/usr/src/cmd/lp/model/netpr/netpr.c +++ b/usr/src/cmd/lp/model/netpr/netpr.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -36,15 +35,126 @@ #include <unistd.h> #include <sys/mman.h> #include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <netdb.h> #include <fcntl.h> #include <syslog.h> +#include <sys/utsname.h> #include "netpr.h" + static void usage_exit(); static void pipehandler(int); char data_file_type = 0; +/* + * null() is to be used as a signal handler that does nothing. It is used in + * place of SIG_IGN, because we want the signal to be delivered and + * interupt the current system call. + */ +static void +null(int i) +{ + syslog(LOG_DEBUG, "null(%d)", i); +} + +/* + * net_open() opens a tcp connection to the printer port on the host specified + * in the arguments passed in. If the connection is not made in the + * timeout (in seconds) passed in, an error it returned. If the host is + * unknown, an error is returned. If all is well, a file descriptor is + * returned to be used for future communications. + */ +int +net_open(char *host, int timeout) +{ + struct hostent *hp; + struct servent *sp; + struct sockaddr_in6 sin; + void (*old_handler)(); + static struct utsname uts; + + int s, + lport, + err, + error_num; + unsigned timo = 1; + + syslog(LOG_DEBUG, "net_open(%s, %d)", (host != NULL ? host : "NULL"), + timeout); + /* + * Get the host address and port number to connect to. + */ + if (host == NULL) { + return (-1); + } + + (void) memset((char *)&sin, NULL, sizeof (sin)); + if ((hp = getipnodebyname(host, AF_INET6, AI_DEFAULT, + &error_num)) == NULL) { + syslog(LOG_DEBUG|LOG_ERR, "unknown host %s " + "getipnodebyname() returned %d", host, error_num); + return (NETWORK_ERROR_HOST); + } + (void) memcpy((caddr_t)&sin.sin6_addr, hp->h_addr, hp->h_length); + sin.sin6_family = hp->h_addrtype; + freehostent(hp); + + if ((sp = getservbyname("printer", "tcp")) == NULL) { + syslog(LOG_DEBUG|LOG_ERR, "printer/tcp: unknown service"); + return (NETWORK_ERROR_SERVICE); + } + sin.sin6_port = sp->s_port; + +retry: + /* + * Try connecting to the server. + * + * Use 0 as lport means that rresvport_af() will bind to a port in + * the anonymous privileged port range. + */ + lport = 0; + s = rresvport_af(&lport, AF_INET6); + if (s < 0) + return (NETWORK_ERROR_PORT); + + old_handler = signal(SIGALRM, null); + (void) alarm(timeout); + if (connect(s, (struct sockaddr *)&sin, sizeof (sin)) < 0) { + (void) alarm(0); + (void) signal(SIGALRM, old_handler); + err = errno; + (void) close(s); + errno = err; + if (errno == EADDRINUSE) { + goto retry; + } + /* + * If connecting to the local system fails, try + * again with "localhost" address instead. + */ + if (uts.nodename[0] == '\0') + (void) uname(&uts); + if (strcmp(host, uts.nodename) == 0) { + IN6_IPADDR_TO_V4MAPPED(htonl(INADDR_LOOPBACK), + &sin.sin6_addr); + sin.sin6_family = AF_INET6; + goto retry; + } + if (errno == ECONNREFUSED && timo <= 16) { + (void) sleep(timo); + timo *= 2; + goto retry; + } + return (NETWORK_ERROR_UNKNOWN); + } + (void) alarm(0); + (void) signal(SIGALRM, old_handler); + return (s); +} + int main(int argc, char *argv[]) { diff --git a/usr/src/cmd/print/bsd-sysv-commands/common.c b/usr/src/cmd/print/bsd-sysv-commands/common.c index fbc68459f8..92a629f776 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/common.c +++ b/usr/src/cmd/print/bsd-sysv-commands/common.c @@ -400,8 +400,8 @@ strsplit(char *string, const char *seperators) } papi_status_t -jobSubmitSTDIN(papi_service_t svc, char *printer, papi_attribute_t **list, - papi_job_t *job) +jobSubmitSTDIN(papi_service_t svc, char *printer, char *prefetch, int len, + papi_attribute_t **list, papi_job_t *job) { papi_status_t status; papi_stream_t stream = NULL; @@ -409,6 +409,10 @@ jobSubmitSTDIN(papi_service_t svc, char *printer, papi_attribute_t **list, char buf[BUFSIZ]; status = papiJobStreamOpen(svc, printer, list, NULL, &stream); + + if (len > 0) + status = papiJobStreamWrite(svc, stream, prefetch, len); + while ((status == PAPI_OK) && ((rc = read(0, buf, sizeof (buf))) > 0)) status = papiJobStreamWrite(svc, stream, buf, rc); @@ -426,19 +430,12 @@ jobSubmitSTDIN(papi_service_t svc, char *printer, papi_attribute_t **list, #define PS_MAGIC "%!" #define PC_PS_MAGIC "^D%!" int -is_postscript(const char *file) +is_postscript_stream(int fd, char *buf, int *len) { - char buf[3]; - int fd; - - if ((fd = open(file, O_RDONLY)) < 0) - return (-1); - - if (read(fd, buf, sizeof (buf)) < 0) { + if ((*len = read(fd, buf, *len)) < 0) { close(fd); return (-1); } - close(fd); if ((strncmp(buf, PS_MAGIC, sizeof (PS_MAGIC) - 1) == 0) || (strncmp(buf, PC_PS_MAGIC, sizeof (PC_PS_MAGIC) - 1) == 0)) @@ -447,6 +444,23 @@ is_postscript(const char *file) return (0); } +int +is_postscript(const char *file) +{ + int rc = -1; + int fd; + + if ((fd = open(file, O_RDONLY)) >= 0) { + char buf[3]; + int len = sizeof (buf); + + rc = is_postscript_stream(fd, buf, &len); + close(fd); + } + + return (rc); +} + static char ** all_list(papi_service_t svc) { diff --git a/usr/src/cmd/print/bsd-sysv-commands/common.h b/usr/src/cmd/print/bsd-sysv-commands/common.h index e8169ed0da..4a74be0abf 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/common.h +++ b/usr/src/cmd/print/bsd-sysv-commands/common.h @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * */ @@ -52,12 +52,14 @@ extern int berkeley_queue_report(papi_service_t svc, FILE *fp, char *dest, int fmt, int ac, char *av[]); extern papi_status_t jobSubmitSTDIN(papi_service_t svc, char *printer, + char *prefetch, int len, papi_attribute_t **list, papi_job_t *job); extern char **interest_list(papi_service_t svc); extern char *localhostname(); extern char *lp_type_to_mime_type(char *lp_type); extern int is_postscript(const char *file); +extern int is_postscript_stream(int fd, char *buf, int *len); extern int cli_auth_callback(papi_service_t svc, void *app_data); diff --git a/usr/src/cmd/print/bsd-sysv-commands/lp.c b/usr/src/cmd/print/bsd-sysv-commands/lp.c index aeec532e54..c7f6b1d4a9 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/lp.c +++ b/usr/src/cmd/print/bsd-sysv-commands/lp.c @@ -70,6 +70,8 @@ main(int ac, char *av[]) papi_attribute_t **list = NULL; papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; papi_job_t job = NULL; + char prefetch[3]; + int prefetch_len = sizeof (prefetch); char *printer = NULL; char b = PAPI_TRUE; int copy = 0; @@ -230,6 +232,10 @@ main(int ac, char *av[]) if (is_postscript(av[optind]) == 1) document_format = "application/postscript"; #endif + } else { + if (is_postscript_stream(0, prefetch, &prefetch_len) + == 1) + document_format = "application/postscript"; } papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, "copies", 1); @@ -257,7 +263,8 @@ main(int ac, char *av[]) if (modify != -1) status = papiJobModify(svc, printer, modify, list, &job); else if (optind == ac) /* no file list, use stdin */ - status = jobSubmitSTDIN(svc, printer, list, &job); + status = jobSubmitSTDIN(svc, printer, prefetch, prefetch_len, + list, &job); else if (validate == 1) /* validate the request can be processed */ status = papiJobValidate(svc, printer, list, NULL, &av[optind], &job); diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpr.c b/usr/src/cmd/print/bsd-sysv-commands/lpr.c index fe6c24a8bc..547e0df36f 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/lpr.c +++ b/usr/src/cmd/print/bsd-sysv-commands/lpr.c @@ -70,6 +70,8 @@ main(int ac, char *av[]) papi_job_t job = NULL; int exit_code = 0; char *printer = NULL; + char prefetch[3]; + int prefetch_len = sizeof (prefetch); papi_encryption_t encryption = PAPI_ENCRYPT_NEVER; int dump = 0; int validate = 0; @@ -217,6 +219,9 @@ main(int ac, char *av[]) if (is_postscript(av[optind]) == 1) document_format = "application/postscript"; #endif + } else { + if (is_postscript_stream(0, prefetch, &prefetch_len) == 1) + document_format = "application/postscript"; } papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, "copies", 1); @@ -238,7 +243,8 @@ main(int ac, char *av[]) status = papiJobValidate(svc, printer, list, NULL, &av[optind], &job); else if (optind == ac) /* no file list, use stdin */ - status = jobSubmitSTDIN(svc, printer, list, &job); + status = jobSubmitSTDIN(svc, printer, prefetch, prefetch_len, + list, &job); else if (copy == 0) /* reference the files in the job, default */ status = papiJobSubmitByReference(svc, printer, list, NULL, &av[optind], &job); diff --git a/usr/src/cmd/print/lpget/lpget.c b/usr/src/cmd/print/lpget/lpget.c index 9e6b0e3f00..5c19480ae1 100644 --- a/usr/src/cmd/print/lpget/lpget.c +++ b/usr/src/cmd/print/lpget/lpget.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -38,7 +38,6 @@ #endif #include <ns.h> -#include <misc.h> #include <list.h> extern char *optarg; diff --git a/usr/src/cmd/print/lpset/lpset.c b/usr/src/cmd/print/lpset/lpset.c index 308c82cd58..d0a765caea 100644 --- a/usr/src/cmd/print/lpset/lpset.c +++ b/usr/src/cmd/print/lpset/lpset.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -41,7 +41,6 @@ #include <pwd.h> #include <ns.h> -#include <misc.h> #include <list.h> extern char *optarg; diff --git a/usr/src/cmd/print/selector/print-service b/usr/src/cmd/print/selector/print-service index f78a4d89dd..9fd672f565 100755 --- a/usr/src/cmd/print/selector/print-service +++ b/usr/src/cmd/print/selector/print-service @@ -64,6 +64,8 @@ my $SVC_CUPS_SCHEDULER = 'cups/scheduler'; my $SVC_CUPS_LPD = 'cups/in-lpd'; sub fatal { + ($ENV{"DESKTOP_LAUNCHED"}) && + exec("/bin/zenity", "--error", "--text=@_"); print STDERR @_; exit(1); } diff --git a/usr/src/lib/print/libpapi-common/common/uri.c b/usr/src/lib/print/libpapi-common/common/uri.c index 9cc6f59006..ee45af9592 100644 --- a/usr/src/lib/print/libpapi-common/common/uri.c +++ b/usr/src/lib/print/libpapi-common/common/uri.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * */ @@ -165,6 +165,14 @@ uri_from_string(char *string, uri_t **uri) u->scheme_part = strdup(&ptr[1]); } + if ((u->host_part == NULL) && (u->path_part == NULL) && + (u->scheme_part == NULL)) { + errno = EINVAL; + uri_free(u); + *uri = NULL; + return (-1); + } + return (0); } diff --git a/usr/src/lib/print/libpapi-dynamic/common/nss.c b/usr/src/lib/print/libpapi-dynamic/common/nss.c index c20b33daf8..dbb2c87e78 100644 --- a/usr/src/lib/print/libpapi-dynamic/common/nss.c +++ b/usr/src/lib/print/libpapi-dynamic/common/nss.c @@ -100,9 +100,16 @@ solaris_lpsched_shortcircuit_hack(papi_attribute_t ***list) papiAttributeListGetString(*list, NULL, "printer-uri-supported", &printer); - if (uri_from_string(printer, &uri) < 0) + /* if there is no printer-uri-supported, there is nothing to do */ + if (printer == NULL) return; + if (uri_from_string(printer, &uri) < 0) { + papiAttributeListFree(*list); + *list = NULL; + return; + } + /* already an lpsched URI ? */ if (strcasecmp(uri->scheme, "lpsched") == 0) return; diff --git a/usr/src/lib/print/libpapi-lpd/common/lpd-job.c b/usr/src/lib/print/libpapi-lpd/common/lpd-job.c index 5a2cb26fa6..52dc69d6c4 100644 --- a/usr/src/lib/print/libpapi-lpd/common/lpd-job.c +++ b/usr/src/lib/print/libpapi-lpd/common/lpd-job.c @@ -94,10 +94,12 @@ add_lpd_control_line(char **metadata, char code, char *value) *metadata = (char *)calloc(1, size); } else { void *tmp; - tmp = realloc(*metadata, size); - if (tmp) + tmp = calloc(1, size); + if (tmp) { + strlcpy(tmp, *metadata, size); + free(*metadata); *metadata = (char *)tmp; - else + } else return (PAPI_TEMPORARY_ERROR); } diff --git a/usr/src/lib/print/libpapi-lpd/common/lpd-port.c b/usr/src/lib/print/libpapi-lpd/common/lpd-port.c index 64cea8dd0a..9c536d886d 100644 --- a/usr/src/lib/print/libpapi-lpd/common/lpd-port.c +++ b/usr/src/lib/print/libpapi-lpd/common/lpd-port.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * */ @@ -232,6 +232,7 @@ next_job_id() (ftruncate(fd, 0) == 0)) write(fd, buf, strlen(buf)); } + close(fd); } syslog(LOG_DEBUG, "next_job_id() is %d", result); diff --git a/usr/src/lib/print/libprint/Makefile.com b/usr/src/lib/print/libprint/Makefile.com index 8d885ada45..88fbb532b0 100644 --- a/usr/src/lib/print/libprint/Makefile.com +++ b/usr/src/lib/print/libprint/Makefile.com @@ -28,7 +28,7 @@ LIBRARY = libprint.a VERS = .2 OBJECTS = \ - job.o list.o misc.o network.o ns.o ns_bsd_addr.o ns_cmn_kvp.o \ + list.o ns.o ns_bsd_addr.o ns_cmn_kvp.o \ ns_cmn_printer.o nss_convert.o nss_ldap.o nss_printer.o nss_write.o include ../../../Makefile.lib diff --git a/usr/src/lib/print/libprint/common/job.c b/usr/src/lib/print/libprint/common/job.c deleted file mode 100644 index b379648d26..0000000000 --- a/usr/src/lib/print/libprint/common/job.c +++ /dev/null @@ -1,591 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ - -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdarg.h> -#include <unistd.h> -#include <string.h> -#include <dirent.h> -#include <sys/mman.h> -#include <sys/systeminfo.h> -#include <syslog.h> -#include <errno.h> -#include <libintl.h> -#include <grp.h> - -#include <job.h> -#include <misc.h> -#include <list.h> - - -#define MAX_RETRIES (5) - -static char *_control_file_prefix = CONTROL_FILE_PREFIX; -static char *_xfer_file_prefix = XFER_FILE_PREFIX; - - -/* - * _job_unlink_data_file() will unlink the path for the jobfile passed in. - * this is only to be used with job_destroy() so it can iterate through - * the job_df_list. - */ -static int -_job_unlink_data_file(jobfile_t *file) -{ - syslog(LOG_DEBUG, "_job_unlink_data_file(%s)", - ((file != NULL) ? file->jf_spl_path : "NULL")); - if (file && file->jf_spl_path) - return (unlink(file->jf_spl_path)); - else - return (-1); -} - -/* - * - */ -static void -_job_file_free(jobfile_t *file) -{ - if (file == NULL) - return; - if (file->jf_spl_path != NULL) free(file->jf_spl_path); - if (file->jf_src_path != NULL) free(file->jf_src_path); - if (file->jf_name != NULL) free(file->jf_name); - if (file->jf_data != NULL) { - if (file->jf_mmapped) - (void) munmap(file->jf_data, file->jf_size); - else - free(file->jf_data); - } - free(file); -} - - -/* - * - */ -static void -_vjob_file_free(jobfile_t *file) -{ - _job_file_free(file); -} - - -/* - * job_free() frees up memory mmapped for malloced - * being used by the structure. - */ -void -job_free(job_t *job) -{ - if (job == NULL) - return; - - syslog(LOG_DEBUG, "job_free(%d, %s, %s)", job->job_id, - (job->job_printer ? job->job_printer : "NULL"), - (job->job_server ? job->job_server : "NULL")); - - if (job->job_printer) free(job->job_printer); - if (job->job_server) free(job->job_server); - if (job->job_user) free(job->job_user); - if (job->job_host) free(job->job_host); - if (job->job_cf) - _job_file_free(job->job_cf); - (void) list_iterate((void *)job->job_df_list, (VFUNC_T)_vjob_file_free); - - if (job->job_df_list) - free(job->job_df_list); - - if (job->job_spool_dir) - free(job->job_spool_dir); - - free(job); -} -void -job_destroy(job_t *job) -{ - char *name = NULL; - jobfile_t *cf; - - if (job == NULL) - return; - - syslog(LOG_DEBUG, "job_destroy(%d, %s, %s)", job->job_id, - job->job_printer, job->job_server); - if (chdir(job->job_spool_dir) < 0) - return; - (void) list_iterate((void *)job->job_df_list, - (VFUNC_T)_job_unlink_data_file); - - /* lose privilege temporarily */ - (void) seteuid(get_user_id(job->job_user)); - - if ((cf = job->job_cf) != NULL) { - for (name = cf->jf_data; name != NULL; - name = strchr(name, '\n')) { - if (name[0] == '\n') - name++; - if (name[0] == CF_UNLINK) { - struct stat st; - char *path = strcdup(&name[1], '\n'), - *p; - - if (stat(path, &st) < 0) { - free(path); - continue; - } - - if (st.st_uid == getuid()) { - (void) unlink(path); - free(path); - continue; - } - - p = strdup(path); - if ((p = strrchr(p, '/')) != NULL) - *++p = NULL; - - if (access(p, W_OK) == 0) - (void) unlink(path); - free(path); - } - } - } - (void) seteuid(0); /* get back privilege */ - - (void) unlink(cf->jf_src_path); - (void) _job_unlink_data_file(cf); - job_free(job); -} - -static int -get_job_from_cfile(jobfile_t *file, char *cFile, char *xFile, job_t *tmp) -{ - jobfile_t *file1; - int n_cnt; - char *p, *cfp; - - /* map in the control data */ - if ((file->jf_size = map_in_file(cFile, &file->jf_data, 0)) <= 0) { - syslog(LOG_INFO, "could not read control file (%s): %m, " - "canceling %d destined for %s:%s", - (file->jf_spl_path ? file->jf_spl_path:"NULL"), - tmp->job_id, - (tmp->job_server ? tmp->job_server : "NULL"), - (tmp->job_printer ? tmp->job_printer : "NULL")); - return (0); - } - file->jf_mmapped = 1; - tmp->job_cf = file; - - /* look for usr, host, & data files */ - - /* - * Bugid 4137904 - "File Name" can be - * anywhere in control file. - * Bugid 4179341 - "File Name" can be missing - * in control file. - * Keep a separate pointer to the control file. - * When a CF_UNLINK entry is found use the second - * pointer to search for a corresponding 'N' entry. - * The behavior is to associate the first CF_UNLINK - * entry with the first 'N' entry and so on. - * Note: n_cnt is only used to determine if we - * should test for 'N' at the beginning of - * the file. - */ - cfp = file->jf_data; - n_cnt = 0; - for (p = file->jf_data - 1; p != NULL; p = strchr(p, '\n')) { - switch (*(++p)) { - case CF_USER: - tmp->job_user = strcdup(++p, '\n'); - break; - case CF_HOST: - tmp->job_host = strcdup(++p, '\n'); - break; - case CF_UNLINK: - if ((file1 = calloc(1, sizeof (*file))) == NULL) { - syslog(LOG_DEBUG, "cf_unlink: calloc() failed"); - munmap(file->jf_data, file->jf_size); - file->jf_mmapped = 0; - return (0); - } - file1->jf_src_path = strdup(xFile); - file1->jf_spl_path = strcdup(++p, '\n'); - file1->jf_size = file_size(file1->jf_spl_path); - - if (cfp != NULL) { - /* - * Beginning of file. Check for first - * character == 'N' - */ - if ((n_cnt == 0) && (*cfp == 'N')) { - cfp++; - n_cnt++; - } else { - cfp = strstr(cfp, "\nN"); - if (cfp != NULL) { - cfp += 2; - n_cnt++; - } - } - if (cfp != NULL) { - file1->jf_name = strcdup(cfp, '\n'); - /* - * Move cfp to end of line or - * set to NULL if end of file. - */ - cfp = strchr(cfp, '\n'); - } - } - tmp->job_df_list = (jobfile_t **)list_append((void **) - tmp->job_df_list, (void *)file1); - break; - } - } - if (tmp->job_df_list == NULL) { - munmap(file->jf_data, file->jf_size); - file->jf_mmapped = 0; - return (0); - } - - return (1); -} - -/* - * job_retrieve() will retrieve the disk copy of a job associated with the - * transfer file name passed in. It returns a pointer to a job structure - * or a NULL if the job was not on disk. - */ -job_t * -job_retrieve(char *xFile, char *spool) -{ - int retry_cnt = 0; - char *s; - jobfile_t *file; - char cFile[BUFSIZ]; - char buf[BUFSIZ]; - int fd; - flock_t flk; - job_t *tmp; - - syslog(LOG_DEBUG, "job_retrieve(%s)", xFile); - if ((tmp = (job_t *)calloc(1, sizeof (*tmp))) == NULL) { - return (NULL); - } - - if ((file = calloc(1, sizeof (*file))) == NULL) { - free(tmp); - return (NULL); - } - - flk.l_type = F_RDLCK; - flk.l_whence = 1; - flk.l_start = 0; - flk.l_len = 0; - - (void) memset(buf, NULL, sizeof (buf)); - /* get job id, from binding file name */ - (void) strlcpy(buf, xFile + strlen(_xfer_file_prefix) + 1, - sizeof (buf)); - - buf[3] = NULL; - tmp->job_id = atoi(buf); - - /* Construct data file and control file names */ - (void) strlcpy(cFile, _control_file_prefix, sizeof (cFile)); - (void) strlcat(cFile, xFile + strlen(_xfer_file_prefix), - sizeof (cFile)); - - /* remove data file and control file whenever xFile is removed */ - if ((fd = open(xFile, O_RDONLY)) < 0) { - syslog(LOG_DEBUG, "job_retrieve(%s) open failed errno=%d", - xFile, errno); - if (get_job_from_cfile(file, cFile, xFile, tmp)) - job_destroy(tmp); - free(file); - free(tmp); - (void) unlink(xFile); - (void) unlink(cFile); - return (NULL); - } - - /* - * If failed to get a lock on the file, just return NULL. It will - * be retried later. - */ - if ((fcntl(fd, F_SETLK, &flk)) < 0) { - syslog(LOG_DEBUG, "job_retrieve(%s) lock failed errno=%d", - xFile, errno); - close(fd); - free(file); - free(tmp); - return (NULL); - } - - /* - * Retry a few times if we failed to read or read returns 0, just - * to make sure we tried hard before giving up. In practice, - * there were cases of read() returning 0. To handle that - * scenario just try a few times. - */ - for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { - if ((read(fd, buf, sizeof (buf))) > 0) { - close(fd); - if ((s = strtok(buf, ":\n")) != NULL) - tmp->job_server = strdup(s); - if ((s = strtok(NULL, ":\n")) != NULL) - tmp->job_printer = strdup(s); - syslog(LOG_DEBUG, "job_retrieve(%s) success - %s:%s", - xFile, tmp->job_server, tmp->job_printer); - break; - } - } - /* - * If failed to read after MAX_RETRIES, return NULL and remove xFile, - * and cFile. - */ - if (retry_cnt == MAX_RETRIES) { - syslog(LOG_DEBUG, "job_retrieve(%s) unsuccessful", xFile); - if (get_job_from_cfile(file, cFile, xFile, tmp)) - job_destroy(tmp); - free(file); - free(tmp); - (void) unlink(xFile); - (void) unlink(cFile); - return (NULL); - } - - file->jf_src_path = strdup(xFile); - file->jf_spl_path = strdup(cFile); - - if (!get_job_from_cfile(file, cFile, xFile, tmp)) { - (void) unlink(file->jf_spl_path); /* control file */ - (void) unlink(file->jf_src_path); /* binding file */ - free(file->jf_src_path); - free(file->jf_spl_path); - free(file); - free(tmp); - return (NULL); - } - - tmp->job_spool_dir = strdup(spool); - return (tmp); -} - - -/* - * job_compar() compare 2 jobs for creation time ordering - */ -static int -job_compar(job_t **j1, job_t **j2) -{ - int server; - int printer; - struct stat s1, - s2; - jobfile_t *f1 = (*j1)->job_cf, - *f2 = (*j2)->job_cf; - - /* - * If there is a null value, assume the job submitted remotely. - * Jobs submitted remotely take precedence over those submitted - * from the server. - */ - if (((*j1)->job_server) == NULL || ((*j1)->job_printer) == NULL || - ((*j1)->job_cf) == NULL) - return (-1); - - else if ((*j2)->job_server == NULL || (*j2)->job_printer == NULL || - (*j2)->job_cf == NULL) - return (1); - - server = strcmp((*j1)->job_server, (*j2)->job_server); - printer = strcmp((*j1)->job_printer, (*j2)->job_printer); - - if (server != 0) - return (server); - if (printer != 0) - return (printer); - - if ((stat(f1->jf_spl_path, &s1) == 0) && - (stat(f2->jf_spl_path, &s2) == 0)) - return (s1.st_ctime - s2.st_ctime); - - return (0); -} - - -/* - * job_list_append() reads all of the jobs associated with the printer passed - * in and appends them to the list of jobs passed in. The returned result - * is a new list of jobs containing all jobs passed in and jobs for the - * printer specified. If the printer is NULL, all jobs for all printers - * are added to the list. - */ -job_t ** -job_list_append(job_t **list, char *printer, char *server, char *spool) -{ - struct dirent *d; - DIR *dirp; - job_t *job; - int i, found = 0; - - syslog(LOG_DEBUG, "job_list_append(0x%x, %s, %s)", list, - ((printer != NULL) ? printer : "NULL"), - ((server != NULL) ? server : "NULL")); - - /* - * 4239765 - in.lpd segfaults performing strcmp() - * in job_list_append() - */ - if (server == NULL) { - server = ""; - } - - if ((dirp = opendir(spool)) == NULL) - return (NULL); - - /* should use scandir */ - while ((d = readdir(dirp)) != NULL) { - if (strncmp(d->d_name, _xfer_file_prefix, - strlen(_xfer_file_prefix)) != 0) - continue; - if ((job = job_retrieve(d->d_name, spool)) == NULL) - continue; - syslog(LOG_DEBUG, "job_printer is (%s:%s)", - job->job_printer, job->job_server); - - found = 0; - - if ((printer == NULL) || - ((strcmp(printer, job->job_printer) == 0) && - (strcmp(server, job->job_server) == 0))) { - if (list) { - for (i = 0; list[i] != NULL; i++) { - if ((list[i]->job_cf != NULL) && - (job->job_cf != NULL) && - (strcmp(list[i]->job_cf->jf_spl_path, - job->job_cf->jf_spl_path) == 0)) - found = 1; - } - } /* if (list) */ - - if (!found) - list = (job_t **)list_append((void **)list, - (void *)job); - } - } /* while */ - - /* count the length of the list for qsort() */ - if (list) { - for (i = 0; list[i] != NULL; i++) - ; - - qsort(list, i, sizeof (job_t *), - (int(*)(const void *, const void *))job_compar); - } - (void) closedir(dirp); - return (list); -} - - - -/* - * - * Shared routines for Canceling jobs. - * - */ - - -/* - * vjob_match_attribute() checks to see if the attribute passed in - * matches the the user or id of the job passed in via stdargs. This is - * intended for use with list_iterate(). - */ -int -vjob_match_attribute(char *attribute, va_list ap) -{ - job_t *job = va_arg(ap, job_t *); - - if ((strcmp(attribute, job->job_user) == 0) || - (job->job_id == atoi(attribute))) - return (1); - else - return (0); -} - - -/* - * vjob_job() determines if the job passed in is for the printer and server - * of the cancel request, and if it is from the user requesting or the - * user is root, it checsk the attributes. If the job matches all of this - * it cancels the job and prints a message. It is intented to be called - * by list_iterate(). - */ -int -vjob_cancel(job_t *job, va_list ap) -{ - int killed_process = 0; - int lock; - char *user = va_arg(ap, char *), - *printer = va_arg(ap, char *), - *server = va_arg(ap, char *), - **list = va_arg(ap, char **); - - syslog(LOG_DEBUG, "vjob_cancel((%s, %s, %d), %s, %s, %s)", - job->job_printer, job->job_server, job->job_id, user, printer, - server); - if (((strcmp(user, "root") == 0) || - (strcmp(user, job->job_user) == 0)) && - ((strcmp(printer, job->job_printer) == 0) && - (strcmp(server, job->job_server) == 0))) { - if (list_iterate((void **)list, - (VFUNC_T)vjob_match_attribute, job) != 0) { - while ((lock = get_lock(job->job_cf->jf_src_path, - 0)) < 0) { - (void) kill_process(job->job_cf->jf_src_path); - killed_process = 1; - } - job_destroy(job); - syslog(LOG_DEBUG, "\t%s-%d: canceled\n", printer, - job->job_id); - (void) printf( - (char *)gettext("\t%s-%d: canceled\n"), printer, - (int)job->job_id); - close(lock); - } - } - return (killed_process); -} diff --git a/usr/src/lib/print/libprint/common/job.h b/usr/src/lib/print/libprint/common/job.h deleted file mode 100644 index 932d993a16..0000000000 --- a/usr/src/lib/print/libprint/common/job.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _JOB_H -#define _JOB_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/va_list.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Sequence number space - */ -#define JOB_ID_START 0 -#define JOB_ID_END 999 - -/* - * Job related files - */ -#define SEQUENCE_FILE ".seq" /* sequence numbers */ -#define TEMP_FILE_PREFIX "tf" /* printer:server */ -#define XFER_FILE_PREFIX "xf" /* printer:server */ -#define CONTROL_FILE_PREFIX "cf" /* job control data */ -#define DATA_FILE_PREFIX "df" /* job data file */ - -/* - * RFC-1179 Control File Primatives - */ -#define CF_CLASS 'C' /* C(ClassName)\n - for banner page */ -#define CF_HOST 'H' /* H(Hostname)\n - host submitting job */ -#define CF_INDENT 'I' /* I(indent)\n - # of spaces for 'f' */ -#define CF_JOBNAME 'J' /* J(Jobname)\n - name of job for banner */ -#define CF_PRINT_BANNER 'L' /* L[User]\n - User name on burst page */ -#define CF_MAIL 'M' /* M(user)\n - User to mail when done */ -#define CF_SOURCE_NAME 'N' /* N(name)\n - source of data file */ -#define CF_USER 'P' /* P(name)\n - requesting user */ -#define CF_SYMLINK 'S' /* S(device) (inode)\n - foget it */ -#define CF_TITLE 'T' /* T(title)\n - for pr */ -#define CF_UNLINK 'U' /* U(file)\n - unlink file */ -#define CF_WIDTH 'W' /* W(width)\n - column width */ -#define CF_FONT_TROFF_R '1' /* 1(file)\n - file with Times Roman font */ -#define CF_FONT_TROFF_I '2' /* 2(file)\n - file with Times Italic font */ -#define CF_FONT_TROFF_B '3' /* 3(file)\n - file with Times Bold font */ -#define CF_FONT_TROFF_S '4' /* 4(file)\n - file with Times Special font */ -#define CF_PRINT_CIF 'c' /* c(file)\n - print/plot file as CIF data */ -#define CF_PRINT_DVI 'd' /* d(file)\n - print file as DVI data */ -#define CF_PRINT_ASCII 'f' /* f(file)\n - print file as ASCII */ -#define CF_PRINT_PLOT 'g' /* g(file)\n - print file as plot data */ -#define CF_KERBERIZED 'k' /* k...\n - for Kerberos */ -#define CF_PRINT_RAW 'l' /* l(file)\n - print file dammit */ -#define CF_PRINT_DROFF 'n' /* n(file)\n - print file as ditroff output */ -#define CF_PRINT_PS 'o' /* o(file)\n - print file as PostScript */ -#define CF_PRINT_PR 'p' /* p(file)\n - print file thru "pr" */ -#define CF_PRINT_FORT 'r' /* r(file)\n - print file as fortran */ -#define CF_PRINT_TROFF 't' /* n(file)\n - print file as troff output */ -#define CF_PRINT_RAS 'v' /* v(file)\n - print file as raster image */ -#define CF_PRINT_PLDM 'z' /* z...\n - for Palladium ??? */ - -/* - * Solaris 2.X LP - BSD protocol extensions - */ -#define CF_SYSV_OPTION 'O' /* for SVR4 LP '-o' option */ -#define CF_SYSV_FEATURE '5' /* for SVR4 LP features */ -#define CF_SYSV_FORM 'f' /* for SVR4 Forms */ -#define CF_SYSV_HANDLING 'H' /* for SVR4 Handling */ -#define CF_SYSV_NOTIFICATION 'p' /* for SVR4 Notification */ -#define CF_SYSV_PAGES 'P' /* for SVR4 Pages */ -#define CF_SYSV_PRIORITY 'q' /* for SVR4 Priority */ -#define CF_SYSV_CHARSET 'S' /* for SVR4 Charset */ -#define CF_SYSV_TYPE 'T' /* for SVR4 Type */ -#define CF_SYSV_MODE 'y' /* for SVR4 Mode */ - - -typedef struct _jobfile jobfile_t; -typedef struct _job job_t; - -struct _jobfile { - char *jf_spl_path; /* df file */ - char *jf_src_path; /* source file */ - char *jf_name; /* title/name */ - char *jf_data; /* ptr to mmapped file */ - long jf_size; /* size of data */ - char jf_mmapped; /* is this mmapped or malloced */ -}; - -struct _job { - int job_id; - char *job_printer; - char *job_server; - char *job_user; - char *job_host; - char *job_spool_dir; - jobfile_t *job_cf; - char job_df_next; - jobfile_t **job_df_list; -}; - - -extern int job_store(job_t *job); -extern void job_free(job_t *job); -extern void job_destroy(job_t *job); -extern job_t *job_retrieve(char *xfer_file, char *spool); -extern job_t **job_list_append(job_t **list, char *printer, - char *server, char *spool); -extern int vjob_match_attribute(char *attribute, __va_list ap); -extern int vjob_cancel(job_t *job, __va_list ap); - -#ifdef __cplusplus -} -#endif - -#endif /* !_JOB_H */ diff --git a/usr/src/lib/print/libprint/common/llib-lprint b/usr/src/lib/print/libprint/common/llib-lprint index 6d89824e36..c52143e527 100644 --- a/usr/src/lib/print/libprint/common/llib-lprint +++ b/usr/src/lib/print/libprint/common/llib-lprint @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -53,75 +53,14 @@ #include <syslog.h> #include <unistd.h> -typedef struct _jobfile jobfile_t; -typedef struct _job job_t; - -struct _jobfile { - char *jf_spl_path; /* df file */ - char *jf_src_path; /* source file */ - char *jf_name; /* title/name */ - char *jf_data; /* ptr to mmapped file */ - long jf_size; /* size of data */ - char jf_mmapped; /* is this mmapped or malloced */ -}; - -struct _job { - int job_id; - char *job_printer; - char *job_server; - char *job_user; - char *job_host; - char *job_spool_dir; - jobfile_t *job_cf; - char job_df_next; - jobfile_t **job_df_list; -}; - -int job_store(job_t *job); -void job_free(job_t *job); -void job_destroy(job_t *job); -job_t *job_create(char *printer, char *server, char *spool); -job_t *job_retrieve(char *xfer_file, char *spool); -job_t **job_list_append(job_t **list, char *printer, char *spool); -#ifndef SUNOS_4 -int vjob_match_attribute(char *attribute, __va_list ap); -int vjob_cancel(job_t *job, __va_list ap); -#endif - - void **list_append(void **, void *); void **list_append_unique(void **, void *, int (*)(void *, void*)); void **list_concatenate(void **, void **); void * list_locate(void **, int (*)(void *, void *), void *); int list_iterate(void **, int (*)(void *, __va_list), ...); -char * get_user_name(void); -int check_client_spool(char *printer); -int get_lock(char *name, int write_pid); -uid_t get_user_id(void); -char *strcdup(char *, char); -char *strndup(char *, int); -char **strsplit(char *, char *); -int file_size(char *); -int copy_file(char *src, char *dst); -int map_in_file(const char *name, char **buf); -int write_buffer(char *name, char *buf, int len); -void start_daemon(int do_fork); -int kill_process(char *file); void *dynamic_function(const char *, const char *); -int net_open(char *host, int timeout); -int net_close(int nd); -int net_read(int nd, char *buf, int len); -int net_write(int nd, char *buf, int len); -int net_printf(int nd, char *fmt, ...); -char *net_gets(char *buf, int size, int nd); -int net_send_message(int nd, char *fmt, ...); -int net_response(int nd); -int net_send_file(int nd, char *name, char *data, int data_len, - int type); - - struct ns_bsd_addr { char *server; /* server name */ char *printer; /* printer name or NULL */ diff --git a/usr/src/lib/print/libprint/common/mapfile-vers b/usr/src/lib/print/libprint/common/mapfile-vers index 8cf667fb92..de93e22eee 100644 --- a/usr/src/lib/print/libprint/common/mapfile-vers +++ b/usr/src/lib/print/libprint/common/mapfile-vers @@ -19,7 +19,7 @@ # CDDL HEADER END # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" @@ -72,36 +72,6 @@ SUNWprivate_2.1 { list_locate; list_iterate; - job_free; # job support - job_destroy; - job_retrieve; - job_list_append; - vjob_match_attribute; - vjob_cancel; - - net_open; # net support - net_close; - net_read; - net_write; - net_printf; - net_gets; - net_send_message; - net_response; - net_send_file; - - check_client_spool; # misc support - get_lock; - get_user_id; - get_user_name; - strcdup; - strndup; - strsplit; - file_size; - copy_file; - map_in_file; - write_buffer; - start_daemon; - files_put_printer; # required for ns_put_printer() nis_put_printer; nisplus_put_printer; diff --git a/usr/src/lib/print/libprint/common/misc.c b/usr/src/lib/print/libprint/common/misc.c deleted file mode 100644 index f9d7e4e966..0000000000 --- a/usr/src/lib/print/libprint/common/misc.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ - -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <signal.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> -#include <pwd.h> -#include <sys/mman.h> -#include <time.h> -#include <syslog.h> -#include <errno.h> - -#include <misc.h> -#include <job.h> -#include <list.h> - - -/* - * info about spool directory that we validate and fix - */ -#define ROOT_UID 0 -#define LP_GID 8 -#define SPOOL_MODE (S_IFDIR|S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) - -/*ARGSUSED*/ -int -check_client_spool(char *printer) -{ - char *dir = SPOOL_DIR; - struct stat st; - - if ((stat(dir, &st) < 0) && (errno == ENOENT)) { - syslog(LOG_ERR, "no spool dir, creating %s", dir); - if (mkdir(dir, 0755) < 0) { - syslog(LOG_ERR, "mkdir(%s): %m", dir); - return (-1); - } - if (chown(dir, ROOT_UID, LP_GID) < 0) { - syslog(LOG_ERR, "chown(%s): %m", dir); - return (-1); - } - return (0); - } - if ((st.st_uid != ROOT_UID) || (st.st_gid != LP_GID)) { - syslog(LOG_ERR, - "correcting spool directory owner/group (was %d/%d)", - st.st_uid, st.st_gid); - if (chown(dir, ROOT_UID, LP_GID) < 0) { - syslog(LOG_ERR, "chown(%s): %m", dir); - return (-1); - } - } - if (st.st_mode != (S_IFDIR | SPOOL_MODE)) { - syslog(LOG_ERR, - "spool dir (%s), incorrect permission (%0), correcting", - dir, st.st_mode); - if (chmod(dir, 0755) < 0) { - syslog(LOG_ERR, "chmod(%s): %m", dir); - return (-1); - } - } - return (0); -} - -int -get_lock(char *name, int write_pid) -{ - int fd; - - syslog(LOG_DEBUG, "get_lock(%s, %d)", ((name != NULL) ? name : "NULL"), - write_pid); - if ((fd = open(name, O_RDWR|O_CREAT, 0640)) < 0) - return (fd); - - if (lockf(fd, F_TLOCK, 0) < 0) { - close(fd); - return (-1); - } - - if (write_pid != 0) { - char pid[16]; - - if (ftruncate(fd, 0) < 0) { - close(fd); - return (-1); - } - if (snprintf(pid, sizeof (pid), "%d\n", (int)getpid()) - >= sizeof (pid)) { - syslog(LOG_ERR, "get_lock: pid buffer overflow"); - return (-1); - } - write(fd, pid, strlen(pid)); - } - (void) fsync(fd); - - syslog(LOG_DEBUG, "get_lock(%s, %d) - have lock", - ((name != NULL) ? name : "NULL"), write_pid); - return (fd); -} - -uid_t -get_user_id(char *name) -{ - struct passwd *p = NULL; - - if (name == NULL) - return (-1); - if ((p = getpwnam(name)) != NULL) - return (p->pw_uid); - else if ((p = getpwnam("nobody")) != NULL) - return (p->pw_uid); - else - return (-2); -} - - -/* - * get_user_name() - */ -char * -get_user_name() -{ - struct passwd *p = NULL; - - if ((p = getpwuid(getuid())) != NULL) - return (strdup(p->pw_name)); - else - return (strdup("unknown")); -} - - - -/* - * strcdup() - duplicate a string up to the first occurence of a character - */ -char * -strcdup(char *p, char c) -{ - char *q, - *r; - - if (p == NULL) - return (NULL); - if ((c == NULL) || ((q = strchr(p, c)) == NULL)) - return (strdup(p)); - - if ((r = malloc((q - p) + 1)) != NULL) - (void) strlcpy(r, p, ((q - p) + 1)); - return (r); -} - - -/* - * Should be obvious - */ -char * -strndup(char *s, int l) -{ - char *t; - - if ((s == NULL) || (l < 1)) - return (NULL); - - if ((t = malloc(l + 1)) != NULL) - (void) strlcpy(t, s, (l + 1)); - return (t); -} - - -/* - * file_size() - need I say more - */ -int -file_size(char *path) -{ - struct stat st; - - if (stat(path, &st) < 0) - return (-1); - else - return (st.st_size); -} - - -/* - * copy_file() - need I say more - */ -int -copy_file(char *src, char *dst) -{ - char *buf; - int size; - - syslog(LOG_DEBUG, "copy_file(%s, %s)", ((src != NULL) ? src : "NULL"), - ((dst != NULL) ? dst : "NULL")); - - if ((src == NULL) || (dst == NULL)) - return (-1); - - if ((size = map_in_file(src, &buf, 1)) < 0) - return (-1); - if (write_buffer(dst, buf, size) < 0) { - (void) munmap(buf, size); - return (-1); - } - - (void) munmap(buf, size); - return (0); -} - -int -backup_file(char *name) -{ - char buf[BUFSIZ]; - - if (snprintf(buf, sizeof (buf), "%s-", name) >= sizeof (buf)) { - syslog(LOG_ERR, "libprint:backup_file: buffer overrun"); - return (-1); - } - return (copy_file(name, buf)); -} - -/* - * map_in_file() - mmaps in a file into a buffer *buf. returns the size of - * the mmapped buffer. - */ -int -map_in_file(const char *file, char **buf, int as_me) -{ - struct stat st; - int fd; - - syslog(LOG_DEBUG, "map_in_file(%s)", (file ? file : "NULL")); - - if (buf == NULL) - return (-1); - - if (as_me != 0) - seteuid(getuid()); /* if we are suid, lose privilege */ - - if ((fd = open(file, O_RDONLY)) < 0) - return (-1); - - if (as_me != 0) - seteuid(0); /* if we fail, didn't have privilege before */ - - if (fstat(fd, &st) < 0) { - close(fd); - return (-1); - } - - if (st.st_size == 0) { - close(fd); - *buf = NULL; - return (0); - } - - if ((*buf = mmap((caddr_t)0, (size_t)st.st_size, PROT_READ, - (MAP_PRIVATE | MAP_NORESERVE), - fd, (off_t)0)) == MAP_FAILED) { - syslog(LOG_ERR, "map_in_file(%s) - mmap:%m", - (file ? file : "NULL")); - close(fd); - return (-1); - } - close(fd); - - syslog(LOG_DEBUG, "map_in_file(%s) - size(%d), addr(0x%x)", - (file ? file : "NULL"), st.st_size, *buf); - return (st.st_size); -} - - -/* - * write_buffer() - writes a buffer in memory out to the file name passed in. - * uses mmap and ftruncate to do this. - */ -int -write_buffer(char *file, char *buf, int len) -{ - int fd; - char *tmp; - - syslog(LOG_DEBUG, "write_buffer(%s, 0x%x, %d)", (file ? file : "NULL"), - buf, len); - - if ((fd = open(file, O_CREAT|O_EXCL|O_RDWR, 0640)) < 0) - return (-1); - if (ftruncate(fd, len) < 0) { - close(fd); - return (-1); - } - if ((tmp = mmap((caddr_t)0, (size_t)len, PROT_READ| PROT_WRITE, - (MAP_SHARED | MAP_NORESERVE), - fd, (off_t)0)) == MAP_FAILED) { - syslog(LOG_ERR, "write_buffer(%s, 0x%x, %d) - mmap:%m", - (file ? file : "NULL"), buf, len); - close(fd); - return (-1); - } - close(fd); - - (void) memcpy(tmp, buf, len); - (void) munmap(tmp, len); - - syslog(LOG_DEBUG, "write_buffer(%s, 0x%x, %d) - ok", - (file ? file : "NULL"), buf, len); - - return (0); -} - - -/* - * start_daemon() - check for jobs queued, check if the lock is free. If - * so, start a daemon either by forking and execing or just execing - * depending on the flag passed in. - */ -void -start_daemon(int do_fork) -{ - int lock; - job_t **jobs = NULL; - - if ((jobs = job_list_append(NULL, NULL, NULL, SPOOL_DIR)) == NULL) - return; - - list_iterate((void **)jobs, (VFUNC_T)job_free); - free(jobs); - - close(lock = get_lock(MASTER_LOCK, 0)); - if (lock < 0) - return; - if (do_fork == 0) { - (void) execle("/usr/lib/print/printd", MASTER_NAME, NULL, NULL); - syslog(LOG_ERR, "start_daemon() - execl: %m"); - exit(-1); - } else - switch (fork()) { - case -1: - syslog(LOG_ERR, "start_daemon() - fork: %m"); - exit(-1); - /* NOTREACHED */ - case 0: - break; - default: - (void) execl("/usr/lib/print/printd", MASTER_NAME, - NULL); - syslog(LOG_ERR, "start_daemon() - execl: %m"); - exit(-1); - /* NOTREACHED */ - } - -} - - -/* - * kill_daemon() - read the master lock file and send SIGTERM to the process - * id stored in the file. - */ -int -kill_process(char *file) -{ - int fd, - pid; - char buf[BUFSIZ], - *p; - - if ((fd = open(file, O_RDONLY)) < 0) - return (-1); - - (void) memset(buf, NULL, sizeof (buf)); - if (read(fd, buf, sizeof (buf)) <= 0) - return (-1); - - if ((p = strchr(buf, '\n')) == NULL) { /* skip the 1st line */ - close(fd); - return (-1); - } - pid = atoi(++p); /* convert the PID */ - - if ((pid < 2) || (kill(pid, SIGTERM) < 0)) { - close(fd); - return (-1); - } - close(fd); - return (0); -} - - -char ** -strsplit(char *string, char *seperators) -{ - char **list = NULL; - char *where = NULL; - char *element; - - for (element = strtok_r(string, seperators, &where); element != NULL; - element = strtok_r(NULL, seperators, &where)) - list = (char **)list_append((void **)list, element); - - return (list); -} diff --git a/usr/src/lib/print/libprint/common/misc.h b/usr/src/lib/print/libprint/common/misc.h deleted file mode 100644 index 5821794557..0000000000 --- a/usr/src/lib/print/libprint/common/misc.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MISC_H -#define _MISC_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Protocol Defined Requests */ -#define PRINT_REQUEST 1 /* \1printer\n */ -#define XFER_REQUEST 2 /* \2printer\n */ -#define XFER_CLEANUP 1 /* \1 */ -#define XFER_CONTROL 2 /* \2size name\n */ -#define XFER_DATA 3 /* \3size name\n */ - -#define SHOW_QUEUE_SHORT_REQUEST 3 /* \3printer [users|jobs ...]\n */ -#define SHOW_QUEUE_LONG_REQUEST 4 /* \4printer [users|jobs ...]\n */ -#define REMOVE_REQUEST 5 /* \5printer person [users|jobs ...]\n */ - -#define ACK_BYTE 0 -#define NACK_BYTE 1 - -#define MASTER_NAME "printd" -#define MASTER_LOCK "/var/spool/print/.printd.lock" -#define SPOOL_DIR "/var/spool/print" -#define TBL_NAME "printers.conf" - - -extern int check_client_spool(char *printer); -extern int get_lock(char *name, int write_pid); -extern uid_t get_user_id(); -extern char *get_user_name(); -extern char *strcdup(char *, char); -extern char *strndup(char *, int); -extern char **strsplit(char *, char *); -extern int file_size(char *); -extern int copy_file(char *src, char *dst); -extern int map_in_file(const char *name, char **buf, int as_me); -extern int write_buffer(char *name, char *buf, int len); -extern void start_daemon(int do_fork); -extern int kill_process(char *file); - -#ifdef __cplusplus -} -#endif - -#endif /* _MISC_H */ diff --git a/usr/src/lib/print/libprint/common/network.c b/usr/src/lib/print/libprint/common/network.c deleted file mode 100644 index 3b064b69c8..0000000000 --- a/usr/src/lib/print/libprint/common/network.c +++ /dev/null @@ -1,418 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ - -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdarg.h> -#include <unistd.h> -#include <string.h> -#include <signal.h> -#include <sys/mman.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <errno.h> -#include <syslog.h> -#include <sys/utsname.h> - -#include <network.h> -#include <misc.h> - -static int read_wait_time_sec = 300; -static int write_wait_time_sec = 10; - -/* - * This module implements a set of functions to handle network - * communications. It attempts to hide any "uglyness" that might be - * necessary for such communications. - */ - - -/* - * null() is to be used as a signal handler that does nothing. It is used in - * place of SIG_IGN, because we want the signal to be delivered and - * interupt the current system call. - */ -static void -null(int i) -{ - syslog(LOG_DEBUG, "null(%d)", i); -} - -/* - * net_open() opens a tcp connection to the printer port on the host specified - * in the arguments passed in. If the connection is not made in the - * timeout (in seconds) passed in, an error it returned. If the host is - * unknown, an error is returned. If all is well, a file descriptor is - * returned to be used for future communications. - */ -int -net_open(char *host, int timeout) -{ - struct hostent *hp; - struct servent *sp; - struct sockaddr_in6 sin; - void (*old_handler)(); - static struct utsname uts; - - int s, - lport, - err, - error_num; - unsigned timo = 1; - - syslog(LOG_DEBUG, "net_open(%s, %d)", (host != NULL ? host : "NULL"), - timeout); - /* - * Get the host address and port number to connect to. - */ - if (host == NULL) { - return (-1); - } - - (void) memset((char *)&sin, NULL, sizeof (sin)); - if ((hp = getipnodebyname(host, AF_INET6, AI_DEFAULT, - &error_num)) == NULL) { - syslog(LOG_DEBUG|LOG_ERR, "unknown host %s " - "getipnodebyname() returned %d", host, error_num); - return (NETWORK_ERROR_HOST); - } - (void) memcpy((caddr_t)&sin.sin6_addr, hp->h_addr, hp->h_length); - sin.sin6_family = hp->h_addrtype; - freehostent(hp); - - if ((sp = getservbyname("printer", "tcp")) == NULL) { - syslog(LOG_DEBUG|LOG_ERR, "printer/tcp: unknown service"); - return (NETWORK_ERROR_SERVICE); - } - sin.sin6_port = sp->s_port; - -retry: - /* - * Try connecting to the server. - * - * Use 0 as lport means that rresvport_af() will bind to a port in - * the anonymous privileged port range. - */ - lport = 0; - s = rresvport_af(&lport, AF_INET6); - if (s < 0) - return (NETWORK_ERROR_PORT); - - old_handler = signal(SIGALRM, null); - (void) alarm(timeout); - if (connect(s, (struct sockaddr *)&sin, sizeof (sin)) < 0) { - (void) alarm(0); - (void) signal(SIGALRM, old_handler); - err = errno; - (void) close(s); - errno = err; - if (errno == EADDRINUSE) { - goto retry; - } - /* - * If connecting to the local system fails, try - * again with "localhost" address instead. - */ - if (uts.nodename[0] == '\0') - (void) uname(&uts); - if (strcmp(host, uts.nodename) == 0) { - IN6_IPADDR_TO_V4MAPPED(htonl(INADDR_LOOPBACK), - &sin.sin6_addr); - sin.sin6_family = AF_INET6; - goto retry; - } - if (errno == ECONNREFUSED && timo <= 16) { - (void) sleep(timo); - timo *= 2; - goto retry; - } - return (NETWORK_ERROR_UNKNOWN); - } - (void) alarm(0); - (void) signal(SIGALRM, old_handler); - return (s); -} - - -/* - * net_close() closes a TCP connection opened by net_open() - */ -int -net_close(int nd) -{ - syslog(LOG_DEBUG, "net_close(%d)", nd); - return (close(nd)); -} - -/* - * net_read() reads up to the length specified into the buffer supplied from - * the network connection specified - */ -int -net_read(int nd, char *buf, int len) -{ - int rc; - void (*old_handler)(); - - syslog(LOG_DEBUG, "net_read(%d, 0x%x, %d)", nd, buf, len); - old_handler = signal(SIGALRM, null); - (void) alarm(read_wait_time_sec); - rc = read(nd, buf, len); - (void) alarm(0); - (void) signal(SIGALRM, old_handler); - return (rc); -} - - -/* - * net_write() writes the buffer specified out to the network connection - * supplied. - */ -int -net_write(int nd, char *buf, int len) -{ - int rc; - void (*old_handler)(); - - syslog(LOG_DEBUG, "net_write(%d, 0x%x, %d)", nd, buf, len); - old_handler = signal(SIGALRM, null); - (void) alarm(write_wait_time_sec); - rc = write(nd, buf, len); - (void) alarm(0); - (void) signal(SIGALRM, old_handler); - return (rc); -} - - -/* - * net_response() reads in a byte from the network connection and - * returns -1 if it isn't 0. - */ -int -net_response(int nd) -{ - char c; - - syslog(LOG_DEBUG, "net_response(%d)", nd); - if ((net_read(nd, &c, 1) != 1) || c) { - errno = EIO; - return (-1); - } - return (0); -} - -/* - * net_printf() sends a text message out to the network connection supplied - * using the same semantics as printf(3C) for stdio. - */ -/*PRINTFLIKE2*/ -int -net_printf(int nd, char *fmt, ...) -{ - char *buf; - va_list ap; - int err; - int size; - int rc; - - syslog(LOG_DEBUG, "net_printf(%d, %s, ...)", nd, fmt); - - if ((buf = malloc(BUFSIZ)) == NULL) { - err = errno; - syslog(LOG_DEBUG, "net_printf malloc failed"); - errno = err; - return (-1); - } - - va_start(ap, fmt); - size = vsnprintf(buf, BUFSIZ, fmt, ap); - if (size >= BUFSIZ) { - if ((buf = (char *)realloc(buf, size + 2)) == NULL) { - err = errno; - syslog(LOG_DEBUG, "net_printf malloc failed"); - errno = err; - return (-1); - } - size = vsnprintf(buf, size + 1, fmt, ap); - } - va_end(ap); - - - rc = net_write(nd, buf, (int)strlen(buf)); - free(buf); - return (rc); -} - -/* - * net_gets() read from the network connection until either a newline - * is encountered, or the buffer passed in is full. This is similiar - * to fgets(3C) - */ -char * -net_gets(char *buf, int bufSize, int nd) -{ - char tmp; - int count = 0; - - syslog(LOG_DEBUG, "net_gets(0x%x, %d, %d)", buf, bufSize, nd); - (void) memset(buf, NULL, bufSize); - while ((count < bufSize) && (net_read(nd, &tmp, 1) > 0)) - if ((buf[count++] = tmp) == '\n') break; - - if (count != 0) - return (buf); - return (NULL); -} - - -/* - * net_send_message() sends a message out the network connection using - * net_printf() and returns the result from net_response() - */ -/*PRINTFLIKE2*/ -int -net_send_message(int nd, char *fmt, ...) -{ - char buf[BUFSIZ]; - va_list ap; - - syslog(LOG_DEBUG, "net_send_message(%d, %s, ...)", nd, fmt); - va_start(ap, fmt); - if (vsnprintf(buf, sizeof (buf), fmt, ap) >= sizeof (buf)) { - syslog(LOG_ERR, "libprint:net_send_message: buffer overrun"); - return (-1); - } - va_end(ap); - - if (net_write(nd, buf, (int)((strlen(buf) != 0) ? strlen(buf) : 1)) < 0) - return (-1); - return (net_response(nd)); -} - - -/* - * net_send_file() sends the appropriate rfc1179 file transfer sub message - * to notify the remote side it is sending a file. It then sends the - * file if the remote side responds that it is ready. If the remote side - * can't accept the file an error is returned. If the transfer fails, - * an error is returned. - */ -int -net_send_file(int nd, char *name, char *data, int data_size, int type) -{ - char *truncated_name, - *mptr, - *fileBuf = NULL; - int count, - retries = 0, - size, - tmperrno; - - syslog(LOG_DEBUG, "net_send_file(%d, %s, 0x%x, %d, %d)", nd, - (name ? name : "NULL"), data, data_size, type); - if ((truncated_name = (char *)strrchr(name, '/')) == NULL) - truncated_name = name; - else - truncated_name++; - - - if (data == NULL) { - size = map_in_file(name, &fileBuf, 1); - mptr = fileBuf; - } else { - mptr = data; - size = data_size; - } - - if (size < 0) { - tmperrno = errno; /* because syslog() can change errno */ - syslog(LOG_DEBUG, "net_send_file(%d, %s, 0x%x, %d, %d): %m", nd, - (name ? name : "NULL"), data, data_size, type); - errno = tmperrno; - return (NETWORK_ERROR_UNKNOWN); - } - - /* send XFER command */ - if (net_send_message(nd, "%c%d %s\n", type, size, - truncated_name) != 0) { - (void) munmap(fileBuf, size); - errno = EIO; - return (NETWORK_ERROR_SEND_RESPONSE); - } - - /* send DATA and ACK */ - count = size; - while (count > 0) { - int rc; - - rc = net_write(nd, mptr, count); - - if (rc < 0) { - if (retries++ < 5) { - /* - * save/restore errno; - * will lose if syslogd down - */ - tmperrno = errno; - syslog(LOG_DEBUG, - "net_send_file error on write: %m %d", - retries); - errno = tmperrno; - continue; - } - /* save/restore errno; will lose if syslogd down */ - tmperrno = errno; - syslog(LOG_DEBUG, "net_send_file error on write: %m"); - if (fileBuf != NULL) - (void) munmap(fileBuf, size); - errno = tmperrno; - return (-1); - - } else { - count -= rc; - mptr += rc; - retries = 0; - } - } - - if (fileBuf != NULL) - (void) munmap(fileBuf, size); - - if (net_send_message(nd, "", NULL) != 0) { - errno = EIO; - return (NETWORK_ERROR_SEND_FAILED); - } - - return (0); -} diff --git a/usr/src/lib/print/libprint/common/network.h b/usr/src/lib/print/libprint/common/network.h deleted file mode 100644 index ee88e421d0..0000000000 --- a/usr/src/lib/print/libprint/common/network.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _NETWORK_H -#define _NETWORK_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -#define NETWORK_ERROR_UNKNOWN -1 -#define NETWORK_ERROR_HOST -2 -#define NETWORK_ERROR_SERVICE -3 -#define NETWORK_ERROR_PORT -4 -#define NETWORK_ERROR_SEND_RESPONSE -5 -#define NETWORK_ERROR_SEND_FAILED -6 - -#define ACK(fd) net_write(fd, "", 1); -#define NACK(fd) net_write(fd, "\1", 1); - -extern int net_open(char *host, int timeout); -extern int net_close(int nd); -extern int net_read(int nd, char *buf, int len); -extern int net_write(int nd, char *buf, int len); -extern int net_printf(int nd, char *fmt, ...); -extern char *net_gets(char *buf, int size, int nd); -extern int net_send_message(int nd, char *fmt, ...); -extern int net_response(int nd); -extern int net_send_file(int nd, char *name, char *data, int data_len, - int type); - -#ifdef __cplusplus -} -#endif - -#endif /* _NETWORK_H */ diff --git a/usr/src/lib/print/libprint/common/ns.c b/usr/src/lib/print/libprint/common/ns.c index fd0a54bd33..baf514c9fd 100644 --- a/usr/src/lib/print/libprint/common/ns.c +++ b/usr/src/lib/print/libprint/common/ns.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -39,7 +39,6 @@ #include <ns.h> #include <list.h> -#include <misc.h> /* diff --git a/usr/src/lib/print/libprint/common/ns_bsd_addr.c b/usr/src/lib/print/libprint/common/ns_bsd_addr.c index c908d4375c..ba142bb8a1 100644 --- a/usr/src/lib/print/libprint/common/ns_bsd_addr.c +++ b/usr/src/lib/print/libprint/common/ns_bsd_addr.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -37,7 +37,20 @@ #include <ns.h> #include <list.h> -#include <misc.h> + +static char ** +strsplit(char *string, char *seperators) +{ + char **list = NULL; + char *where = NULL; + char *element; + + for (element = strtok_r(string, seperators, &where); element != NULL; + element = strtok_r(NULL, seperators, &where)) + list = (char **)list_append((void **)list, element); + + return (list); +} /* * Manipulate bsd_addr structures diff --git a/usr/src/lib/print/libprint/common/nss_convert.c b/usr/src/lib/print/libprint/common/nss_convert.c index fae5610b98..eaee6df5b2 100644 --- a/usr/src/lib/print/libprint/common/nss_convert.c +++ b/usr/src/lib/print/libprint/common/nss_convert.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -40,7 +40,6 @@ #include <ns.h> #include <list.h> -#include <misc.h> #define ESCAPE_CHARS "\\\n=:" /* \, \n, =, : */ diff --git a/usr/src/lib/print/libprint/common/nss_ldap.c b/usr/src/lib/print/libprint/common/nss_ldap.c index 887babc740..c2140d5048 100644 --- a/usr/src/lib/print/libprint/common/nss_ldap.c +++ b/usr/src/lib/print/libprint/common/nss_ldap.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -41,7 +41,6 @@ #include <ns.h> #include <list.h> -#include <misc.h> #define LDAP_REFERRALS #include <lber.h> diff --git a/usr/src/lib/print/libprint/common/nss_write.c b/usr/src/lib/print/libprint/common/nss_write.c index 77f894be5a..c30c1274b4 100644 --- a/usr/src/lib/print/libprint/common/nss_write.c +++ b/usr/src/lib/print/libprint/common/nss_write.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -41,7 +41,6 @@ #include <ns.h> #include <list.h> -#include <misc.h> /* escaped chars include delimiters and shell meta characters */ #define ESCAPE_CHARS "\\\n=: `&;|>^$()<*?[" diff --git a/usr/src/tools/pmodes/exceptions.h b/usr/src/tools/pmodes/exceptions.h index bdb1222080..2ddc3a5de9 100644 --- a/usr/src/tools/pmodes/exceptions.h +++ b/usr/src/tools/pmodes/exceptions.h @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,8 +19,8 @@ * CDDL HEADER END */ /* - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. * * $Id: exceptions.h,v 1.11 2000/01/13 14:12:58 casper Exp $ * @@ -57,6 +56,9 @@ "/var/spool/lp/requests", "/var/spool/lp/system", + /* CUPS */ + "/var/cache/cups", + /* another strange logfile */ "/usr/oasys/tmp/TERRLOG", |