summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorjacobs <none@none>2006-11-15 19:19:07 -0800
committerjacobs <none@none>2006-11-15 19:19:07 -0800
commit0a44ef6d9afbfe052a7e975f55ea0d2954b62a82 (patch)
treeafca18ba6ad0fb467b29e368f05399e53a19ec4a /usr/src
parent3383b6dda001791704e0e66f7b78dd0dfe74f547 (diff)
downloadillumos-joyent-0a44ef6d9afbfe052a7e975f55ea0d2954b62a82.tar.gz
4634017 Lpadmin's new printer limit needs to be increased.
4941143 lpsched leaks memory in freeprinter() 6480891 lpsched fixes unused files 6486772 in.lpd should use libpapi 6486967 print-svc refers to /usr/sbin/cut 6487898 lpadmin doesn't add remote access 6488443 printmr/lpadmin should prefer IPP support when it's available 6490445 psm-lpd has incorrect mime type in it's translation table 6490453 lpr uses the wrong default mime type 6491971 in.lpd and the ipp listener should detect cycles 6491978 libhttp-core should build when -DDEBUG is specified 6492414 lpstat -o -l should report on requested form when available --HG-- rename : usr/src/cmd/lp/cmd/adaptor/Makefile => deleted_files/usr/src/cmd/lp/cmd/adaptor/Makefile rename : usr/src/cmd/lp/cmd/adaptor/cancel_job.c => deleted_files/usr/src/cmd/lp/cmd/adaptor/cancel_job.c rename : usr/src/cmd/lp/cmd/adaptor/misc.c => deleted_files/usr/src/cmd/lp/cmd/adaptor/misc.c rename : usr/src/cmd/lp/cmd/adaptor/misc.h => deleted_files/usr/src/cmd/lp/cmd/adaptor/misc.h rename : usr/src/cmd/lp/cmd/adaptor/show_queue.c => deleted_files/usr/src/cmd/lp/cmd/adaptor/show_queue.c rename : usr/src/cmd/lp/cmd/adaptor/submit_job.c => deleted_files/usr/src/cmd/lp/cmd/adaptor/submit_job.c rename : usr/src/cmd/print/gateway/Makefile => deleted_files/usr/src/cmd/print/gateway/Makefile rename : usr/src/cmd/print/gateway/adaptor.c => deleted_files/usr/src/cmd/print/gateway/adaptor.c rename : usr/src/cmd/print/gateway/adaptor.h => deleted_files/usr/src/cmd/print/gateway/adaptor.h rename : usr/src/cmd/print/gateway/cleanup.xml => deleted_files/usr/src/cmd/print/gateway/cleanup.xml rename : usr/src/cmd/print/gateway/main.c => deleted_files/usr/src/cmd/print/gateway/main.c rename : usr/src/cmd/print/gateway/print-cleanup => deleted_files/usr/src/cmd/print/gateway/print-cleanup rename : usr/src/cmd/print/gateway/printd.c => deleted_files/usr/src/cmd/print/gateway/printd.c rename : usr/src/cmd/print/gateway/translators/Makefile => deleted_files/usr/src/cmd/print/gateway/translators/Makefile rename : usr/src/cmd/print/gateway/translators/cascade/Makefile => deleted_files/usr/src/cmd/print/gateway/translators/cascade/Makefile rename : usr/src/cmd/print/gateway/translators/cascade/cascade.c => deleted_files/usr/src/cmd/print/gateway/translators/cascade/cascade.c rename : usr/src/cmd/print/gateway/translators/test/Makefile => deleted_files/usr/src/cmd/print/gateway/translators/test/Makefile rename : usr/src/cmd/print/gateway/translators/test/README => deleted_files/usr/src/cmd/print/gateway/translators/test/README rename : usr/src/cmd/print/gateway/translators/test/test.c => deleted_files/usr/src/cmd/print/gateway/translators/test/test.c rename : usr/src/cmd/print/gateway/rfc1179.xml => usr/src/cmd/print/bsd-sysv-commands/rfc1179.xml
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/lp/Makefile2
-rw-r--r--usr/src/cmd/lp/cmd/Makefile9
-rw-r--r--usr/src/cmd/lp/cmd/adaptor/Makefile76
-rw-r--r--usr/src/cmd/lp/cmd/adaptor/cancel_job.c236
-rw-r--r--usr/src/cmd/lp/cmd/adaptor/misc.c299
-rw-r--r--usr/src/cmd/lp/cmd/adaptor/misc.h38
-rw-r--r--usr/src/cmd/lp/cmd/adaptor/show_queue.c261
-rw-r--r--usr/src/cmd/lp/cmd/adaptor/submit_job.c690
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/alerts.c97
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/cancel.c27
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/daisyforms.c66
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/disp1.c330
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/disp2.c252
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/disp3.c159
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/disp4.c43
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/disp5.c48
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/dispatch.h2
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/disptab.c7
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/dowait.c40
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/exec.c70
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/faults.c20
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/files.c24
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/fncs.c594
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/init.c569
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/log.c19
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/lpfsck.c2
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/lpsched.c76
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/lpsched.h105
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/msgs.c47
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/nodes.h120
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/notify.c13
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/print-svc2
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/requeue.c22
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/rstatus.c98
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/schedule.c123
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/status.c88
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/terminate.c21
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/validate.c31
-rw-r--r--usr/src/cmd/lp/cmd/lpsched/validate.h11
-rw-r--r--usr/src/cmd/lp/include/lp.h3
-rw-r--r--usr/src/cmd/lp/include/msgs.h46
-rw-r--r--usr/src/cmd/lp/include/printers.h8
-rw-r--r--usr/src/cmd/lp/include/requests.h19
-rw-r--r--usr/src/cmd/lp/include/secure.h8
-rw-r--r--usr/src/cmd/lp/lib/class/freeclass.c17
-rw-r--r--usr/src/cmd/lp/lib/class/getclass.c35
-rw-r--r--usr/src/cmd/lp/lib/lp/getpaths.c2
-rw-r--r--usr/src/cmd/lp/lib/msgs/msgfmts.c4
-rw-r--r--usr/src/cmd/lp/lib/papi/lpsched-jobs.c35
-rw-r--r--usr/src/cmd/lp/lib/papi/lpsched-msgs.c8
-rw-r--r--usr/src/cmd/lp/lib/papi/mapfile3
-rw-r--r--usr/src/cmd/lp/lib/printers/freeprinter.c20
-rw-r--r--usr/src/cmd/lp/lib/printers/getprinter.c127
-rw-r--r--usr/src/cmd/lp/lib/printers/printwheels.c20
-rw-r--r--usr/src/cmd/lp/lib/requests/freerequest.c15
-rw-r--r--usr/src/cmd/lp/lib/requests/getrequest.c109
-rw-r--r--usr/src/cmd/lp/lib/requests/putrequest.c13
-rw-r--r--usr/src/cmd/lp/lib/secure/secure.c51
-rw-r--r--usr/src/cmd/print/Makefile4
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/Makefile20
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/common.c75
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/common.h2
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/in.lpd.c635
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/lp.c52
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/lpr.c9
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/lpstat.c6
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/rfc1179.xml (renamed from usr/src/cmd/print/gateway/rfc1179.xml)17
-rw-r--r--usr/src/cmd/print/gateway/Makefile106
-rw-r--r--usr/src/cmd/print/gateway/adaptor.c359
-rw-r--r--usr/src/cmd/print/gateway/adaptor.h65
-rw-r--r--usr/src/cmd/print/gateway/cleanup.xml88
-rw-r--r--usr/src/cmd/print/gateway/main.c609
-rw-r--r--usr/src/cmd/print/gateway/print-cleanup47
-rw-r--r--usr/src/cmd/print/gateway/printd.c336
-rw-r--r--usr/src/cmd/print/gateway/translators/Makefile50
-rw-r--r--usr/src/cmd/print/gateway/translators/cascade/Makefile70
-rw-r--r--usr/src/cmd/print/gateway/translators/cascade/cascade.c373
-rw-r--r--usr/src/cmd/print/gateway/translators/test/Makefile70
-rw-r--r--usr/src/cmd/print/gateway/translators/test/README60
-rw-r--r--usr/src/cmd/print/gateway/translators/test/test.c238
-rw-r--r--usr/src/cmd/print/scripts/lpadmin26
-rw-r--r--usr/src/lib/print/libhttp-core/common/http.c2
-rw-r--r--usr/src/lib/print/libhttp-core/common/http.h3
-rw-r--r--usr/src/lib/print/libipp-listener/common/ipp-listener.c68
-rw-r--r--usr/src/lib/print/libpapi-common/common/attribute.c2
-rw-r--r--usr/src/lib/print/libpapi-common/common/common.c3
-rw-r--r--usr/src/lib/print/libpapi-common/common/list.c52
-rw-r--r--usr/src/lib/print/libpapi-common/common/mapfile4
-rw-r--r--usr/src/lib/print/libpapi-common/common/papi.h2
-rw-r--r--usr/src/lib/print/libpapi-dynamic/common/mapfile2
-rw-r--r--usr/src/lib/print/libpapi-ipp/common/ipp-support.c2
-rw-r--r--usr/src/lib/print/libpapi-ipp/common/mapfile2
-rw-r--r--usr/src/lib/print/libpapi-lpd/common/lpd-job.c4
-rw-r--r--usr/src/lib/print/libpapi-lpd/common/mapfile2
-rw-r--r--usr/src/pkgdefs/SUNWpcr/prototype_com12
-rw-r--r--usr/src/pkgdefs/SUNWpcu/Makefile1
-rw-r--r--usr/src/pkgdefs/SUNWpcu/prototype_com6
-rw-r--r--usr/src/pkgdefs/SUNWpsu/prototype_com6
98 files changed, 2408 insertions, 6362 deletions
diff --git a/usr/src/cmd/lp/Makefile b/usr/src/cmd/lp/Makefile
index a57b7a8561..0ebfa7228d 100644
--- a/usr/src/cmd/lp/Makefile
+++ b/usr/src/cmd/lp/Makefile
@@ -38,7 +38,6 @@ ROOTDIRS = \
$(ROOTLIBLP)/model \
$(ROOTLIBLPLOCL) \
$(ROOTLIB)/print \
- $(ROOTLIB)/print/bsd-adaptor \
$(LPOWNSDIRS)
LPOWNSDIRS = \
$(ROOTETCLP) \
@@ -85,7 +84,6 @@ $(ROOTVARSP)/lp/system := DIRMODE = 775
$(LPOWNSDIRS) := OWNER = lp
$(LPOWNSDIRS) := GROUP = lp
$(ROOTLIB)/print := DIRMODE = 0755
-$(ROOTLIB)/print/bsd-adaptor := DIRMODE = 0755
POFILE= lp.po
POFILES= lp_*.po
diff --git a/usr/src/cmd/lp/cmd/Makefile b/usr/src/cmd/lp/cmd/Makefile
index 17a2af2d01..e558d3c992 100644
--- a/usr/src/cmd/lp/cmd/Makefile
+++ b/usr/src/cmd/lp/cmd/Makefile
@@ -20,20 +20,19 @@
#
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# cmd/lp/cmd/Makefile
+
+#
+# ident "%Z%%M% %I% %E% SMI"
#
include ../Makefile.lp
OWNER = root
-SUBDIRS = lptest lpadmin lpsched adaptor scripts
+SUBDIRS = lptest lpadmin lpsched scripts
LOCALPROG = lpshut
diff --git a/usr/src/cmd/lp/cmd/adaptor/Makefile b/usr/src/cmd/lp/cmd/adaptor/Makefile
deleted file mode 100644
index 088d384e24..0000000000
--- a/usr/src/cmd/lp/cmd/adaptor/Makefile
+++ /dev/null
@@ -1,76 +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.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-LIBRARY = bsd_lpsched.a
-VERS=.1
-
-OBJECTS = show_queue.o cancel_job.o submit_job.o misc.o
-
-include ../../../../lib/Makefile.lib
-include ../../Makefile.lp
-
-# There should be a mapfile here
-MAPFILES =
-
-ROOTLIBDIR= $(ROOT)/usr/lib/print/bsd-adaptor
-
-CPPFLAGS += -I$(LPINC)
-CPPFLAGS += -I$(SRC)/lib/print/libprint/common
-LDLIBS += -lprint -z lazyload -ltsol -z nolazyload -lc
-LDLIBS += -L$(SRC)/cmd/lp/lib/msgs -llpmsg
-LDLIBS += -L$(SRC)/cmd/lp/lib/class -llpcls
-LDLIBS += -L$(SRC)/cmd/lp/lib/lp -llp
-LDLIBS += -L$(SRC)/cmd/lp/lib/requests -llpreq
-LDLIBS += -L$(SRC)/cmd/lp/lib/secure -llpsec
-
-
-LIBS = $(DYNLIB)
-SRCS= $(OBJECTS:%.o=%.c)
-
-POFILE= lp_cmd_adaptor.po
-OBJS= $(OBJECTS)
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-_msg:
- @echo "Messages are made in usr/src/cmd/lp"
-
-install: $(ROOTLIBS) $(ROOTLINKS)
-
-cstyle:
- cstyle $(SRCS)
-
-lint:
- $(LINT.c) $(SRCS)
-
-strip:
-
-include ../../../../lib/Makefile.targ
-
-include ../Makefile.msg
diff --git a/usr/src/cmd/lp/cmd/adaptor/cancel_job.c b/usr/src/cmd/lp/cmd/adaptor/cancel_job.c
deleted file mode 100644
index 4ae65e5dcc..0000000000
--- a/usr/src/cmd/lp/cmd/adaptor/cancel_job.c
+++ /dev/null
@@ -1,236 +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"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/systeminfo.h>
-#include <string.h>
-#include <libintl.h>
-#include <netdb.h>
-
-#include <syslog.h>
-
-/* lpsched include files */
-#include "lp.h"
-#include "msgs.h"
-#include "printers.h"
-#include "class.h"
-
-#include "misc.h"
-
-/* print NS include */
-#include <ns.h>
-
-
-static char *
-cancel_requestor(const char *printer, const char *user, const char *host)
-{
- static char buf[BUFSIZ]; /* This is larger than necessary */
- char *tmp, *s;
- ns_printer_t *pobj;
-
- if (((pobj = ns_printer_get_name(printer, NULL)) != NULL) &&
- ((tmp = ns_get_value_string("user-equivalence", pobj)) != NULL) &&
- (strcasecmp(tmp, "true") == 0) && ((strcmp(user, "root") != 0) ||
- (strcmp(user, "lp") != 0)))
- host = "all";
-
- tmp = strdup(user);
- while ((s = strpbrk(tmp, "()")) != NULL)
- *s = '_';
- user = tmp;
-
- if ((strcmp(user, "root") == 0) || (strcmp(user, "lp") == 0)) {
- user = "all"; /* root/lp can cancel any request */
- if (strcmp(host, "all") != 0) {
- char thost[MAXHOSTNAMELEN];
-
- sysinfo(SI_HOSTNAME, thost, sizeof (thost));
- if ((strcasecmp(host, thost) == 0) ||
- ((strcasecmp(host, "localhost") == 0)))
- host = "all"; /* cancel from anywhere */
- }
- }
-
- snprintf(buf, sizeof (buf), "%s@%s", user, host);
-
- return (buf);
-}
-
-/*
- * lpsched_cancel_job() attempts to cancel an lpsched requests that match the
- * passed in criteria. a message is written for each cancelation or
- * attempted cancelation
- */
-int
-lpsched_cancel_job(const char *printer, FILE *ofp, const char *requestor,
- const char *host, const char **list)
-{
- short status;
- char **job_list = NULL;
- char *cancel_name;
- int first_job_only = 0;
-
- syslog(LOG_DEBUG, "cancel_job(%s, %d, %s, %s, 0x%x)",
- (printer ? printer : "NULL"), ofp, requestor, host, list);
-
- if ((printer == NULL) || (requestor == NULL) || (host == NULL) ||
- (list == NULL))
- return (-1);
-
- /* if list is empty, then cancel only the first job */
- if ((*list == NULL) && (strcmp(requestor, "-all") != 0))
- first_job_only = 1;
-
- if (!isprinter((char *)printer) && !isclass((char *)printer)) {
- fprintf(ofp, gettext("unknown printer/class"));
- return (-1);
- }
-
- if (snd_msg(S_INQUIRE_REQUEST, "", printer, "", "", "") < 0) {
- fprintf(ofp, gettext("Failure to communicate with lpsched\n"));
- return (-1);
- }
-
- do {
- size_t size;
- time_t date;
- short outcome;
- char *dest, *slabel, *form, *pwheel, *file, *owner, *reqid;
- const char **list_ptr = list;
- char buf[BUFSIZ];
-
- if (rcv_msg(R_INQUIRE_REQUEST, &status, &reqid, &owner, &slabel,
- &size, &date, &outcome, &dest, &form, &pwheel,
- &file) < 0) {
- fprintf(ofp,
- gettext("Failure to communicate with lpsched\n"));
- return (-1);
- }
-
- switch (status) {
- case MOK:
- case MOKMORE:
-
- /*
- * if cancelling only the fist job, then add
- * the first job to job_list and increment
- * first_job_only so no more jobs get added
- */
- if (first_job_only == 1) {
- snprintf(buf, sizeof (buf), "%s %s", owner,
- reqid);
- appendlist(&job_list, buf);
- first_job_only++;
- break;
- } else if (first_job_only > 1)
- break;
-
- if (strcasecmp(requestor, "-all") == 0) {
- snprintf(buf, sizeof (buf), "%s %s", owner,
- reqid);
- appendlist(&job_list, buf);
- break;
- }
-
- while ((list_ptr != NULL) && (*list_ptr != NULL)) {
- char *user = (char *)user_name(owner);
- int rid = id_no(reqid);
- int id = atoi(*list_ptr++);
-
- if ((rid == id) ||
- (strcmp(user, list_ptr[-1]) == 0)) {
- snprintf(buf, sizeof (buf), "%s %s",
- owner, reqid);
- appendlist(&job_list, buf);
- }
- }
- break;
- default:
- break;
- }
- } while (status == MOKMORE);
-
- if (strcasecmp(requestor, "-all") == 0)
- requestor = "root";
-
- cancel_name = cancel_requestor(printer, requestor, host);
-
- while ((job_list != NULL) && (*job_list != NULL)) {
- char *user = strtok(*job_list, " ");
- char *reqid = strtok(NULL, " ");
-
- syslog(LOG_DEBUG,
- "cancel %s, owned by %s, on %s, requested by %s\n",
- reqid, user, printer, cancel_name);
-
- if (snd_msg(S_CANCEL, printer, cancel_name, reqid) < 0) {
- fprintf(ofp,
- gettext("Failure to communicate with lpsched\n"));
- return (-1);
- }
-
- do {
- int status2;
- char *job_name = "unknown";
-
- if (rcv_msg(R_CANCEL, &status, &status2,
- &job_name) < 0) {
- fprintf(ofp,
- gettext("Failure to communicate with lpsched\n"));
- return (-1);
- }
-
- switch (status2) {
- case MOK:
- case MOKMORE:
- fprintf(ofp, gettext("%s: cancelled\n"),
- job_name);
- break;
- case MUNKNOWN:
- case MNOPERM:
- fprintf(ofp, gettext("%s: permission denied\n"),
- reqid);
- break;
- break;
- case M2LATE:
- fprintf(ofp, gettext("cannot dequeue %s\n"),
- job_name);
- break;
- default:
- fprintf(ofp,
- gettext("%s: cancel failed (%d)\n"),
- reqid, status2);
- break;
- }
- } while (status == MOKMORE);
- job_list++;
- }
-
- return (0);
-}
diff --git a/usr/src/cmd/lp/cmd/adaptor/misc.c b/usr/src/cmd/lp/cmd/adaptor/misc.c
deleted file mode 100644
index 4aeb08b4df..0000000000
--- a/usr/src/cmd/lp/cmd/adaptor/misc.c
+++ /dev/null
@@ -1,299 +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"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <stdarg.h>
-#include <sys/systeminfo.h>
-#include <netdb.h>
-#include <pwd.h>
-
-#include <syslog.h>
-
-#include <tsol/label.h>
-
-#include "misc.h"
-
-/* lpsched include files */
-#include "lp.h"
-#include "msgs.h"
-#include "printers.h"
-
-static char Msg[MSGMAX];
-
-/*
- * Format and send message to lpsched
- * (die if any errors occur)
- */
-/*VARARGS1*/
-int
-snd_msg(int type, ...)
-{
- int rc = -1;
- va_list ap;
-
- va_start(ap, type);
- if ((_putmessage(Msg, type, ap) >= 0) && (msend(Msg) >= 0))
- rc = 0;
- va_end(ap);
- return (rc);
-}
-
-/*
- * Recieve message from lpsched
- * (die if any errors occur)
- */
-int
-rcv_msg(int type, ...)
-{
- int rc = -1;
- va_list ap;
-
- va_start(ap, type);
- if ((mrecv(Msg, MSGMAX) == type) && (_getmessage(Msg, type, ap) >= 0))
- rc = 0;
- va_end(ap);
- return (rc);
-}
-
-
-/*
- * id_no() pulls the job id number out of a request id in the format of
- * printer-job_id
- */
-int
-id_no(const char *id)
-{
- char *tmp;
-
- if ((id == NULL) || ((tmp = strrchr(id, '-')) == NULL))
- return (-1);
- tmp++;
- return (atoi(tmp));
-}
-
-
-/*
- * user_name() pulls the user name out of a string in the format of
- * host!user or user@host
- */
-char *
-user_name(const char *user)
-{
- static char result[BUFSIZ];
- char *tmp;
-
- if ((tmp = strchr(user, '@')) != NULL) {
- *tmp = '\0';
- snprintf(result, sizeof (result), "%s", user);
- *tmp = '@';
- } else if ((tmp = strrchr(user, '!')) != NULL)
- snprintf(result, sizeof (result), "%s", ++tmp);
- else
- snprintf(result, sizeof (result), "%s", user);
-
- return (result);
-}
-
-
-/*
- * host_name() pulls the host name out of a string in the format of
- * host!user. If no host exists, the local hostname is returned.
- */
-char *
-user_host(const char *user)
-{
- static char host[MAXHOSTNAMELEN];
- char *tmp;
-
- snprintf(host, sizeof (host), "%s", user);
- if ((tmp = strrchr(user, '@')) != NULL) {
- snprintf(host, sizeof (host), "%s", ++tmp);
- } else if ((tmp = strrchr(user, '!')) != NULL) {
- *tmp = '\0';
- snprintf(host, sizeof (host), "%s", user);
- *tmp = '!';
- } else
- snprintf(host, sizeof (host), "%s", "localhost");
-
-
- return (host);
-}
-
-
-/*
- * lpsched_server_available() opens the connection to lpsched
- */
-int
-lpsched_spooler_available(const char *printer)
-{
- syslog(LOG_DEBUG, "lpsched_spooler_available(%s)",
- (printer ? printer : "NULL"));
-
- if (printer == NULL)
- return (-1);
-
- return (mopen());
-}
-
-
-/*
- * lpsched_spooler_accepting_jobs() will ask the spooler if it is currently
- * accepting jobs for the specified printer. If it is, a 0 will be returned,
- * if not -1.
- */
-int
-lpsched_spooler_accepting_jobs(const char *printer)
-{
- short status = 0,
- prstatus = 0;
- char *prname = NULL,
- *form = NULL,
- *pwheel = NULL,
- *dis_reason = NULL,
- *rej_reason = NULL,
- *reqid = NULL;
- time_t *dis_date = NULL,
- *rej_date = NULL;
-
- syslog(LOG_DEBUG, "lpsched_spooler_accepting_jobs(%s)",
- (printer ? printer : "NULL"));
-
- if (printer == NULL)
- return (-1);
-
- if (isprinter((char *)printer)) {
- if ((snd_msg(S_INQUIRE_PRINTER_STATUS, printer) < 0) ||
- (rcv_msg(R_INQUIRE_PRINTER_STATUS, &status, &prname, &form,
- &pwheel, &dis_reason, &rej_reason, &prstatus,
- &reqid, &dis_date, &rej_date) < 0))
- status = MUNKNOWN;
- } else if (isclass(printer)) {
- if ((snd_msg(S_INQUIRE_CLASS, printer) < 0) ||
- (rcv_msg(R_INQUIRE_CLASS, &status, &prname,
- &prstatus, &rej_reason, &rej_date) < 0))
- status = MUNKNOWN;
- } else
- status = MUNKNOWN;
-
- if ((status == MOK) && ((prstatus & PS_REJECTED) != PS_REJECTED))
- return (0);
- else
- return (-1);
-}
-
-
-/*
- * lpsched_client_access() is intended to validate that the requesting host
- * has access to communicate with the scheduler. In Solaris this currently
- * has no meaning. The host is automatically allowed access.
- */
-char *slabel = NULL;
-
-int
-lpsched_client_access(const char *printer, const char *host, int peerfd)
-{
- syslog(LOG_DEBUG, "lpsched_client_access(%s, %s, %d)",
- (printer ? printer : "NULL"), (host ? host : "NULL"),
- peerfd);
-
- if ((printer == NULL) || (host == NULL))
- return (-1);
-
- if (is_system_labeled()) {
- short status = MOK;
- extern MESG *lp_Md; /* liblpmsg supplies this */
-
- if ((snd_msg(S_PASS_PEER_CONNECTION) < 0) ||
- (ioctl(lp_Md->writefd, I_SENDFD, peerfd) < 0) ||
- (rcv_msg(R_PASS_PEER_CONNECTION, &status) < 0))
- status = MTRANSMITERR;
- if (status != MOK)
- return (-1);
-
- get_peer_label(peerfd, &slabel);
- }
-
- return (0);
-}
-
-
-/*
- * lpsched_restart_printer() is intended to restart processing of a queue. In
- * the lpsched spooling paradigm, this does nothing since the restart is
- * automatically done at job submission.
- */
-int
-lpsched_restart_printer(const char *printer)
-{
- syslog(LOG_DEBUG, "lpsched_restart_printer(%s)",
- (printer ? printer : "NULL"));
-
- if (printer == NULL)
- return (-1);
-
- return (0);
-}
-
-
-/*
- * lpsched_temp_dir() returns the location of the temporary disk space to
- * place transfered jobs. An attempt is always made to make the requests and
- * tmp directory for the requesting host. A NULL is returned upon failure to
- * locate a space.
- */
-char *
-lpsched_temp_dir(const char *printer, const char *host)
-{
- char buf[BUFSIZ];
- mode_t old_msk;
- struct passwd *p = NULL;
-
- syslog(LOG_DEBUG, "lpsched_temp_dir(%s, %s)",
- (printer ? printer : "NULL"), (host ? host : "NULL"));
-
- if ((printer == NULL) || (host == NULL))
- return (NULL);
-
- snprintf(buf, sizeof (buf), "%s/%s", Lp_Requests, host);
- old_msk = umask((mode_t)0);
- mkdir(buf, 0755);
- p = getpwnam("lp");
- if (p != NULL)
- chown(buf, p->pw_uid, p->pw_gid);
- snprintf(buf, sizeof (buf), "%s/%s", Lp_Tmp, host);
- mkdir(buf, 0775);
- if (p != NULL)
- chown(buf, p->pw_uid, p->pw_gid);
- (void) umask(old_msk);
-
- return (strdup(buf));
-}
diff --git a/usr/src/cmd/lp/cmd/adaptor/misc.h b/usr/src/cmd/lp/cmd/adaptor/misc.h
deleted file mode 100644
index f475468600..0000000000
--- a/usr/src/cmd/lp/cmd/adaptor/misc.h
+++ /dev/null
@@ -1,38 +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.
- */
-
-#ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(_MISC_H)
-#define _MISC_H
-
-extern int snd_msg(int, ...);
-extern int rcv_msg(int, ...);
-extern int id_no(const char *);
-extern char *user_name(const char *);
-extern char *user_host(const char *);
-extern char *slabel;
-
-#endif /* _MISC_H */
diff --git a/usr/src/cmd/lp/cmd/adaptor/show_queue.c b/usr/src/cmd/lp/cmd/adaptor/show_queue.c
deleted file mode 100644
index 4ed83bad82..0000000000
--- a/usr/src/cmd/lp/cmd/adaptor/show_queue.c
+++ /dev/null
@@ -1,261 +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"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <string.h>
-#include <libintl.h>
-
-#include <syslog.h>
-
-/* lpsched include files */
-#include "lp.h"
-#include "msgs.h"
-#include "printers.h"
-#include "class.h"
-
-#include "misc.h"
-
-static char *
-status_string(const char *printer, int *bad_status)
-{
- short status, prstatus;
- char *prname = NULL,
- *form = NULL,
- *pwheel = NULL,
- *dis_reason = NULL,
- *rej_reason = NULL,
- *reqid = NULL;
- time_t *dis_date = NULL,
- *rej_date = NULL;
- static char mesg[BUFSIZ];
-
- *bad_status = 1; /* assume it's bad news */
-
- if (printer == NULL)
- return ("no destination");
-
- if (isprinter((char *)printer)) {
- if ((snd_msg(S_INQUIRE_PRINTER_STATUS, printer) < 0) ||
- (rcv_msg(R_INQUIRE_PRINTER_STATUS, &status, &prname, &form,
- &pwheel, &dis_reason, &rej_reason, &prstatus,
- &reqid, &dis_date, &rej_date) < 0))
- status = MTRANSMITERR;
- } else if (isclass(printer)) {
- if ((snd_msg(S_INQUIRE_CLASS, printer) < 0) ||
- (rcv_msg(R_INQUIRE_CLASS, &status, &prname,
- &prstatus, &rej_reason, &rej_date) < 0))
- status = MTRANSMITERR;
- } else {
- snprintf(mesg, sizeof (mesg),
- gettext("%s: not a printer or class"), printer);
- return (mesg);
- }
-
- switch (status) {
- case MNODEST:
- snprintf(mesg, sizeof (mesg),
- gettext("unknown destination: %s"), printer);
- break;
- case MNOINFO:
- snprintf(mesg, sizeof (mesg),
- gettext("unknown status: %s"), printer);
- break;
- case MTRANSMITERR:
- snprintf(mesg, sizeof (mesg),
- gettext("failure to communicate with lpsched"));
- break;
- case MOK:
- if (prstatus & (PS_DISABLED | PS_FAULTED))
- snprintf(mesg, sizeof (mesg),
- gettext("Warning: %s is down: %s\n"),
- prname, dis_reason);
- else if (prstatus & PS_REJECTED)
- snprintf(mesg, sizeof (mesg),
- gettext("Warning: %s queue is turned off: %s\n"),
- prname, rej_reason);
- else if (!(prstatus & (PS_DISABLED | PS_FAULTED))) {
- *bad_status = 0;
- snprintf(mesg, sizeof (mesg),
- gettext("%s is ready and printing\n"),
- prname);
- }
-
- break;
- default:
- snprintf(mesg, sizeof (mesg),
- gettext("bad status: %s, 0x%x"), printer, status);
- break;
- }
-
- return (mesg);
-}
-
-
-static char *_rank_suffixes[] = {
- "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"
-};
-
-
-static char *
-rank_string(const int rank)
-{
- /* Room for ten digits (2 ^ 31) plus suffix plus NUL */
- static char buf[13];
-
- if (rank < 0)
- snprintf(buf, sizeof (buf), gettext("invalid"));
- else if (rank == 0)
- snprintf(buf, sizeof (buf), gettext("active"));
- else if ((rank > 10) && (rank < 14))
- sprintf(buf, "%dth", rank);
- else
- sprintf(buf, "%d%s", rank, _rank_suffixes[rank % 10]);
-
- return (buf);
-}
-
-
-static int
-is_matched(int id, char *user, const char **list)
-{
- if ((list == NULL) || (list[0] == NULL))
- return (1);
-
- while (*list != NULL)
- if ((strcmp(user, *list) == 0) || (atoi(*list) == id))
- return (1);
- else
- list++;
- return (0);
-}
-
-
-#define HEADER gettext("Rank\tOwner\tJob\tFile(s)\t\t\t\tTotal Size\n")
-
-static int
-job_list(const char *printer, FILE *ofp, const int type,
- const char **list, const char *status_message, int *rank)
-{
- int count = 0;
- short status, outcome;
-
-
- if (snd_msg(S_INQUIRE_REQUEST, "", printer, "", "", "") < 0)
- return (0);
- do {
- size_t size;
- time_t date;
- int id;
- char *user, *slabel, *reqid, *owner, *dest, *form, *pwheel,
- *file, *host;
-
- if (rcv_msg(R_INQUIRE_REQUEST, &status, &reqid, &owner, &slabel,
- &size, &date, &outcome, &dest, &form, &pwheel,
- &file) < 0)
- return (count);
-
- host = (char *)user_host(owner);
- user = (char *)user_name(owner);
- id = id_no(reqid);
-
- if (is_matched(id, user, list) == 0)
- continue;
-
- switch (status) {
- case MOK:
- case MOKMORE:
- count++;
- if (status_message != NULL) {
- fprintf(ofp, "%s", status_message);
- if (type == 3)
- fprintf(ofp, HEADER);
- status_message = NULL;
- }
- if (type == 3) { /* short format */
- fprintf(ofp,
- gettext("%s\t%s\t%d\t%-32.32s%d bytes\n"),
- rank_string((*rank)++), user,
- id, file, size);
- } else { /* long format */
- fprintf(ofp,
- gettext("\n%s: %s\t\t\t\t[job %d %s]\n\t%-32.32s\t%d bytes\n"),
- user, rank_string((*rank)++),
- id, host, file, size);
- }
-
- }
- } while (status == MOKMORE);
-
- return (count);
-}
-
-
-/*
- * lpsched_show_queue() attempts to display the queue of "pending" jobs. The
- * "type" is used to determine if this should be a short or long format
- * that gets written back to ofp.
- */
-int
-lpsched_show_queue(const char *printer, FILE *ofp, const int type,
- const char **list)
-{
- char *status_message = NULL;
- int rank = 0;
- char **plist = NULL;
- CLASS *clp = NULL;
-
- syslog(LOG_DEBUG, "lpsched_show_queue(%s, %d, %d, 0x%x)",
- (printer ? printer : "NULL"), ofp, type, list);
-
- if ((printer == NULL) || (list == NULL))
- return (-1);
-
- status_message = status_string(printer, &rank);
-
- if (isclass((char *)printer) &&
- ((clp = getclass((char *)printer)) != NULL))
- plist = clp->members;
-
- do {
- if (plist != NULL)
- printer = *(plist++);
-
- if (job_list(printer, ofp, type, list,
- (const char *)status_message, &rank) > 0)
- status_message = NULL;
-
- } while ((plist != NULL) && (*plist != NULL));
-
- if (rank == 0)
- fprintf(ofp, gettext("no entries\n"));
- else if (status_message != NULL)
- fprintf(ofp, "%s\n", status_message);
-
- return (0);
-}
diff --git a/usr/src/cmd/lp/cmd/adaptor/submit_job.c b/usr/src/cmd/lp/cmd/adaptor/submit_job.c
deleted file mode 100644
index ac6ad66fa4..0000000000
--- a/usr/src/cmd/lp/cmd/adaptor/submit_job.c
+++ /dev/null
@@ -1,690 +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"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/zone.h>
-#include <string.h>
-#include <libintl.h>
-
-#include <syslog.h>
-#include <stdarg.h>
-
-#include <tsol/label.h>
-
-#include "misc.h"
-
-/* lpsched include files */
-#if defined PS_FAULTED
-#undef PS_FAULTED
-#endif /* PS_FAULTED */
-#include "lp.h"
-#include "msgs.h"
-#include "printers.h"
-#include "class.h"
-#include "requests.h"
-#include "secure.h"
-
-#define PROTOCOL_MAX 1000
-#define MAX_JOB_ID (52 * PROTOCOL_MAX)
-#define LP_UID 71
-
-/*
- * This function replaces characters in a string that might be used
- * to exploit a security hole. Replace command seperators (`, &, ;, |, ^),
- * output redirection (>, |), variable expansion ($), and character
- * escape (\). Taken directly from lpsched/exec.c. If we ever build
- * a real library for LP, this should go in it.
- *
- * Bugid 4141687
- * Add ( ) < * ? [
- * Remove \
- */
-static void clean_string(char *ptr)
-{
- char *cp;
- wchar_t wc;
- size_t len;
-
- for (cp = ptr; *cp != NULL; ) {
- if ((len = mbtowc(&wc, cp, MB_CUR_MAX)) == -1) {
- cp++;
- continue;
- }
-
- if (len == 1 &&
- ((wc == L'`') || (wc == L'&') || (wc == L';') ||
- (wc == L'|') || (wc == L'>') || (wc == L'^') ||
- (wc == L'$') || (wc == L'(') || (wc == L')') ||
- (wc == L'<') || (wc == L'*') || (wc == L'?') ||
- (wc == L'[')))
- *cp = '_';
- cp += len;
- }
-}
-
-/*
- * mail() will send a mail message to the requesting user in the event of an
- * error during job submission.
- */
-
-static void
-mail(REQUEST *request, char *req_file, char *fmt, ...)
-{
- FILE *pp;
- char buf[BUFSIZ];
- char *uname;
- va_list ap;
- char *mail_zonename = NULL;
-
- /*
- * Clean-up user name so we don't pass flags to /bin/mail, or
- * pass nothing at all (uname == '#') which causes /bin/mail
- * to enter reader mode
- */
- uname = request->user;
- while (*uname == ' ' || *uname == '-' || *uname == '#')
- uname++;
-
- if (*uname == '\0')
- return; /* No username found */
-
- /*
- * If in the global zone and the system is labeled, mail is
- * handled via a local labeled zone that is the same label as the
- * request.
- */
- if ((getzoneid() == GLOBAL_ZONEID) && is_system_labeled() &&
- slabel != NULL) {
- if ((mail_zonename = get_labeled_zonename(slabel)) ==
- (char *)-1) {
- /* error during get_labeled_zonename, just return */
- return;
- }
- }
-
- /*
- * If mail_zonename is not NULL, use zlogin to execute /bin/mail
- * in the labeled zone 'mail_zonename'.
- */
-
- if (mail_zonename != NULL) {
- syslog(LOG_DEBUG,
- "lpsched: using '/usr/sbin/zlogin %s /bin/mail %s' to mail",
- mail_zonename, uname);
- snprintf(buf, sizeof (buf),
- "/usr/sbin/zlogin %s /bin/mail %s",
- mail_zonename, uname);
- Free(mail_zonename);
- } else {
- syslog(LOG_DEBUG,
- "lpsched: using '/bin/mail %s' to mail",
- uname);
- snprintf(buf, sizeof (buf), "/bin/mail %s", uname);
- }
- clean_string(buf);
- if ((pp = popen(buf, "w+")) == NULL)
- return;
- fprintf(pp, gettext("Subject: print request for %s failed\n\n"),
- request->destination);
-
- fprintf(pp, gettext("\n\tRequest File: %s"), req_file);
- fprintf(pp, gettext("\n\tDocument Type: %s"),
- (request->input_type ? request->input_type :
- gettext("(unknown)")));
- fprintf(pp, gettext("\n\tTitle:\t%s"),
- (request->title ? request->title : gettext("(none)")));
- fprintf(pp, gettext("\n\tCopies:\t%d"), request->copies);
- fprintf(pp, gettext("\n\tPriority:\t%d"), request->priority);
- fprintf(pp, gettext("\n\tForm:\t%s"),
- (request->form ? request->form : gettext("(none)")));
- fprintf(pp, gettext("\n\tOptions:\t%s"),
- (request->options ? request->options : gettext("(none)")));
- fprintf(pp, gettext("\n\tModes:\t%s"),
- (request->modes ? request->modes : gettext("(none)")));
-
- fprintf(pp, gettext("\n\tReason for Failure:\n\n\t\t"));
- va_start(ap, fmt);
- vfprintf(pp, fmt, ap);
- va_end(ap);
- fprintf(pp, "\n");
-
- pclose(pp);
-}
-
-
-/*
- * is_postscript() will detect if the file passed in contains postscript
- * data. A one is returned if the file contains postscript, zero is returned
- * if the file is not postscript, and -1 is returned if an error occurs
- */
-#define PS_MAGIC "%!"
-#define PC_PS_MAGIC "%!"
-static int
-is_postscript(const char *file)
-{
- char buf[3];
- int fd;
-
- if ((fd = open(file, O_RDONLY)) < 0)
- return (-1);
-
- if (read(fd, buf, sizeof (buf)) < 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))
- return (1);
- else
- return (0);
-}
-
-
-/*
- * name_to_id_no() will pull the id number out of a file name and attempt to
- * assign that ID to a print job. If the ID collides with an existing one, it
- * will increment and try again. This continues until an open ID is found, or
- * the ID space is exausted.
- */
-static int
-name_to_id_no(const char *name)
-{
- char *tmp, buf[BUFSIZ];
- int done = 1;
- int start;
- int id;
- int fd;
-
- strncpy(buf, name, sizeof (buf));
- for (tmp = buf; ((*tmp != NULL) && (isdigit(*tmp) == 0)); tmp++);
- if (*tmp == NULL)
- return (-1);
-
- if ((start = atoi(tmp)) < 0)
- start = 0;
- id = start;
-
- do {
- sprintf(buf, "%d-0", id);
- if ((fd = open(buf, O_CREAT|O_EXCL, 0600)) < 0) {
- syslog(LOG_DEBUG, "ID Collision %d", id);
- if ((id += PROTOCOL_MAX) >= MAX_JOB_ID) {
- id %= PROTOCOL_MAX;
- if (--id < 0)
- id = PROTOCOL_MAX -1;
- if (id == start) {
- syslog(LOG_ERR,
- "No Request IDs available");
- return (-1);
- }
- }
- } else
- done = 0;
- } while (done != 0);
-
- close(fd);
- return (id);
-}
-
-static void
-unlink_files(char **files)
-{
- while ((files != NULL) && (*files != NULL))
- unlink(*files++);
-}
-
-/*
- * parse_cf() will pass through the BSD Control file data and fill in a
- * request structure will all the information it can. The actual job data
- * files will not be placed in the request by this function.
- */
-static REQUEST *
-parse_cf(char *cf, const char *host)
-{
- static REQUEST request;
- char previous = NULL,
- *entry,
- *job_name = NULL,
- *class = NULL,
- *s,
- *user = NULL,
- **options = NULL,
- **file_list = NULL,
- **modes = NULL,
- *prtitle = NULL, /* pr title */
- text[BUFSIZ],
- buf[BUFSIZ];
- int copies_set = 0,
- count = 0,
- width = -1, /* pr width */
- indent = -1, /* pr indent */
- pr_specified = 0,
- banner = 0;
-
- memset(&request, 0, sizeof (request));
- request.priority = -1;
- request.copies = 1;
-
- entry = strdup(cf); /* duplicate it just for grins */
- for (entry = strtok(entry, "\n"); entry != NULL;
- entry = strtok(NULL, "\n")) {
-
- if (previous != entry[0]) { /* set the copy count */
- if (request.copies != 1)
- copies_set++;
- previous = entry[0];
- } else if ((copies_set == 0) &&
- ((entry[0] <= 'z') && (entry[0] >= 'a')))
- request.copies++;
-
- switch (entry[0]) {
- /* RFC-1179 options */
- case 'J': /* RFC-1179 Banner Job Name */
- job_name = ++entry;
- break;
- case 'C': /* RFC-1179 Banner Class Name */
- class = ++entry;
- break;
- case 'L': /* RFC-1179 Banner toggle */
- banner = 1;
- break;
- case 'T': /* RFC-1179 Title (pr) */
- prtitle = ++entry;
- break;
- case 'H': /* RFC-1179 Host */
- /* use the host as known by us, not by them */
- break;
- case 'P': /* RFC-1179 User */
- ++entry;
- while ((s = strpbrk(entry, " ()")) != NULL)
- *s = '_';
- user = entry;
- break;
- case 'M': /* RFC-1179 Mail to User */
- request.actions |= ACT_MAIL;
- break;
- case 'W': /* RFC-1179 Width (pr) */
- width = atoi(++entry);
- break;
- case 'I': /* RFC-1179 Indent (pr) */
- indent = atoi(++entry);
- break;
- case 'N': /* RFC-1179 Filename */
- /* could have HP extension embedded */
- if (entry[1] != ' ')
- appendlist(&file_list, ++entry);
- else if (entry[2] == 'O') /* HP lp -o options */
- appendlist(&options, ++entry);
- break;
- case 'U': /* RFC-1179 Unlink */
- break; /* ignored */
- case '1': /* RFC-1179 TROFF Font R */
- case '2': /* RFC-1179 TROFF Font I */
- case '3': /* RFC-1179 TROFF Font B */
- case '4': /* RFC-1179 TROFF Font S */
- break;
- case 'f': /* RFC-1179 ASCII file (print) */
- case 'l': /* RFC-1179 CATV file (print) */
- if (request.input_type == NULL) {
- if (is_postscript(++entry) == 1)
- request.input_type = "postscript";
- else
- request.input_type = "simple";
- }
- break;
- case 'o': /* RFC-1179 Postscript file (print) */
- if (request.input_type == NULL)
- request.input_type = "postscript";
- break;
- case 'p': /* RFC-1179 PR file (print) */
- pr_specified = 1;
- if (request.input_type == NULL)
- request.input_type = "pr";
- break;
- case 't': /* RFC-1179 TROFF file (print) */
- if (request.input_type == NULL)
- request.input_type = "otroff";
- break;
- case 'n': /* RFC-1179 DITROFF file (print) */
- if (request.input_type == NULL)
- request.input_type = "troff";
- break;
- case 'd': /* RFC-1179 DVI file (print) */
- if (request.input_type == NULL)
- request.input_type = "tex";
- break;
- case 'g': /* RFC-1179 GRAPH file (print) */
- if (request.input_type == NULL)
- request.input_type = "plot";
- break;
- case 'c': /* RFC-1179 CIF file (print) */
- if (request.input_type == NULL)
- request.input_type = "cif";
- break;
- case 'v': /* RFC-1179 RASTER file (print) */
- if (request.input_type == NULL)
- request.input_type = "raster";
- break;
- case 'r': /* RFC-1179 FORTRAN file (print) */
- if (request.input_type == NULL)
- request.input_type = "fortran";
- break;
- /* Sun Solaris Extensions */
- case 'O':
- ++entry;
- do {
- if (*entry != '"')
- text[count++] = *entry;
- } while (*entry++);
- appendlist(&options, text);
- break;
- case '5':
- switch (entry[1]) {
- case 'f': /* Solaris form */
- request.form = strdup(&entry[2]);
- break;
- case 'H': /* Solaris handling */
- if (strcmp(&entry[2], NAME_IMMEDIATE) == 0)
- request.actions |= ACT_IMMEDIATE;
- else if (strcmp(&entry[2], NAME_RESUME) == 0)
- request.actions |= ACT_RESUME;
- else if (strcmp(&entry[2], NAME_HOLD) == 0)
- request.actions |= ACT_HOLD;
- else
- syslog(LOG_INFO,
- "handling (%s): unknown",
- entry[2]);
- break;
- case 'p': /* Solaris notification */
- /* request.alert = strdup(&entry[2]); */
- request.actions |= ACT_MAIL;
- break;
- case 'P': /* Solaris page list */
- request.pages = strdup(&entry[2]);
- break;
- case 'q': /* Solaris priority */
- request.priority = atoi(&entry[2]);
- break;
- case 'S': /* Solaris character set */
- request.charset = strdup(&entry[2]);
- break;
- case 'T': /* Solaris type */
- if (request.input_type == NULL)
- request.input_type = strdup(&entry[2]);
- break;
- case 'y': /* Solaris mode */
- appendlist(&modes, &entry[2]);
- break;
- default:
- syslog(LOG_INFO|LOG_DEBUG,
- "Warning: cf message (%s) ignored",
- entry);
- break;
- }
- break;
- /* HP Extensions */
-
- /* Undefined Extensions */
- default:
- syslog(LOG_INFO|LOG_DEBUG,
- "Warning: cf message (%s) ignored", entry);
- break;
- }
- }
-
- /* The -p option must be specified with the -T, -w, and -i options */
- if (prtitle != NULL)
- if (pr_specified == 1) {
- snprintf(buf, sizeof (buf), "prtitle='%s'",
- prtitle);
- appendlist(&modes, buf);
- } else
- syslog(LOG_DEBUG, "Warning: title option ignored "
- "as the pr filter option was not specified");
- if (width != -1)
- if (pr_specified == 1) {
- snprintf(buf, sizeof (buf), "prwidth=%d",
- width);
- appendlist(&modes, buf);
- } else
- syslog(LOG_DEBUG, "Warning: width option ignored "
- "as the pr filter option was not specified");
- if (indent != -1)
- if (pr_specified == 1) {
- snprintf(buf, sizeof (buf), "indent=%d",
- indent);
- appendlist(&modes, buf);
- } else
- syslog(LOG_DEBUG, "Warning: indent option ignored "
- "as the pr filter option was not specified");
-
- snprintf(buf, sizeof (buf), "%s%s%s", (user ? user : "nobody"),
- (host ? "@" : ""), (host ? host : ""));
- request.user = strdup(buf);
-
- if (banner != 0) {
- snprintf(buf, sizeof (buf), "%s%s%s",
- (job_name ? job_name : ""),
- (job_name && class ? "\\n#####\\n#####\\t\\t " : ""),
- (class ? class : ""));
- request.title = strdup(buf);
- } else
- appendlist(&options, "nobanner");
-
- if ((request.priority < 0) || (request.priority > 20))
- request.priority = 20;
-
- if (file_list != NULL) {
- char *tmp = sprintlist(file_list);
-
- snprintf(buf, sizeof (buf), "flist='%s'", tmp);
- appendlist(&options, buf);
- free(tmp);
- freelist(file_list);
- }
- if (options != NULL) {
- request.options = sprintlist(options);
- freelist(options);
- }
- if (modes != NULL) {
- request.modes = sprintlist(modes);
- freelist(modes);
- }
- request.version = VERSION_BSD; /* this probably isn't necessary */
-
- return (&request);
-}
-
-
-
-/*
- * submit_job() takes in a printer, host, control file, and list of data files.
- * it attempts to submit the print job to the local spooler using the lpsched
- * local named pipe. The routine will auto-detect if the first data file
- * is postscript, and set the job to "postscript". If an error occurs, a
- * message is mailed back to the requestor.
- */
-int
-lpsched_submit_job(const char *printer, const char *host, char *cf,
- char **df_list)
-{
- REQUEST *request = NULL;
- SECURE secure;
- char buf[MAXPATHLEN];
- int file_no = 0;
- int rc = -1;
- char *tmp_dir;
- char *tmp;
- short status;
- long bits;
- int request_id = 0;
- int job_size = 0;
-
- syslog(LOG_DEBUG, "lpsched_submit_job(%s, %s, 0x%x)",
- (printer ? printer : "NULL"), (cf ? cf : "NULL"), df_list);
-
- tmp_dir = (char *)lpsched_temp_dir(printer, host);
-
- if ((printer == NULL) || (host == NULL) || (cf == NULL) ||
- (df_list == NULL))
- return (-1);
-
- if ((request_id = name_to_id_no(df_list[0])) < 0)
- return (-1);
-
- if ((request = parse_cf(cf, host)) == NULL) {
- syslog(LOG_ERR|LOG_DEBUG,
- "Error parsing control file, Contents:\n%s\n", cf);
- return (-1);
- }
-
- request->destination = strdup(printer);
- while ((df_list != NULL) && (*df_list != NULL)) {
- struct stat st;
- /* move/rename the file to req-%d */
- snprintf(buf, sizeof (buf), "%s/%d-%d", tmp_dir, request_id,
- ++file_no);
- rename(*df_list++, buf);
- chown(buf, LP_UID, 0);
- if (stat(buf, &st) == 0)
- job_size += st.st_size;
-
- appendlist(&request->file_list, buf);
- }
-
- if (request->file_list == NULL) {
- syslog(LOG_ERR|LOG_DEBUG,
- "Job %d doesn't contain any data files", request_id);
- return (-1);
- }
-
- /* submit the request */
- memset(&secure, NULL, sizeof (secure));
- secure.size = job_size;
- secure.date = time(0);
- secure.system = strdup(host);
- secure.user = request->user;
- snprintf(buf, sizeof (buf), "%s-%d", printer, request_id);
- secure.req_id = strdup(buf);
- secure.uid = LP_UID;
- secure.gid = 0;
- secure.slabel = NULL;
-
- /* save the request file */
- snprintf(buf, sizeof (buf), "%s/%d-0", host, request_id);
- if (putrequest(buf, request) < 0) {
- mail(request, buf,
- gettext("Can't save print request"));
- unlink_files(request->file_list);
- return (-1);
- }
-
- /* save the secure file */
- if (putsecure(buf, &secure) < 0) {
- mail(request, buf,
- gettext("Can't save print secure file"));
- snprintf(buf, sizeof (buf), "%s/%s/%d-0", Lp_Tmp, host,
- request_id);
- unlink(buf);
- unlink_files(request->file_list);
- return (-1);
- }
-
- /* kick lpsched */
- if ((snd_msg(S_PRINT_REQUEST, buf) < 0) ||
- (rcv_msg(R_PRINT_REQUEST, &status, &tmp, &bits) < 0))
- status = MTRANSMITERR;
-
- /* how did we do ? */
- if (status != MOK) {
- rc = -1;
- switch (status) {
- case MNOMEM:
- mail(request, buf,
- gettext("lpsched: out of memory"));
- break;
- case MNOFILTER:
- mail(request, buf,
- gettext("No filter available to convert job"));
- break;
- case MNOOPEN:
- mail(request, buf,
- gettext("lpsched: could not open request"));
- break;
- case MERRDEST:
- mail(request, buf,
- gettext("An error occured in submission"));
- break;
- case MDENYDEST:
- mail(request, buf,
- gettext("Destination: %s, denied request"),
- printer);
- break;
- case MNOMEDIA:
- mail(request, buf,
- gettext("unknown form specified in job"));
- break;
- case MDENYMEDIA:
- mail(request, buf,
- gettext("access denied to form specified in job"));
- break;
- case MNOPERM:
- mail(request, buf,
- gettext("no permission for printer or job data empty"));
- break;
- case MTRANSMITERR:
- mail(request, buf,
- gettext("failure to communicate with lpsched"));
- break;
- default:
- mail(request, buf,
- gettext("Unknown error: %d"),
- status);
- break;
- }
-
- /* clean it up */
- snprintf(buf, sizeof (buf), "%s/%s/%d-0", Lp_Requests, host,
- request_id);
- unlink(buf);
- snprintf(buf, sizeof (buf), "%s/%s/%d-0", Lp_Tmp, host,
- request_id);
- unlink(buf);
- unlink_files(request->file_list);
- } else { /* It was OK */
- rc = 0;
- syslog(LOG_DEBUG, "Submit: %s", tmp);
- }
-
- return (rc);
-}
diff --git a/usr/src/cmd/lp/cmd/lpsched/alerts.c b/usr/src/cmd/lp/cmd/lpsched/alerts.c
index c6d2a24fc0..7e9b5c5824 100644
--- a/usr/src/cmd/lp/cmd/lpsched/alerts.c
+++ b/usr/src/cmd/lp/cmd/lpsched/alerts.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 1998 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,7 +27,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.11.1.4 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "lpsched.h"
#include "stdarg.h"
@@ -77,20 +76,15 @@ static int f_count(),
void
alert (int type, ...)
{
- PSTATUS *pr;
- RSTATUS *rp;
- FSTATUS *fp;
- PWSTATUS *pp;
- char *text;
va_list args;
va_start (args, type);
switch (type) {
- case A_PRINTER:
- pr = va_arg(args, PSTATUS *);
- rp = va_arg(args, RSTATUS *);
- text = va_arg(args, char *);
+ case A_PRINTER: {
+ PSTATUS *pr = va_arg(args, PSTATUS *);
+ RSTATUS *rp = va_arg(args, RSTATUS *);
+ char *text = va_arg(args, char *);
pformat(pr->alert->msgfile, text, pr, rp);
if (!pr->alert->active)
{
@@ -105,9 +99,9 @@ alert (int type, ...)
}
}
break;
-
- case A_PWHEEL:
- pp = va_arg(args, PWSTATUS *);
+ }
+ case A_PWHEEL: {
+ PWSTATUS *pp = va_arg(args, PWSTATUS *);
pwformat(pp->alert->msgfile, pp);
if (!pp->alert->active) {
if (exec(EX_PALERT, pp) == 0)
@@ -120,12 +114,12 @@ alert (int type, ...)
}
}
break;
-
+ }
case A_FORM: {
int isFormMessage;
char *formPath;
+ FSTATUS *fp = va_arg(args, FSTATUS *);
- fp = va_arg(args, FSTATUS *);
isFormMessage = (STREQU(fp->form->alert.shcmd, "showfault"));
if (isFormMessage)
formPath = makepath(Lp_A_Forms, fp->form->name,
@@ -178,8 +172,7 @@ pformat(char *file, char *text, PSTATUS *pr, RSTATUS *rp)
fdprintf(fd, Pf_msg[3], rp->secure->req_id);
}
fdprintf(fd, Pf_msg[4]);
- if (text)
- {
+ if (text) {
while (*text == '\n' || *text == '\r')
text++;
fdprintf(fd, "%s", text);
@@ -191,24 +184,22 @@ pformat(char *file, char *text, PSTATUS *pr, RSTATUS *rp)
static void
pwformat(char *file, PWSTATUS *pp)
{
- int fd;
- PSTATUS *p;
+ int fd, i;
if ((fd = open_locked(file, "w", MODE_READ)) < 0)
return;
fdprintf(fd, Pa_msg[0], NB(pp->pwheel->name), NB(pp->pwheel->name));
- for (p = walk_ptable(1); p; p = walk_ptable(0))
- if (
- p->printer->daisy
- && !SAME(p->pwheel_name, pp->pwheel->name)
- && searchlist(pp->pwheel->name, p->printer->char_sets)
- )
- {
- register int n = p_count(pp, p->printer->name);
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++) {
+ PSTATUS *p = PStatus[i];
+
+ if (p->printer->daisy && !SAME(p->pwheel_name, pp->pwheel->name) &&
+ searchlist(pp->pwheel->name, p->printer->char_sets)) {
+ int n = p_count(pp, p->printer->name);
if (n)
fdprintf(fd, Pa_msg[1], p->printer->name, n);
}
+ }
fdprintf(fd, Pa_msg[2], pp->requests);
close(fd);
pp->requests_last = pp->requests;
@@ -217,8 +208,7 @@ pwformat(char *file, PWSTATUS *pp)
static void
fformat(char *file, FSTATUS *fp, int isFormMessage)
{
- int fd;
- PSTATUS *p;
+ int fd, i;
int numLines=0;
if ((fd = open_locked(file, "w", MODE_READ)) < 0)
@@ -233,18 +223,21 @@ fformat(char *file, FSTATUS *fp, int isFormMessage)
else
fdprintf(fd, Fa_msg[0], NB(fp->form->name), NB(fp->form->name));
- for (p = walk_ptable(1); p; p = walk_ptable(0))
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++) {
+ PSTATUS *p = PStatus[i];
+
if ((! isFormMountedOnPrinter(p,fp)) &&
allowed(fp->form->name, p->forms_allowed,
p->forms_denied)) {
- register int n = f_count(fp, p->printer->name);
+ int n = f_count(fp, p->printer->name);
if (n) {
fdprintf(fd, Fa_msg[1], p->printer->name, n);
numLines++;
}
}
+ }
if (numLines != 1) fdprintf(fd, Fa_msg[2], fp->requests);
if (!isFormMessage) {
@@ -307,50 +300,50 @@ dest_equivalent_printer(char *dest, char *printer)
STREQU(dest, printer)
|| STREQU(dest, NAME_ANY)
|| (
- ((pc = search_ctable(dest)) != NULL)
+ ((pc = search_cstatus(dest)) != NULL)
&& searchlist(printer, pc->class->members)
)
);
}
static int
-f_count(fp, name)
-register FSTATUS *fp;
-register char *name;
+f_count(FSTATUS *fp, char *name)
{
- register int count = 0;
- register RSTATUS *rp;
+ int count = 0;
+ RSTATUS *rp;
- BEGIN_WALK_BY_FORM_LOOP(rp, fp)
- if (dest_equivalent_printer(rp->request->destination, name))
+ for (rp = Request_List; rp != NULL; rp = rp->next)
+ if ((rp->form == fp ) &&
+ (dest_equivalent_printer(rp->request->destination, name)))
count++;
- END_WALK_LOOP
+
if (
NewRequest
&& NewRequest->form == fp
&& dest_equivalent_printer(NewRequest->request->destination, name)
)
count++;
+
return(count);
}
static int
-p_count(pp, name)
-register PWSTATUS *pp;
-register char *name;
+p_count(PWSTATUS *pp, char *name)
{
- register int count = 0;
- register RSTATUS *rp;
+ int count = 0;
+ RSTATUS *rp;
- BEGIN_WALK_LOOP(rp, rp->pwheel == pp)
- if (dest_equivalent_printer(rp->request->destination, name))
+ for (rp = Request_List; rp != NULL; rp = rp->next)
+ if ((rp->pwheel == pp) &&
+ (dest_equivalent_printer(rp->request->destination, name)))
count++;
- END_WALK_LOOP
+
if (
NewRequest
&& NewRequest->pwheel == pp
&& dest_equivalent_printer(NewRequest->request->destination, name)
)
count++;
+
return(count);
}
diff --git a/usr/src/cmd/lp/cmd/lpsched/cancel.c b/usr/src/cmd/lp/cmd/lpsched/cancel.c
index 24029722e8..9b1fc200a7 100644
--- a/usr/src/cmd/lp/cmd/lpsched/cancel.c
+++ b/usr/src/cmd/lp/cmd/lpsched/cancel.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.
@@ -19,21 +18,19 @@
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
/*
- * Copyright (c) 2001 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
#pragma ident "%Z%%M% %I% %E% SMI"
#include "lpsched.h"
-static char cerrbuf[160] = ""; /* fix for bugid 1100252 */
-
/**
** cancel() - CANCEL A REQUEST
@@ -57,15 +54,7 @@ cancel (RSTATUS *prs, int spool)
terminate (prs->exec);
}
else if (prs->request->outcome | RS_NOTIFY) {
- /* start fix for bugid 1100252 */
- if (prs->printer->status & PS_REMOTE) {
- snprintf(cerrbuf, sizeof (cerrbuf),
- "Remote status=%d, canceled by remote system\n",
- prs->reason);
- }
- notify (prs, cerrbuf, 0, 0, 0);
- cerrbuf[0] = (char) NULL;
- /* end fix for bugid 1100252 */
+ notify (prs, "canceled by remote system\n", 0, 0, 0);
}
check_request (prs);
diff --git a/usr/src/cmd/lp/cmd/lpsched/daisyforms.c b/usr/src/cmd/lp/cmd/lpsched/daisyforms.c
index d72a8974a4..da4a22d627 100644
--- a/usr/src/cmd/lp/cmd/lpsched/daisyforms.c
+++ b/usr/src/cmd/lp/cmd/lpsched/daisyforms.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.
@@ -24,8 +23,8 @@
/*
- * Copyright (c) 2001 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -40,7 +39,7 @@ static int max_requests_needing_pwheel_mounted ( char * );
**/
void
-queue_form(register RSTATUS *prs, FSTATUS *pfs)
+queue_form(RSTATUS *prs, FSTATUS *pfs)
{
if ((prs->form = pfs) != NULL) {
prs->form->requests++;
@@ -55,7 +54,7 @@ queue_form(register RSTATUS *prs, FSTATUS *pfs)
**/
void
-unqueue_form(register RSTATUS *prs)
+unqueue_form(RSTATUS *prs)
{
FSTATUS * pfs = prs->form;
@@ -73,7 +72,7 @@ unqueue_form(register RSTATUS *prs)
**/
void
-queue_pwheel(register RSTATUS *prs, char *name)
+queue_pwheel(RSTATUS *prs, char *name)
{
if (name) {
prs->pwheel_name = Strdup(name);
@@ -85,7 +84,7 @@ queue_pwheel(register RSTATUS *prs, char *name)
*/
if (
!one_printer_with_charsets(prs)
- && (prs->pwheel = search_pwtable(name))
+ && (prs->pwheel = search_pwstatus(name))
) {
prs->pwheel->requests++;
check_pwheel_alert (prs->pwheel, (PWHEEL *)0);
@@ -99,7 +98,7 @@ queue_pwheel(register RSTATUS *prs, char *name)
**/
void
-unqueue_pwheel(register RSTATUS *prs)
+unqueue_pwheel(RSTATUS *prs)
{
PWSTATUS * ppws = prs->pwheel;
@@ -117,9 +116,9 @@ unqueue_pwheel(register RSTATUS *prs)
**/
void
-check_form_alert(register FSTATUS *pfs, register _FORM *pf)
+check_form_alert(FSTATUS *pfs, _FORM *pf)
{
- register short trigger,
+ short trigger,
fire_off_alert = 0;
int requests_waiting;
@@ -213,9 +212,9 @@ Return: if (pf) {
**/
void
-check_pwheel_alert(register PWSTATUS *ppws, register PWHEEL *ppw)
+check_pwheel_alert(PWSTATUS *ppws, PWHEEL *ppw)
{
- register short trigger,
+ short trigger,
fire_off_alert = 0;
int requests_waiting;
@@ -382,6 +381,7 @@ max_requests_needing_form_mounted(FSTATUS *pfs)
PSTATUS * pps;
RSTATUS * prs;
int max = 0;
+ int i;
/*
* For each printer that doesn't have this form mounted,
@@ -393,14 +393,15 @@ max_requests_needing_form_mounted(FSTATUS *pfs)
* through the printers would result in #printers x #requests
* steps, whereas this entails #requests steps.)
*/
- for (pps = walk_ptable(1); pps; pps = walk_ptable(0))
- pps->nrequests = 0;
- BEGIN_WALK_BY_FORM_LOOP (prs, pfs)
- if (((pps = prs->printer) != NULL) &&
- (!isFormMountedOnPrinter(pps,pfs)))
- if (++pps->nrequests >= max)
- max = pps->nrequests;
- END_WALK_LOOP
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
+ PStatus[i]->nrequests = 0;
+
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if ((prs->form == pfs) && ((pps = prs->printer) != NULL) &&
+ (!isFormMountedOnPrinter(pps,pfs)) &&
+ (++pps->nrequests >= max))
+ max = pps->nrequests;
+
if (NewRequest)
if (((pps = NewRequest->printer) != NULL) &&
(!isFormMountedOnPrinter(pps,pfs)))
@@ -415,6 +416,7 @@ max_requests_needing_pwheel_mounted(char *pwheel_name)
PSTATUS * pps;
RSTATUS * prs;
int max = 0;
+ int i;
/*
@@ -427,17 +429,17 @@ max_requests_needing_pwheel_mounted(char *pwheel_name)
* through the printers would result in #printers x #requests
* steps, whereas this entails #requests steps.)
*/
- for (pps = walk_ptable(1); pps; pps = walk_ptable(0))
- pps->nrequests = 0;
- BEGIN_WALK_BY_PWHEEL_LOOP (prs, pwheel_name)
- if (
- ((pps = prs->printer) != NULL)
- && pps->printer->daisy
- && !SAME(pps->pwheel_name, pwheel_name)
- )
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
+ PStatus[i]->nrequests = 0;
+
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if ((prs->pwheel_name != NULL) &&
+ (STREQU(prs->pwheel_name, pwheel_name)) &&
+ ((pps = prs->printer) != NULL) && pps->printer->daisy &&
+ (!SAME(pps->pwheel_name, pwheel_name)))
if (++pps->nrequests >= max)
max = pps->nrequests;
- END_WALK_LOOP
+
if (NewRequest)
if (
((pps = NewRequest->printer) != NULL)
@@ -454,7 +456,7 @@ max_requests_needing_pwheel_mounted(char *pwheel_name)
**/
int
-one_printer_with_charsets(register RSTATUS *prs)
+one_printer_with_charsets(RSTATUS *prs)
{
/*
* This little function answers the question: Is a request
diff --git a/usr/src/cmd/lp/cmd/lpsched/disp1.c b/usr/src/cmd/lp/cmd/lpsched/disp1.c
index a551b7e2ec..c70e7aa608 100644
--- a/usr/src/cmd/lp/cmd/lpsched/disp1.c
+++ b/usr/src/cmd/lp/cmd/lpsched/disp1.c
@@ -59,8 +59,7 @@ void s_alloc_files ( char * m, MESG * md ) /* funcdef */
getmessage (m, S_ALLOC_FILES, &count);
syslog(LOG_DEBUG, "s_alloc_files(%d)", count);
- if ((file_prefix = _alloc_files(count, (char *)0, md->uid, md->gid, NULL)))
- {
+ if ((file_prefix = _alloc_files(count, (char *)0, md->uid, md->gid))) {
mputm (md, R_ALLOC_FILES, MOK, file_prefix);
add_flt_act(md, FLT_FILES, file_prefix, count);
}
@@ -109,7 +108,7 @@ void s_print_request ( char * m, MESG * md )
* request list but is to be considered with the rest of the
* requests (e.g. calculating # of requests awaiting a form).
*/
- if ((rp = NewRequest = allocr()) == NULL)
+ if ((rp = NewRequest = new_rstatus(NULL, NULL)) == NULL)
status = MNOMEM;
else
@@ -124,132 +123,93 @@ void s_print_request ( char * m, MESG * md )
else
{
- *(rp->request) = *r;
rp->req_file = Strdup(req_file);
- /*
- ** Test for the presence of a secure file.
- ** If found skip sanity checks.
- ** The secure file will only exist if the request
- ** originated on a different system. Since the
- ** request has not been validated on this side yet
- ** we remove the secure file until it is.
- **
- */
- if ((s = Getsecure(req_file)))
- {
- (void) rmsecure (req_file);
- rp->request->outcome = 0;
- *(rp->secure) = *s;
- rp->secure->req_id = Strdup(s->req_id);
- rp->secure->user = Strdup(s->user);
- rp->secure->system = Strdup(s->system);
- if (md->slabel != NULL)
- rp->secure->slabel = Strdup(md->slabel);
- freesecure(s);
- /*
- ** There are some anomallies associated w/
- ** '-1', '-2', etc. files received from other systems
- ** so even though the uid and gid will be 'lp'
- ** the mode may be incorrect. 'chfiles()' will
- ** fix this for us.
- */
- (void) chfiles (rp->request->file_list, Lp_Uid, Lp_Gid);
+ freerequest(rp->request);
+ rp->request = r;
+
+ rp->request->outcome = 0;
+ rp->secure->uid = md->uid;
+ rp->secure->gid = md->gid;
+ if (md->slabel != NULL)
+ rp->secure->slabel = Strdup(md->slabel);
+
+ pw = getpwuid(md->uid);
+ endpwent();
+ if (pw && pw->pw_name && *pw->pw_name)
+ rp->secure->user = Strdup(pw->pw_name);
+ else {
+ rp->secure->user = Strdup(BIGGEST_NUMBER_S);
+ (void) sprintf (rp->secure->user, "%ld", md->uid);
}
- else
- {
- rp->request->outcome = 0;
- rp->secure->uid = md->uid;
- rp->secure->gid = md->gid;
- if (md->slabel != NULL)
- rp->secure->slabel = Strdup(md->slabel);
+
+ if ((rp->request->actions & ACT_SPECIAL) == ACT_HOLD)
+ rp->request->outcome |= RS_HELD;
+ if ((rp->request->actions & ACT_SPECIAL) == ACT_RESUME)
+ rp->request->outcome &= ~RS_HELD;
+ if((rp->request->actions & ACT_SPECIAL) == ACT_IMMEDIATE) {
+ if (!md->admin) {
+ status = MNOPERM;
+ goto Return;
+ }
+ rp->request->outcome |= RS_IMMEDIATE;
+ }
+
+ size = chfiles(rp->request->file_list, Lp_Uid, Lp_Gid);
+
+ if (size < 0) {
+ /* at this point, chfiles() may have failed because the
+ * the file may live on an NFS mounted filesystem, under
+ * a directory of mode 700. such a directory isn't
+ * accessible even by root, according to the NFS protocol
+ * (i.e. the Stat() in chfiles() failed). this most commonly
+ * happens via the automounter, and rlogin.
+ *
+ * thus we change our euid/egid to that of the user, and
+ * try again. if *this* fails, then the file must really
+ * be inaccessible.
+ */
+ org_uid = geteuid();
+ org_gid = getegid();
- pw = getpwuid(md->uid);
- endpwent();
- if (pw && pw->pw_name && *pw->pw_name)
- rp->secure->user = Strdup(pw->pw_name);
- else
- {
- rp->secure->user = Strdup(BIGGEST_NUMBER_S);
- (void) sprintf (rp->secure->user, "%ld", md->uid);
- }
-
- if ((rp->request->actions & ACT_SPECIAL) == ACT_HOLD)
- rp->request->outcome |= RS_HELD;
- if ((rp->request->actions & ACT_SPECIAL) == ACT_RESUME)
- rp->request->outcome &= ~RS_HELD;
- if((rp->request->actions & ACT_SPECIAL) == ACT_IMMEDIATE)
- {
- if (!md->admin)
- {
- status = MNOPERM;
- goto Return;
- }
- rp->request->outcome |= RS_IMMEDIATE;
- }
+ if (setegid(md->gid) != 0) {
+ status = MUNKNOWN;
+ goto Return;
+ }
- size = chfiles(rp->request->file_list, Lp_Uid, Lp_Gid);
+ if (seteuid(md->uid) != 0) {
+ setgid(org_gid);
+ status = MUNKNOWN;
+ goto Return;
+ }
- if (size < 0)
- {
+ size = chfiles(rp->request->file_list, Lp_Uid, Lp_Gid);
- /* at this point, chfiles() may have failed because the
- * the file may live on an NFS mounted filesystem, under
- * a directory of mode 700. such a directory isn't
- * accessible even by root, according to the NFS protocol
- * (i.e. the Stat() in chfiles() failed). this most commonly
- * happens via the automounter, and rlogin.
- *
- * thus we change our euid/egid to that of the user, and
- * try again. if *this* fails, then the file must really
- * be inaccessible.
- */
- org_uid = geteuid();
- org_gid = getegid();
-
- if (setegid(md->gid) != 0) {
- status = MUNKNOWN;
- goto Return;
- }
-
- if (seteuid(md->uid) != 0) {
- setgid(org_gid);
- status = MUNKNOWN;
- goto Return;
- }
-
- size = chfiles(rp->request->file_list, Lp_Uid, Lp_Gid);
-
- if (seteuid(org_uid) != 0) {
- /* should never happen */
- note("s_print_request(): ");
- note("seteuid back to uid=%d failed!!\n", org_uid);
- size = -1;
- }
-
- if (setegid(org_gid) != 0) {
- /* should never happen */
- note("s_print_request(): ");
- note("setegid back to uid=%d failed!!\n", org_uid);
- size = -1;
- }
-
- if (size < 0) {
- status = MUNKNOWN;
- goto Return;
- }
- }
- if (!(rp->request->outcome & RS_HELD) && size == 0)
- {
- status = MNOPERM;
- goto Return;
- }
- rp->secure->size = size;
+ if (seteuid(org_uid) != 0) { /* should never happen */
+ note("s_print_request(): ");
+ note("seteuid back to uid=%d failed!!\n", org_uid);
+ size = -1;
+ }
- (void) time(&rp->secure->date);
- rp->secure->req_id = NULL;
- rp->secure->system = Strdup(Local_System);
+ if (setegid(org_gid) != 0) { /* should never happen */
+ note("s_print_request(): ");
+ note("setegid back to uid=%d failed!!\n", org_uid);
+ size = -1;
+ }
+
+ if (size < 0) {
+ status = MUNKNOWN;
+ goto Return;
+ }
}
+ if (!(rp->request->outcome & RS_HELD) && size == 0) {
+ status = MNOPERM;
+ goto Return;
+ }
+ rp->secure->size = size;
+
+ (void) time(&rp->secure->date);
+ rp->secure->req_id = NULL;
if (!rp->request->title) {
if (strlen(*rp->request->file_list) < (size_t)24)
@@ -292,7 +252,7 @@ void s_print_request ( char * m, MESG * md )
*/
snprintf(tmpName, sizeof (tmpName),
"%s-%s", idno, LP_PAPIATTRNAME);
- path = makepath(SPOOLDIR, "temp", tmpName, (char *)0);
+ path = makepath(Lp_Temp, tmpName, (char *)0);
if (stat(path, &tmpBuf) == 0)
{
@@ -318,7 +278,6 @@ void s_print_request ( char * m, MESG * md )
|| putrequest(req_file, rp->request) == -1
)
status = MNOMEM;
-
else
{
status = MOK;
@@ -343,7 +302,7 @@ Return:
Free(idno);
if (status != MOK && rp) {
rmfiles(rp, 0);
- freerstatus(rp);
+ free_rstatus(rp);
}
mputm(md, R_PRINT_REQUEST, status, NB(req_id), chkprinter_result);
return;
@@ -641,7 +600,7 @@ _cancel(MESG *md, char *dest, char *user, char *req_id)
crp->reason = MOK;
creq_id = Strdup(crp->secure->req_id);
- syslog(LOG_DEBUG, "cancel reqid (%s) uid: %d, secureuid: %d\n",
+ syslog(LOG_DEBUG, "cancel reqid (%s) uid: %d, secureuid: %d",
creq_id, md->uid, crp->secure->uid);
if (cancel(crp, (md->uid != crp->secure->uid)))
@@ -716,99 +675,6 @@ void s_cancel(char *m, MESG *md)
mputm(md, R_CANCEL, MOK, MUNKNOWN, "");
}
-/**
- ** s_inquire_request()
- **/
-
-void s_inquire_request(char *m, MESG *md)
-{
- char *form;
- char *dest;
- char *pwheel;
- char *user;
- char *req_id;
- RSTATUS *rp;
- RSTATUS *found;
- char files[BUFSIZ];
-
- found = (RSTATUS *)0;
-
- (void) getmessage(m, S_INQUIRE_REQUEST,&form,&dest,&req_id,&user,&pwheel);
- syslog(LOG_DEBUG, "s_inquire_request(%s, %s, %s, %s, %s)",
- (form ? form : "NULL"), (dest ? dest : "NULL"),
- (req_id ? req_id : "NULL"), (user ? user : "NULL"),
- (pwheel ? pwheel : "NULL"));
-
- for(rp = Request_List; rp != NULL; rp = rp->next) {
- if (*form && !SAME(form, rp->request->form))
- continue;
-
- if (*dest && !STREQU(dest, rp->request->destination)) {
- if (!rp->printer)
- continue;
- if (!STREQU(dest, rp->printer->printer->name))
- continue;
- }
- if (*req_id && !STREQU(req_id, rp->secure->req_id))
- continue;
-
- if (*user && !bangequ(user, rp->secure->user))
- continue;
-
- if (*pwheel && !SAME(pwheel, rp->pwheel_name))
- continue;
-
- /*
- * For Trusted Extensions, we need to check the sensitivity label of the
- * connection and job before we return it to the client.
- */
- if ((md->admin <= 0) && (is_system_labeled()) &&
- (md->slabel != NULL) && (rp->secure->slabel != NULL) &&
- (!STREQU(md->slabel, rp->secure->slabel)))
- continue;
-
- if (found) {
- GetRequestFiles(found->request, files, sizeof(files));
- mputm(md, R_INQUIRE_REQUEST,
- MOKMORE,
- found->secure->req_id,
- found->request->user, /* bgolden 091996, bug 1257405 */
- found->secure->slabel,
- found->secure->size,
- found->secure->date,
- found->request->outcome,
- found->printer->printer->name,
- (found->form? found->form->form->name : ""),
- NB(found->pwheel_name),
- files
- );
- }
- found = rp;
- }
-
- if (found) {
- GetRequestFiles(found->request, files, sizeof(files));
- mputm(md, R_INQUIRE_REQUEST,
- MOK,
- found->secure->req_id,
- found->request->user, /* bgolden 091996, bug 1257405 */
- found->secure->slabel,
- found->secure->size,
- found->secure->date,
- found->request->outcome,
- found->printer->printer->name,
- (found->form? found->form->form->name : ""),
- (NB(found->pwheel_name)),
- files
- );
- } else
- mputm(md, R_INQUIRE_REQUEST, MNOINFO, "", "", "", 0L, 0L, 0, "", "", "",
- "");
-
- return;
-}
-
-
/*
* s_inquire_request_rank()
*/
@@ -822,10 +688,10 @@ void s_inquire_request_rank(char *m, MESG *md)
char *req_id;
RSTATUS *rp;
RSTATUS *found = NULL;
- PSTATUS *pps;
int found_rank = 0;
short prop;
char files[BUFSIZ];
+ int i;
(void) getmessage(m, S_INQUIRE_REQUEST_RANK, &prop, &form, &dest,
&req_id, &user, &pwheel);
@@ -834,8 +700,8 @@ void s_inquire_request_rank(char *m, MESG *md)
(req_id ? req_id : "NULL"), (user ? user : "NULL"),
(pwheel ? pwheel : "NULL"));
- for (pps = walk_ptable(1); pps; pps = walk_ptable(0))
- pps->nrequests = 0;
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
+ PStatus[i]->nrequests = 0;
for (rp = Request_List; rp != NULL; rp = rp->next) {
if (rp->printer && !(rp->request->outcome & RS_DONE))
@@ -883,8 +749,7 @@ void s_inquire_request_rank(char *m, MESG *md)
found->printer->printer->name,
(found->form? found->form->form->name : ""),
NB(found->pwheel_name),
- ((found->status & RSS_RANK) ?
- found->rank : found_rank),
+ found_rank,
files
);
}
@@ -905,7 +770,7 @@ void s_inquire_request_rank(char *m, MESG *md)
found->printer->printer->name,
(found->form? found->form->form->name : ""),
NB(found->pwheel_name),
- ((found->status & RSS_RANK) ? found->rank : found_rank),
+ found_rank,
files
);
} else
@@ -939,8 +804,7 @@ mv_file(RSTATUS *rp, char *dest)
for (listp = rp->request->file_list; *listp; listp++) {
cnt++;
snprintf(tmp_nam, sizeof (tmp_nam),
- "%s/%s/F%s-%d", Lp_Tmp,
- rp->secure->system, reqno, cnt);
+ "%s/F%s-%d", Lp_Temp, reqno, cnt);
unlink(tmp_nam);
}
@@ -958,7 +822,7 @@ mv_file(RSTATUS *rp, char *dest)
reqno = strdup(getreqno(securep->req_id));
(void) free(securep->req_id);
if ((securep->req_id = calloc(strlen(dest) + 1 +
- strlen(reqno) +1, sizeof (char))) == NULL)
+ strlen(reqno) +1, sizeof (char))) == NULL)
return (MNOMEM);
(void) sprintf(securep->req_id, "%s-%s", dest, reqno);
/* remove the old request file; save new one */
@@ -1027,7 +891,7 @@ void s_move_request(char *m, MESG *md)
(dest ? dest : "NULL"));
- if (!(search_ptable(dest)) && !(search_ctable(dest))) {
+ if (!(search_pstatus(dest)) && !(search_cstatus(dest))) {
mputm(md, R_MOVE_REQUEST, MNODEST, 0L);
return;
}
@@ -1071,13 +935,13 @@ void s_move_dest(char *m, MESG *md)
syslog(LOG_DEBUG, "s_move_dest(%s, %s)", (fromdest ? fromdest : "NULL"),
(dest ? dest : "NULL"));
- if (!search_ptable(fromdest) && !search_ctable(fromdest))
+ if (!search_pstatus(fromdest) && !search_cstatus(fromdest))
{
mputm(md, R_MOVE_DEST, MNODEST, fromdest, 0);
return;
}
- if (!(search_ptable(dest)) && !(search_ctable(dest)))
+ if (!(search_pstatus(dest)) && !(search_cstatus(dest)))
{
mputm(md, R_MOVE_DEST, MNODEST, dest, 0);
return;
@@ -1089,9 +953,9 @@ void s_move_dest(char *m, MESG *md)
return;
}
- BEGIN_WALK_BY_DEST_LOOP (rp, fromdest)
- if (!(rp->request->outcome &
- (RS_DONE|RS_CHANGING|RS_NOTIFYING))) {
+ for (rp = Request_List; rp != NULL; rp = rp->next) {
+ if ((STREQU(rp->request->destination, fromdest)) &&
+ (!(rp->request->outcome & (RS_DONE|RS_CHANGING|RS_NOTIFYING)))) {
if (mv_file(rp, dest) == MOK) {
num_ok++;
continue;
@@ -1102,7 +966,7 @@ void s_move_dest(char *m, MESG *md)
mputm(md, R_MOVE_DEST, MMORERR, found, 0);
found = rp->secure->req_id;
- END_WALK_LOOP
+ }
if (found)
mputm(md, R_MOVE_DEST, MERRDEST, found, num_ok);
diff --git a/usr/src/cmd/lp/cmd/lpsched/disp2.c b/usr/src/cmd/lp/cmd/lpsched/disp2.c
index 1a59653aa5..459367f2dc 100644
--- a/usr/src/cmd/lp/cmd/lpsched/disp2.c
+++ b/usr/src/cmd/lp/cmd/lpsched/disp2.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,14 +28,12 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9.1.5 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "dispatch.h"
#include <syslog.h>
#include <time.h>
-extern char *LP_ALL_NEW;
-
char *showForms(PSTATUS *);
/*
@@ -61,7 +59,6 @@ s_load_printer(char *m, MESG *md)
{
char *printer;
ushort status;
- PRINTER op;
register PRINTER *pp;
register PSTATUS *pps;
char **paperDenied;
@@ -83,18 +80,18 @@ s_load_printer(char *m, MESG *md)
status = MNODEST;
break;
}
- } else if ((pps = search_ptable(printer))) {
+ } else if ((pps = search_pstatus(printer))) {
/* Printer we know about already? */
+ PRINTER *op = pps->printer;
- op = *(pps->printer);
- *(pps->printer) = *pp;
+ pps->printer = pp;
/*
* Ensure that an old Terminfo type that's no longer
* needed gets freed, and that an existing type gets
* reloaded (in case it has been changed).
*/
- untidbit_all (op.printer_types);
+ untidbit_all (op->printer_types);
untidbit_all (pp->printer_types);
/*
@@ -104,8 +101,8 @@ s_load_printer(char *m, MESG *md)
*/
if (pps->alert->active)
if (!SAME(pp->fault_alert.shcmd,
- op.fault_alert.shcmd) ||
- pp->fault_alert.W != op.fault_alert.W) {
+ op->fault_alert.shcmd) ||
+ pp->fault_alert.W != op->fault_alert.W) {
/*
* We can't use "cancel_alert()" here
* because it will remove the message.
@@ -121,7 +118,7 @@ s_load_printer(char *m, MESG *md)
else
Unlink (pps->alert->msgfile);
}
- freeprinter (&op);
+ freeprinter (op);
unload_list (&pps->users_allowed);
unload_list (&pps->users_denied);
@@ -157,53 +154,17 @@ s_load_printer(char *m, MESG *md)
} else if (pp->remote) {
/* don't really load a remote printer */
status = MOK;
- } else if ((pps = search_ptable((char *)0))) {
- /* Room for new printer? */
+ } else if ((pps = new_pstatus(pp))) {
pps->status = PS_DISABLED | PS_REJECTED;
- pps->request = 0;
- pps->alert->active = 0;
-
- pps->forms = 0;
- pps->numForms = 0;
- pps->pwheel_name = 0;
- pps->pwheel = 0;
-
load_str (&pps->dis_reason, CUZ_NEW_PRINTER);
load_str (&pps->rej_reason, CUZ_NEW_DEST);
load_str (&pps->fault_reason, CUZ_PRINTING_OK);
time (&pps->dis_date);
time (&pps->rej_date);
- *(pps->printer) = *pp;
-
- untidbit_all (pp->printer_types);
-
- unload_list (&pps->users_allowed);
- unload_list (&pps->users_denied);
- unload_list (&pps->forms_allowed);
- unload_list (&pps->forms_denied);
- load_userprinter_access(pp->name, &pps->users_allowed,
- &pps->users_denied);
- load_formprinter_access(pp->name, &pps->forms_allowed,
- &pps->forms_denied);
-
- unload_list (&pps->paper_allowed);
- load_paperprinter_access(pp->name, &pps->paper_allowed,
- &paperDenied);
- freelist(paperDenied);
-
- load_sdn (&pps->cpi, pp->cpi);
- load_sdn (&pps->lpi, pp->lpi);
- load_sdn (&pps->plen, pp->plen);
- load_sdn (&pps->pwid, pp->pwid);
-
- pps->last_dial_rc = 0;
- pps->nretry = 0;
-
dump_pstatus ();
status = MOK;
-
} else {
freeprinter (pp);
status = MNOSPACE;
@@ -221,7 +182,7 @@ s_load_printer(char *m, MESG *md)
static void
_unload_printer(PSTATUS *pps)
{
- register CSTATUS *pcs;
+ int i;
if (pps->alert->active)
cancel_alert (A_PRINTER, pps);
@@ -239,17 +200,15 @@ _unload_printer(PSTATUS *pps)
* we have deleted the printer but still have it in the
* class, we may have trouble!
*/
- for (pcs = walk_ctable(1); pcs; pcs = walk_ctable(0))
- (void) dellist(&(pcs->class->members), pps->printer->name);
-
- untidbit_all (pps->printer->printer_types);
- freeprinter (pps->printer);
- pps->printer->name = 0; /* freeprinter() doesn't */
- if (pps->forms) {
- Free(pps->forms);
- }
- pps->forms = NULL;
- pps->numForms = 0;
+ for (i = 0; CStatus != NULL && CStatus[i] != NULL; i++)
+ (void) dellist(&(CStatus[i]->class->members),
+ pps->printer->name);
+
+ free_pstatus(pps);
+ /*
+ * this is removed from the PStatus table by the caller
+ * list_remove((void ***)&PStatus, (void *)pps);
+ */
return;
}
@@ -273,12 +232,15 @@ s_unload_printer(char *m, MESG *md)
status = MBUSY;
else {
- for (pps = walk_ptable(1); pps; pps = walk_ptable(0))
- _unload_printer (pps);
+ int i;
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
+ _unload_printer (PStatus[i]);
+ free(PStatus);
+ PStatus = NULL;
status = MOK;
}
- else if (!(pps = search_ptable(printer)))
+ else if (!(pps = search_pstatus(printer)))
/* Have we seen this printer before */
status = MNODEST;
else {
@@ -294,9 +256,10 @@ s_unload_printer(char *m, MESG *md)
else
status = MBUSY;
- if (status == MOK)
+ if (status == MOK) {
_unload_printer (pps);
-
+ list_remove((void ***)&PStatus, (void *)pps);
+ }
}
if (status == MOK)
@@ -371,21 +334,23 @@ void
s_inquire_printer_status(char *m, MESG *md)
{
char *printer;
- register PSTATUS *pps, *ppsnext;
+ register PSTATUS *pps;
(void) getmessage(m, S_INQUIRE_PRINTER_STATUS, &printer);
- syslog(LOG_DEBUG, "s_inquire_printer_status(%s)\n", printer);
+ syslog(LOG_DEBUG, "s_inquire_printer_status(%s)", printer);
if (!*printer || STREQU(printer, NAME_ALL)) {
/* inquire about all printers */
- pps = walk_ptable(1);
- while (ppsnext = walk_ptable(0)) {
- local_printer_status(md, pps, MOKMORE);
- pps = ppsnext;
+ int i;
+
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++) {
+ pps = PStatus[i];
+ if (PStatus[i + 1] != NULL)
+ local_printer_status(md, pps, MOKMORE);
}
} else
/* inquire about a specific printer */
- pps = search_ptable(printer);
+ pps = search_pstatus(printer);
if (pps)
local_printer_status(md, pps, MOK);
@@ -426,47 +391,46 @@ s_load_class(char *m, MESG *md)
break;
}
- } else if ((pcs = search_ctable(class))) {
+ } else if ((pcs = search_cstatus(class))) {
/* Class we already know about */
register RSTATUS *prs;
freeclass (pcs->class);
- *(pcs->class) = *pc;
+ pcs->class = pc;
/*
* Here we go through the list of requests
* to see who gets affected.
*/
- BEGIN_WALK_BY_DEST_LOOP (prs, class)
- /*
- * If not still eligible for this class...
- */
- switch (validate_request(prs, (char **)0, 1)) {
- case MOK:
- case MERRDEST: /* rejecting (shouldn't happen) */
- break;
- case MDENYDEST:
- case MNOMOUNT:
- case MNOMEDIA:
- case MNOFILTER:
- default:
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if (STREQU(prs->request->destination, class)) {
/*
- * ...then too bad!
- */
- cancel (prs, 1);
- break;
+ * If not still eligible for this class...
+ */
+ switch (validate_request(prs, (char **)0, 1)) {
+ case MOK:
+ case MERRDEST: /* rejecting (shouldn't happen) */
+ break;
+ case MDENYDEST:
+ case MNOMOUNT:
+ case MNOMEDIA:
+ case MNOFILTER:
+ default:
+ /*
+ * ...then too bad!
+ */
+ cancel (prs, 1);
+ break;
+ }
}
- END_WALK_LOOP
+
status = MOK;
- } else if ((pcs = search_ctable((char *)0))) {
+ } else if ((pcs = new_cstatus(pc))) {
/* Room for new class? */
pcs->status = CS_REJECTED;
-
load_str (&pcs->rej_reason, CUZ_NEW_DEST);
time (&pcs->rej_date);
- *(pcs->class) = *pc;
-
dump_cstatus ();
status = MOK;
@@ -488,7 +452,9 @@ static void
_unload_class(CSTATUS *pcs)
{
freeclass (pcs->class);
- pcs->class->name = 0; /* freeclass() doesn't */
+ if (pcs->rej_reason != NULL)
+ Free (pcs->rej_reason);
+ Free(pcs);
return;
}
@@ -498,7 +464,7 @@ s_unload_class(char *m, MESG *md)
{
char *class;
ushort status;
- RSTATUS *prs;
+ RSTATUS *prs;
register CSTATUS *pcs;
(void) getmessage(m, S_UNLOAD_CLASS, &class);
@@ -508,27 +474,32 @@ s_unload_class(char *m, MESG *md)
* Unload ALL classes?
*/
if (!*class || STREQU(class, NAME_ALL)) {
-
+ int i;
/*
* If we have a request queued for a member of ANY
* class, we can't do it.
*/
status = MOK;
- for (pcs = walk_ctable(1); pcs && status == MOK;
- pcs = walk_ctable(0))
- BEGIN_WALK_BY_DEST_LOOP (prs, pcs->class->name)
- status = MBUSY;
- break;
- END_WALK_LOOP
+ for (i = 0; ((CStatus[i] != NULL) && (status == MOK)); i++) {
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if (STREQU(prs->request->destination,
+ CStatus[i]->class->name)) {
+ status = MBUSY;
+ break;
+ }
+ }
- if (status == MOK)
- for (pcs = walk_ctable(1); pcs; pcs = walk_ctable(0))
- _unload_class (pcs);
+ if (status == MOK) {
+ for (i = 0; CStatus != NULL && CStatus[i] != NULL; i++)
+ _unload_class (CStatus[i]);
+ free(CStatus);
+ CStatus = NULL;
+ }
/*
* Have we seen this class before?
*/
- } else if (!(pcs = search_ctable(class)))
+ } else if (!(pcs = search_cstatus(class)))
status = MNODEST;
/*
@@ -537,12 +508,16 @@ s_unload_class(char *m, MESG *md)
*/
else {
status = MOK;
- BEGIN_WALK_BY_DEST_LOOP (prs, class)
- status = MBUSY;
- break;
- END_WALK_LOOP
- if (status == MOK)
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if (STREQU(prs->request->destination, class)) {
+ status = MBUSY;
+ break;
+ }
+
+ if (status == MOK) {
_unload_class (pcs);
+ list_remove((void ***)&CStatus, (void *)pcs);
+ }
}
if (status == MOK)
@@ -560,8 +535,7 @@ void
s_inquire_class(char *m, MESG *md)
{
char *class;
- register CSTATUS *pcs,
- *pcsnext;
+ register CSTATUS *pcs;
(void) getmessage(m, S_INQUIRE_CLASS, &class);
syslog(LOG_DEBUG, "s_inquire_class(%s)", (class ? class : "NULL"));
@@ -570,16 +544,18 @@ s_inquire_class(char *m, MESG *md)
if (!*class || STREQU(class, NAME_ALL)) {
/* inquire about ALL classes */
- pcs = walk_ctable(1);
- while (pcsnext = walk_ctable(0)) {
- send(md, R_INQUIRE_CLASS, MOKMORE,
- pcs->class->name, pcs->status,
- pcs->rej_reason, pcs->rej_date);
- pcs = pcsnext;
+ int i;
+
+ for (i = 0; CStatus != NULL && CStatus[i] != NULL; i++) {
+ pcs = CStatus[i];
+ if (CStatus[i + 1] != NULL)
+ send(md, R_INQUIRE_CLASS, MOKMORE,
+ pcs->class->name, pcs->status,
+ pcs->rej_reason, pcs->rej_date);
}
} else
/* inquire about a single class */
- pcs = search_ctable(class);
+ pcs = search_cstatus(class);
if (pcs)
send(md, R_INQUIRE_CLASS, MOK, pcs->class->name, pcs->status,
@@ -607,18 +583,22 @@ s_paper_allowed(char *m, MESG *md)
if (!*printer || STREQU(printer, NAME_ALL)) {
/* inquire about ALL printers */
- pps = walk_ptable(1);
- while (ppsnext = walk_ptable(0)) {
- paperList = sprintlist(pps->paper_allowed);
- send(md, R_PAPER_ALLOWED, MOKMORE, pps->printer->name,
- (paperList ? paperList : ""));
- if (paperList)
- Free(paperList);
- pps = ppsnext;
+ int i;
+
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++) {
+ pps = PStatus[i];
+ if (PStatus[i + 1] != NULL) {
+ paperList = sprintlist(pps->paper_allowed);
+ send(md, R_PAPER_ALLOWED, MOKMORE,
+ pps->printer->name,
+ (paperList ? paperList : ""));
+ if (paperList)
+ Free(paperList);
+ }
}
} else
/* inquire about a specific printer */
- pps = search_ptable(printer);
+ pps = search_pstatus(printer);
if (pps) {
paperList = sprintlist(pps->paper_allowed);
diff --git a/usr/src/cmd/lp/cmd/lpsched/disp3.c b/usr/src/cmd/lp/cmd/lpsched/disp3.c
index a49bb8289c..438f389a2d 100644
--- a/usr/src/cmd/lp/cmd/lpsched/disp3.c
+++ b/usr/src/cmd/lp/cmd/lpsched/disp3.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -37,16 +37,12 @@
** remount_form() - MOUNT A FORM WHERE ANOTHER WAS MOUNTED
**/
-extern char *LP_TRAY_UNMOUNT;
-
-
void
remount_form(register PSTATUS *pps, FSTATUS *pfs, short trayNum)
{
trayNum--; /* make zero based */
if (pps->forms && (pps->forms[trayNum].form == pfs)) {
- pps->forms[trayNum].isAvailable = ((pfs ||
- (!LP_TRAY_UNMOUNT)) ? 1 : 0);
+ pps->forms[trayNum].isAvailable = (pfs ? 1 : 0);
/* force it */
return; /* nothing to do */
} else if ((!pps->forms) && (!pfs)) {
@@ -60,7 +56,7 @@ remount_form(register PSTATUS *pps, FSTATUS *pfs, short trayNum)
register FSTATUS *Opfs = pps->forms[trayNum].form;
pps->forms[trayNum].form = 0;
- pps->forms[trayNum].isAvailable = (LP_TRAY_UNMOUNT ? 0 : 1);
+ pps->forms[trayNum].isAvailable = 0;
Opfs->mounted--;
/*
@@ -182,7 +178,7 @@ remount_pwheel(register PSTATUS *pps, char *pwheel_name)
*/
if (pwheel_name) {
load_str (&pps->pwheel_name, pwheel_name);
- if (ppws = search_pwtable(pwheel_name)) {
+ if (ppws = search_pwstatus(pwheel_name)) {
pps->pwheel = ppws;
ppws->mounted++;
@@ -252,7 +248,7 @@ s_max_trays(char *m, MESG *md)
numTrays);
/* Have we seen this printer before? */
- if (!*printer || !(pps = search_ptable(printer)))
+ if (!*printer || !(pps = search_pstatus(printer)))
status = MNODEST;
/* How about the tray? */
@@ -271,7 +267,7 @@ s_max_trays(char *m, MESG *md)
for (i = pps->numForms; i < numTrays; i++) {
ppfs[i].form = NULL;
- ppfs[i].isAvailable = (LP_TRAY_UNMOUNT ? 0 : 1);
+ ppfs[i].isAvailable = 0;
}
pps->forms = ppfs;
pps->numForms = numTrays;
@@ -308,11 +304,11 @@ s_mount(char *m, MESG *md)
status = MNOMEDIA;
/* Have we seen this printer before? */
- else if (!*printer || !(pps = search_ptable(printer)))
+ else if (!*printer || !(pps = search_pstatus(printer)))
status = MNODEST;
/* How about the form? */
- else if (*form && !(pfs = search_ftable(form)))
+ else if (*form && !(pfs = search_fstatus(form)))
status = MNOMEDIA;
/* If the printer is currently printing, we can't disturb it. */
@@ -357,11 +353,11 @@ s_mount_tray(char *m, MESG *md)
status = MNOMEDIA;
/* Have we seen this printer before? */
- else if (!*printer || !(pps = search_ptable(printer)))
+ else if (!*printer || !(pps = search_pstatus(printer)))
status = MNODEST;
/* How about the form? */
- else if (*form && !(pfs = search_ftable(form)))
+ else if (*form && !(pfs = search_fstatus(form)))
status = MNOMEDIA;
/* How about the tray? */
@@ -411,7 +407,7 @@ s_unmount(char *m, MESG *md)
/*
* Have we seen this printer before?
*/
- else if (!*printer || !(pps = search_ptable(printer)))
+ else if (!*printer || !(pps = search_pstatus(printer)))
status = MNODEST;
@@ -463,7 +459,7 @@ s_unmount_tray(char *m, MESG *md)
if (!*form && !*pwheel_name)
status = MNOMEDIA;
- else if (!*printer || !(pps = search_ptable(printer)))
+ else if (!*printer || !(pps = search_pstatus(printer)))
/* haven't seen this printer before */
status = MNODEST;
else if ((trayNum <=0) || (trayNum > pps->numForms))
@@ -516,7 +512,7 @@ s_load_form(char *m, MESG *md)
break;
}
- } else if ((pfs = search_ftable(form))) {
+ } else if ((pfs = search_fstatus(form))) {
/* Have we seen this form before? */
unload_list (&pfs->users_allowed);
unload_list (&pfs->users_denied);
@@ -556,38 +552,17 @@ s_load_form(char *m, MESG *md)
/*
* Room for a new form?
*/
- } else if ((pfs = search_ftable((char *)0))) {
-
- pfs->alert->active = 0;
- pfs->requests = pfs->requests_last = 0;
- pfs->mounted = 0;
-
+ } else if ((pfs = new_fstatus(pf))) {
/*
* No alert is possible for a new form, of course,
* but this routine does a bit more than just check
* the alert.
*/
check_form_alert (pfs, pf);
-
- unload_list (&pfs->users_allowed);
- unload_list (&pfs->users_denied);
- load_userform_access (
- pf->name,
- &pfs->users_allowed,
- &pfs->users_denied
- );
-
- load_sdn (&pfs->cpi, pf->cpi);
- load_sdn (&pfs->lpi, pf->lpi);
- load_sdn (&pfs->plen, pf->plen);
- load_sdn (&pfs->pwid, pf->pwid);
-
status = MOK;
-
} else {
free_form (pf);
status = MNOSPACE;
-
}
mputm (md, R_LOAD_FORM, status);
@@ -601,8 +576,6 @@ s_load_form(char *m, MESG *md)
static void
_unload_form(register FSTATUS *pfs)
{
- register PSTATUS *pps = &PStatus[0],
- *ppsend = &PStatus[PT_Size];
int i;
short numForms;
PFSTATUS *ppfs;
@@ -610,14 +583,13 @@ _unload_form(register FSTATUS *pfs)
/*
* Unmount this form everywhere and get rid of it.
*/
- for (; pps < ppsend; pps++)
- if (((ppfs = pps->forms) != NULL) &&
- ((numForms = pps->numForms) > 0))
- for ( i = 0 ; i < numForms ; i++ )
- if (ppfs[i].form == pfs) ppfs[i].form= NULL;
-
- free_form (pfs->form);
- pfs->form->name = 0;
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
+ if (((ppfs = PStatus[i]->forms) != NULL) &&
+ ((numForms = PStatus[i]->numForms) > 0)) {
+ int j;
+ for ( j = 0 ; j < numForms ; j++ )
+ if (ppfs[j].form == pfs) ppfs[j].form= NULL;
+ }
return;
}
@@ -634,30 +606,41 @@ s_unload_form(char *m, MESG *md)
syslog(LOG_DEBUG, "s_unload_form(%s)", (form ? form : "NULL"));
if (!*form || STREQU(form, NAME_ALL)) {
+ int i;
/* If we have a request queued for ANY form, we can't do it. */
status = MOK;
- for (pfs = walk_ftable(1); pfs && status == MOK;
- pfs = walk_ftable(0))
- BEGIN_WALK_BY_FORM_LOOP (prs, pfs)
- status = MBUSY;
- break;
- END_WALK_LOOP
+ for (i = 0; FStatus != NULL && FStatus[i] != NULL &&
+ status == MOK; i++) {
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if (prs->form == FStatus[i]) {
+ status = MBUSY;
+ break;
+ }
+ }
- if (status == MOK)
- for (pfs = walk_ftable(1); pfs; pfs = walk_ftable(0))
- _unload_form (pfs);
- } else if (!*form || !(pfs = search_ftable(form)))
+ if (status == MOK) {
+ for (i = 0; FStatus != NULL && FStatus[i] != NULL; i++)
+ _unload_form (FStatus[i]);
+ free(FStatus);
+ FStatus = NULL;
+ }
+
+ } else if (!*form || !(pfs = search_fstatus(form)))
/* Have we seen this form before? */
status = MNODEST;
else {
/* Is there even one request waiting for this form? */
status = MOK;
- BEGIN_WALK_BY_FORM_LOOP (prs, pfs)
- status = MBUSY;
- break;
- END_WALK_LOOP
- if (status == MOK)
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if (prs->form == pfs) {
+ status = MBUSY;
+ break;
+ }
+
+ if (status == MOK) {
_unload_form (pfs);
+ list_remove((void ***)&FStatus, (void *)pfs);
+ }
}
mputm (md, R_UNLOAD_FORM, status);
@@ -694,17 +677,13 @@ s_load_printwheel(char *m, MESG *md)
status = MNODEST;
break;
}
- } else if ((ppws = search_pwtable(pwheel_name))) {
+ } else if ((ppws = search_pwstatus(pwheel_name))) {
/* Print wheel we already know about? */
check_pwheel_alert (ppws, ppw);
status = MOK;
- } else if ((ppws = search_pwtable((char *)0))) {
+ } else if ((ppws = new_pwstatus(ppw))) {
/* Room for a new print wheel? */
- register RSTATUS *prs;
-
- ppws->alert->active = 0;
- ppws->requests = ppws->requests_last = 0;
- ppws->mounted = 0;
+ register RSTATUS *prs;
/*
* Because of the quirky nature of the print wheel
@@ -713,12 +692,12 @@ s_load_printwheel(char *m, MESG *md)
* and see which ones are waiting for this print wheel,
* so we can assign alerts and count pending requests.
*/
- BEGIN_WALK_BY_PWHEEL_LOOP (prs, pwheel_name)
- if (!one_printer_with_charsets(prs)) {
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if ((prs->pwheel_name == pwheel_name) &&
+ (!one_printer_with_charsets(prs))) {
prs->pwheel = ppws;
ppws->requests++;
}
- END_WALK_LOOP
check_pwheel_alert (ppws, ppw);
status = MOK;
@@ -738,9 +717,9 @@ s_load_printwheel(char *m, MESG *md)
static void
_unload_pwheel(register PWSTATUS *ppws)
{
- register PSTATUS *pps = &PStatus[0],
- *ppsend = &PStatus[PT_Size];
- register RSTATUS *prs;
+ register PSTATUS *pps;
+ register RSTATUS *prs;
+ int i;
/*
@@ -748,9 +727,9 @@ _unload_pwheel(register PWSTATUS *ppws)
* THIS IS NOT A COMPLETE UNMOUNT, JUST THE ALERT STRUCTURE
* IS REMOVED.
*/
- for (; pps < ppsend; pps++)
- if (pps->pwheel == ppws)
- pps->pwheel = 0;
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
+ if (PStatus[i]->pwheel == ppws)
+ PStatus[i]->pwheel = 0;
/*
* Remove the alert part from all requests.
@@ -773,8 +752,7 @@ _unload_pwheel(register PWSTATUS *ppws)
if (ppws->alert->active)
cancel_alert (A_PWHEEL, ppws);
- freepwheel (ppws->pwheel);
- ppws->pwheel->name = 0; /* freeprinter() doesn't */
+ free_pwstatus(ppws);
return;
}
@@ -803,18 +781,23 @@ s_unload_printwheel(char *m, MESG *md)
* Remove all print wheel alerts?
*/
if (!*pwheel_name || STREQU(pwheel_name, NAME_ALL)) {
- for (ppws = walk_pwtable(1); ppws; ppws = walk_pwtable(0))
- _unload_pwheel (ppws);
+ int i;
+
+ for (i = 0; PWStatus != NULL && PWStatus[i] != NULL; i++)
+ _unload_pwheel (PWStatus[i]);
+ free(PWStatus);
+ PWStatus = NULL;
status = MOK;
/*
* Have we seen this print wheel before?
*/
- } else if (!(ppws = search_pwtable(pwheel_name)))
+ } else if (!(ppws = search_pwstatus(pwheel_name)))
status = MNODEST;
else {
_unload_pwheel (ppws);
+ list_remove((void ***)&PWStatus, (void *)ppws);
status = MOK;
}
diff --git a/usr/src/cmd/lp/cmd/lpsched/disp4.c b/usr/src/cmd/lp/cmd/lpsched/disp4.c
index 569c222135..bb61d0cddc 100644
--- a/usr/src/cmd/lp/cmd/lpsched/disp4.c
+++ b/usr/src/cmd/lp/cmd/lpsched/disp4.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 1998 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,20 +27,13 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.13.1.8 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "time.h"
#include "dispatch.h"
#include <syslog.h>
-extern char *LP_KILL_NO_PAPER;
-
-#define PRINTER_ON_SYSTEM(PPS,PSS) \
- (((PPS)->status & PS_REMOTE) && (PPS)->system == (PSS))
-
-extern PSTATUS * search_ptable_remote(char * printer);
-
/**
** s_accept_dest()
**/
@@ -61,7 +53,7 @@ s_accept_dest(char *m, MESG *md)
/*
* Have we seen this destination as a printer?
*/
- if ((pps = search_ptable(destination)))
+ if ((pps = search_pstatus(destination)))
if ((pps->status & PS_REJECTED) == 0)
status = MERRDEST;
else {
@@ -74,7 +66,7 @@ s_accept_dest(char *m, MESG *md)
/*
* Have we seen this destination as a class?
*/
- else if ((pcs = search_ctable(destination)))
+ else if ((pcs = search_cstatus(destination)))
if ((pcs->status & CS_REJECTED) == 0)
status = MERRDEST;
else {
@@ -113,7 +105,7 @@ s_reject_dest(char *m, MESG *md)
/*
* Have we seen this destination as a printer?
*/
- if ((pps = search_ptable(destination)))
+ if ((pps = search_pstatus(destination)))
if (pps->status & PS_REJECTED)
status = MERRDEST;
else {
@@ -127,7 +119,7 @@ s_reject_dest(char *m, MESG *md)
/*
* Have we seen this destination as a class?
*/
- else if ((pcs = search_ctable(destination)))
+ else if ((pcs = search_cstatus(destination)))
if (pcs->status & CS_REJECTED)
status = MERRDEST;
else {
@@ -163,7 +155,7 @@ s_enable_dest(char *m, MESG *md)
/*
* Have we seen this printer before?
*/
- if ((pps = search_ptable(printer)))
+ if ((pps = search_pstatus(printer)))
if (enable(pps) == -1)
status = MERRDEST;
else
@@ -198,7 +190,7 @@ s_disable_dest(char *m, MESG *md)
/*
* Have we seen this printer before?
*/
- if ((pps = search_ptable(destination))) {
+ if ((pps = search_pstatus(destination))) {
/*
* If we are to cancel a currently printing request,
@@ -384,7 +376,7 @@ s_quiet_alert(char *m, MESG *md)
else switch (type) {
case QA_FORM:
- if (!(pfs = search_ftable(name)))
+ if (!(pfs = search_fstatus(name)))
status = MNODEST;
else if (!pfs->alert->active)
@@ -398,7 +390,7 @@ s_quiet_alert(char *m, MESG *md)
break;
case QA_PRINTER:
- if (!(pps = search_ptable(name)))
+ if (!(pps = search_pstatus(name)))
status = MNODEST;
else if (!pps->alert->active)
@@ -412,7 +404,7 @@ s_quiet_alert(char *m, MESG *md)
break;
case QA_PRINTWHEEL:
- if (!(ppws = search_pwtable(name)))
+ if (!(ppws = search_pwstatus(name)))
status = MNODEST;
else if (!ppws->alert->active)
@@ -447,7 +439,7 @@ s_send_fault(char *m, MESG *md)
(printerOrForm ? printerOrForm : "NULL"), key,
(alert_text ? alert_text : "NULL"));
- if (!(pps = search_ptable(printerOrForm)) || (!pps->exec) ||
+ if (!(pps = search_pstatus(printerOrForm)) || (!pps->exec) ||
pps->exec->key != key || !pps->request) {
status = MERRDEST;
} else {
@@ -475,7 +467,7 @@ s_clear_fault(char *m, MESG *md)
(alert_text ? alert_text : "NULL"));
- if (! (pps = search_ptable(printerOrForm)) || ((key > 0) &&
+ if (! (pps = search_pstatus(printerOrForm)) || ((key > 0) &&
((!pps->exec) || pps->exec->key != key || !pps->request ))) {
status = MERRDEST;
} else {
@@ -506,7 +498,7 @@ s_paper_changed(char *m, MESG *md)
(printer ? printer : "NULL"), trayNum, (paper ? paper : "NULL"),
mode, pagesPrinted);
- if (!(pps = search_ptable(printer)))
+ if (!(pps = search_pstatus(printer)))
status = MNODEST;
else if ((trayNum <=0) || (trayNum > pps->numForms))
status = MNOTRAY;
@@ -523,8 +515,7 @@ s_paper_changed(char *m, MESG *md)
}
if ( status == MOK ) {
pps->forms[trayNum].isAvailable = mode;
- if ((chgd || !mode) && (!pagesPrinted) &&
- LP_KILL_NO_PAPER && pps->exec) {
+ if ((chgd || !mode) && (!pagesPrinted) && pps->exec) {
if (pps->request)
pps->request->request->outcome |=
RS_STOPPED;
diff --git a/usr/src/cmd/lp/cmd/lpsched/disp5.c b/usr/src/cmd/lp/cmd/lpsched/disp5.c
index bacffbf9dd..bd3a3dd92c 100644
--- a/usr/src/cmd/lp/cmd/lpsched/disp5.c
+++ b/usr/src/cmd/lp/cmd/lpsched/disp5.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -45,32 +45,34 @@ void
s_child_done(char *m, MESG *md)
{
long key;
- short slot;
short status;
short err;
+ int i;
- getmessage (m, S_CHILD_DONE, &key, &slot, &status, &err);
- syslog(LOG_DEBUG, "s_child_done(%d, %d, %d, %d)", key, slot, status,
- err);
+ getmessage (m, S_CHILD_DONE, &key, &status, &err);
+ syslog(LOG_DEBUG, "s_child_done(%d, %d, %d)", key, status, err);
- if ((0 <= slot) && (slot < ET_Size) && (Exec_Table[slot].key == key) &&
- (Exec_Table[slot].md == md)) {
- /*
- * Remove the message descriptor from the listen
- * table, then forget about it; we don't want to
- * accidently match this exec-slot to a future,
- * unrelated child.
- */
- DROP_MD (Exec_Table[slot].md);
- Exec_Table[slot].md = 0;
+ for (i = 0; Exec_Table[i] != NULL; i++)
+ if ((Exec_Table[i]->key == key) && (Exec_Table[i]->md == md)) {
+ EXEC *ep = Exec_Table[i];
- Exec_Table[slot].pid = -99;
- Exec_Table[slot].status = status;
- Exec_Table[slot].Errno = err;
- DoneChildren++;
+ syslog(LOG_DEBUG,
+ "s_child_done(%d, 0x%8.8x): clearing 0x%8.8x",
+ key, md, ep);
+ /*
+ * Remove the message descriptor from the listen
+ * table, then forget about it; we don't want to
+ * accidently match this exec-slot to a future,
+ * unrelated child.
+ */
+ DROP_MD (ep->md);
- }
+ ep->pid = -99;
+ ep->status = status;
+ ep->Errno = err;
+ DoneChildren++;
+ }
return;
}
diff --git a/usr/src/cmd/lp/cmd/lpsched/dispatch.h b/usr/src/cmd/lp/cmd/lpsched/dispatch.h
index d4d6e50ce5..ddb109e100 100644
--- a/usr/src/cmd/lp/cmd/lpsched/dispatch.h
+++ b/usr/src/cmd/lp/cmd/lpsched/dispatch.h
@@ -43,8 +43,6 @@ void s_enable_dest ( char * , MESG * );
void s_end_change_request ( char * , MESG * );
void s_inquire_class ( char * , MESG * );
void s_inquire_printer_status ( char * , MESG * );
-void s_inquire_remote_printer ( char * , MESG * );
-void s_inquire_request ( char * , MESG * );
void s_inquire_request_rank ( char * , MESG * );
void s_load_class ( char * , MESG * );
void s_load_filter_table ( char * , MESG * );
diff --git a/usr/src/cmd/lp/cmd/lpsched/disptab.c b/usr/src/cmd/lp/cmd/lpsched/disptab.c
index 46366a84ec..138539393a 100644
--- a/usr/src/cmd/lp/cmd/lpsched/disptab.c
+++ b/usr/src/cmd/lp/cmd/lpsched/disptab.c
@@ -27,7 +27,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5.1.4 */
+#pragma ident "%Z%%M% %I% %E% SMI"
# include "dispatch.h"
#include <syslog.h>
@@ -49,7 +49,7 @@ static DISPATCH dispatch_table[] = {
/* R_END_CHANGE_REQUEST */ 0, D_BADMSG,
/* S_CANCEL_REQUEST */ s_cancel_request, 0,
/* R_CANCEL_REQUEST */ 0, D_BADMSG,
-/* S_INQUIRE_REQUEST */ s_inquire_request, 0,
+/* S_INQUIRE_REQUEST */ 0, D_BADMSG,
/* R_INQUIRE_REQUEST */ 0, D_BADMSG,
/* S_LOAD_PRINTER */ s_load_printer, D_ADMIN,
/* R_LOAD_PRINTER */ r_H, D_BADMSG,
@@ -308,7 +308,8 @@ dispatch(int type, char *m, MESG *md)
{
register DISPATCH *pd = &dispatch_table[type];
- syslog(LOG_DEBUG, "dispatch %s\n", dispatchName(type));
+ syslog(LOG_DEBUG, "dispatch(%s, %s, 0x%8.8x)",
+ dispatchName(type), m, md);
if (type <= 0 || type > LAST_MESSAGE || pd->fncp == NULL)
mputm (md, R_BAD_MESSAGE);
diff --git a/usr/src/cmd/lp/cmd/lpsched/dowait.c b/usr/src/cmd/lp/cmd/lpsched/dowait.c
index a6053bbdf2..aadd4d34d3 100644
--- a/usr/src/cmd/lp/cmd/lpsched/dowait.c
+++ b/usr/src/cmd/lp/cmd/lpsched/dowait.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.
@@ -19,14 +18,14 @@
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
/*
- * Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -35,6 +34,7 @@
#include "lpsched.h"
#include "ctype.h"
#include "sys/stat.h"
+#include <syslog.h>
/*
* Macro to test if we should notify the user.
@@ -64,16 +64,21 @@ dowait (void)
register PSTATUS *pps;
register ALERT *pas;
+ syslog(LOG_DEBUG, "dowait(%d)", DoneChildren);
while (DoneChildren > 0) {
DoneChildren--;
- for (i = 0; i < ET_Size; i++)
- if (Exec_Table[i].pid == -99)
+ for (i = 0; (ep = Exec_Table[i]) != NULL; i++)
+ if (ep->pid == -99)
break;
- if (i >= ET_Size)
+
+ syslog(LOG_DEBUG, "dowait(): 0x%8.8x", ep);
+
+ if (Exec_Table[i] == NULL) /* nothing to cleanup */
continue;
- ep = Exec_Table + i;
+ syslog(LOG_DEBUG, "dowait(): cleaning up 0x%8.8x", ep);
+
ep->pid = 0;
ep->key = 0; /* avoid subsequent sneaks */
if (ep->md)
@@ -82,6 +87,9 @@ dowait (void)
killed = KILLED(ep->status);
exited = EXITED(ep->status);
+ syslog(LOG_DEBUG, "dowait(): type %d, killed %d, exited %d",
+ ep->type, killed, exited);
+
switch (ep->type) {
case EX_INTERF:
@@ -556,11 +564,9 @@ check_request(RSTATUS *prs)
unqueue_form (prs);
unqueue_pwheel (prs);
putrequest (prs->req_file, prs->request);
- if (!(prs->status & RSS_SENDREMOTE) &&
- !(prs->request->outcome &
- (RS_ACTIVE | RS_NOTIFY | RS_SENDING))) {
+ if (!(prs->request->outcome & (RS_ACTIVE | RS_NOTIFY))) {
rmfiles (prs, 1);
- freerstatus (prs);
+ free_rstatus (prs);
}
}
return;
@@ -575,10 +581,10 @@ check_children(void)
{
register int i;
- for (i = 0; i < ET_Size; i++)
- if (Exec_Table[i].pid > 0)
+ for (i = 0; Exec_Table[i] != NULL; i++)
+ if (Exec_Table[i]->pid > 0)
break;
- if (i >= ET_Size)
+ if (Exec_Table[i] == NULL)
Shutdown = 2;
}
diff --git a/usr/src/cmd/lp/cmd/lpsched/exec.c b/usr/src/cmd/lp/cmd/lpsched/exec.c
index 4dd2b8a3c7..01d6e10bf1 100644
--- a/usr/src/cmd/lp/cmd/lpsched/exec.c
+++ b/usr/src/cmd/lp/cmd/lpsched/exec.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
@@ -56,7 +57,6 @@ static MESG * ChildMd;
static int ChildPid;
static int WaitedChildPid;
-static int slot;
static int do_undial;
static char argbuf[ARG_MAX];
@@ -322,10 +322,6 @@ exec(int type, ...)
case EX_INTERF:
printer = va_arg(args, PSTATUS *);
- if (printer->status & PS_REMOTE) {
- errno = EINVAL;
- return (-1);
- }
request = printer->request;
ep = printer->exec;
break;
@@ -403,7 +399,6 @@ exec(int type, ...)
ep->flags = 0;
key = ep->key = getkey();
- slot = ep - Exec_Table;
switch ((ep->pid = Fork1(ep))) {
@@ -443,10 +438,13 @@ exec(int type, ...)
(void)signal (i, SIG_DFL);
(void)signal (SIGALRM, SIG_IGN);
(void)signal (SIGTERM, sigtrap);
-
+
+ closelog();
for (i = 0; i < OpenMax; i++)
if (i != ChildMd->writefd)
Close (i);
+ openlog("lpsched", LOG_PID|LOG_NDELAY|LOG_NOWAIT, LOG_LPR);
+
setpgrp();
/* Set a default path */
@@ -559,7 +557,7 @@ exec(int type, ...)
(void)Close (1);
- if (strchr (request->secure->user, '!'))
+ if (strchr (request->request->user, '@'))
{
procuid = Lp_Uid;
procgid = Lp_Gid;
@@ -600,10 +598,7 @@ exec(int type, ...)
register char * prefix;
prefix = makestr(
- Lp_Tmp,
- "/",
- (request->secure && request->secure->system ?
- request->secure->system : Local_System),
+ Lp_Temp,
"/F",
getreqno(request->secure->req_id),
"-",
@@ -640,14 +635,13 @@ exec(int type, ...)
*/
snprintf(tmpName, sizeof (tmpName), "%s-%s",
getreqno(request->secure->req_id), LP_PAPIATTRNAME);
- path = makepath(SPOOLDIR, "temp", tmpName, (char *)0);
+ path = makepath(Lp_Temp, tmpName, (char *)0);
if ((path != NULL) && (stat(path, &tmpBuf) == 0))
{
/*
* IPP job attribute file exists for this job so
* set the environment variable
*/
- syslog(LOG_DEBUG, "exec(): ATTRPATH='%s'", path);
addenv(&envp, "ATTRPATH", path);
}
Free(path);
@@ -666,8 +660,6 @@ exec(int type, ...)
path = makepath(ETCDIR, "ppd", tmpName, (char *)0);
if ((path != NULL) && (stat(path, &tmpBuf) == 0))
{
- syslog(LOG_DEBUG,
- "exec(): Printer PPD='%s'", path);
addenv(&envp, "PPD", path);
}
Free(path);
@@ -716,13 +708,6 @@ exec(int type, ...)
addenv(&envp, "FILTER", request->fast);
/*
- */
- if (strcmp (request->secure->user, request->request->user))
- {
- addenv (&envp, "ALIAS_USERNAME",
- request->request->user);
- }
- /*
* Add the sensitivity label to the environment for
* banner page and header/footer processing
*/
@@ -765,10 +750,7 @@ exec(int type, ...)
av[ac++] = arg_string(TRUSTED, "%s/%s", Lp_A_Interfaces,
printer->printer->name);
av[ac++] = arg_string(TRUSTED, "%s", request->secure->req_id);
- av[ac++] = arg_string(UNTRUSTED, "%s%s%s",
- request->secure->user,
- (cp? "" : "@"),
- (cp? "" : request->secure->system));
+ av[ac++] = arg_string(UNTRUSTED, "%s", request->request->user);
av[ac++] = arg_string(TRUSTED, "%s", clean_title);
av[ac++] = arg_string(TRUSTED, "%d", request->copies);
@@ -886,7 +868,7 @@ exec(int type, ...)
if (request->slow)
addenv(&envp, "FILTER", request->slow);
- if (strchr (request->secure->user, '!'))
+ if (strchr (request->request->user, '@'))
{
procuid = Lp_Uid;
procgid = Lp_Gid;
@@ -899,17 +881,10 @@ exec(int type, ...)
cp = _alloc_files(
lenlist(request->request->file_list),
getreqno(request->secure->req_id),
- procuid,
- procgid,
- (request->secure && request->secure->system ?
- request->secure->system : NULL )
- );
+ procuid, procgid);
av[ac++] = arg_string(TRUSTED, "%s", Lp_Slow_Filter);
- av[ac++] = arg_string(TRUSTED, "%s/%s/%s", Lp_Tmp,
- (request->secure && request->secure->system ?
- request->secure->system : Local_System),
- cp);
+ av[ac++] = arg_string(TRUSTED, "%s/%s/%s", Lp_Temp, cp);
for (listp = request->request->file_list; *listp; listp++)
av[ac++] = arg_string(TRUSTED, "%s", *listp);
@@ -924,14 +899,13 @@ exec(int type, ...)
*/
snprintf(tmpName, sizeof (tmpName), "%s-%s",
getreqno(request->secure->req_id), LP_PAPIATTRNAME);
- path = makepath(SPOOLDIR, "temp", tmpName, (char *)0);
+ path = makepath(Lp_Temp, tmpName, (char *)0);
if ((path != NULL) && (stat(path, &tmpBuf) == 0))
{
/*
* IPP job attribute file exists for this job so
* set the environment variable
*/
- syslog(LOG_DEBUG, "exec(): ATTRPATH='%s'", path);
addenv(&envp, "ATTRPATH", path);
}
Free(path);
@@ -951,8 +925,6 @@ exec(int type, ...)
path = makepath(ETCDIR, "ppd", tmpName, (char *)0);
if ((path != NULL) && (stat(path, &tmpBuf) == 0))
{
- syslog(LOG_DEBUG,
- "exec(): Printer PPD='%s'", path);
addenv(&envp, "PPD", path);
}
Free(path);
@@ -1019,7 +991,7 @@ exec(int type, ...)
case EX_NOTIFY:
if (request->request->alert) {
- if (strchr(request->secure->user, '!')) {
+ if (strchr(request->request->user, '@')) {
procuid = Lp_Uid;
procgid = Lp_Gid;
} else {
@@ -1029,13 +1001,11 @@ exec(int type, ...)
av[ac++] = arg_string(TRUSTED, "%s",
request->request->alert);
} else {
- char *user = strdup(request->secure->user);
+ char *user = strdup(request->request->user);
clean_string(user);
slabel = request->secure->slabel;
- if ((request->request->actions & ACT_WRITE) &&
- (!request->secure->system ||
- STREQU(request->secure->system, Local_System))) {
+ if (request->request->actions & ACT_WRITE) {
av[ac++] = arg_string(TRUSTED, "%s", BINWRITE);
snprintf(argbuf, sizeof (argbuf),
"%s %s || %s %s",
@@ -1113,10 +1083,12 @@ exec(int type, ...)
* turn off signals in the last child!
*/
+#ifdef DEBUG
for (i = 0; av[i] != NULL; i++)
- syslog(LOG_DEBUG, "exec: av[%d] = %s", i, av[i]);
+ note("exec(%s): av[%d] = %s", _exec_name(type), i, av[i]);
for (i = 0; envp[i] != NULL; i++)
- syslog(LOG_DEBUG, "exec: envp[%d] = %s", i, envp[i]);
+ note("exec(%s): envp[%d] = %s", _exec_name(type), i, envp[i]);
+#endif
execvpe(av[0], av, envp);
Done (EXEC_EXIT_NEXEC, errno);
@@ -1339,7 +1311,7 @@ done(int status, int err)
if (do_undial)
undial (1);
- mputm (ChildMd, S_CHILD_DONE, key, slot, status, err);
+ mputm (ChildMd, S_CHILD_DONE, key, status, err);
mdisconnect (ChildMd);
exit (0);
diff --git a/usr/src/cmd/lp/cmd/lpsched/faults.c b/usr/src/cmd/lp/cmd/lpsched/faults.c
index 621b2c6ab0..d6ee713356 100644
--- a/usr/src/cmd/lp/cmd/lpsched/faults.c
+++ b/usr/src/cmd/lp/cmd/lpsched/faults.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.
@@ -19,15 +18,17 @@
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
/*
- * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+
#pragma ident "%Z%%M% %I% %E% SMI"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
@@ -117,11 +118,6 @@ printer_fault(register PSTATUS *pps, register RSTATUS *prs, char *alert_text,
(pps->printer->fault_alert.shcmd ?
pps->printer->fault_alert.shcmd : "??"),
pps->status, shortWhy);
- syslog(LOG_INFO, "fault (%s), type (%s), status(%x): %s",
- (pps->printer->name ? pps->printer->name : "NULL"),
- (pps->printer->fault_alert.shcmd ?
- pps->printer->fault_alert.shcmd : "NULL"),
- pps->status, (shortWhy ? shortWhy : "NULL"));
if (pps->status & PS_SHOW_FAULT)
schedule (EV_MESSAGE, pps);
diff --git a/usr/src/cmd/lp/cmd/lpsched/files.c b/usr/src/cmd/lp/cmd/lpsched/files.c
index 71459be435..c3f087a0e2 100644
--- a/usr/src/cmd/lp/cmd/lpsched/files.c
+++ b/usr/src/cmd/lp/cmd/lpsched/files.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.
@@ -21,7 +20,7 @@
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -144,11 +143,7 @@ void rmfiles ( RSTATUS * rp, int log_it ) /* funcdef */
* Copy the request file to the log file, if asked,
* or simply remove it.
*/
-#if defined(TEMP_OR_TMP)
- path = makepath(Lp_Temp, rp->req_file, (char *)0);
-#else
path = makepath(Lp_Tmp, rp->req_file, (char *)0);
-#endif
if (log_it && rp->secure && rp->secure->req_id) {
if (fd == -1)
fd = open_locked(Lp_ReqLog, "a", MODE_NOREAD);
@@ -165,7 +160,7 @@ void rmfiles ( RSTATUS * rp, int log_it ) /* funcdef */
fdprintf(fd, "x %s\n", rp->slow);
if (rp->fast)
fdprintf(fd, "y %s\n", rp->fast);
- if (rp->printer && rp->printer->printer->name)
+ if (rp->printer && rp->printer->printer)
fdprintf(fd, "z %s\n", rp->printer->printer->name);
while ((n = Read(reqfd, buf, BUFSIZ)) > 0)
write (fd, buf, n);
@@ -232,8 +227,7 @@ void rmfiles ( RSTATUS * rp, int log_it ) /* funcdef */
while(count > 0)
{
sprintf(num, "%d", count--);
- path = makestr(Lp_Tmp, "/", rp->secure->system, "/F", p, "-",
- num, (char *)0);
+ path = makestr(Lp_Temp, "/F", p, "-", num, (char *)0);
Unlink(path);
Free(path);
}
@@ -345,8 +339,7 @@ _alloc_files (
int num,
char * prefix,
uid_t uid,
- gid_t gid,
- char * host
+ gid_t gid
)
{
static char base[
@@ -381,10 +374,7 @@ _alloc_files (
plus = 1;
}
- if (host != NULL)
- file = makepath(Lp_Tmp, host, base, (char *)0);
- else
- file = makepath(Lp_Temp, base, (char *)0);
+ file = makepath(Lp_Temp, base, (char *)0);
cp = strrchr(file, '-') + 1;
while (num--) {
diff --git a/usr/src/cmd/lp/cmd/lpsched/fncs.c b/usr/src/cmd/lp/cmd/lpsched/fncs.c
index 02d6b22981..b99815b0f1 100644
--- a/usr/src/cmd/lp/cmd/lpsched/fncs.c
+++ b/usr/src/cmd/lp/cmd/lpsched/fncs.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -41,132 +41,446 @@
#include "lpsched.h"
-/**
- ** walk_ptable() - WALK PRINTER TABLE, RETURNING ACTIVE ENTRIES
- ** walk_ftable() - WALK FORMS TABLE, RETURNING ACTIVE ENTRIES
- ** walk_ctable() - WALK CLASS TABLE, RETURNING ACTIVE ENTRIES
- ** walk_pwtable() - WALK PRINT WHEEL TABLE, RETURNING ACTIVE ENTRIES
- **/
+static int __list_increment = 16;
+
+int
+list_append(void ***list, void *item)
+{
+ int count;
+ if ((list == NULL) || (item == NULL)) {
+ errno = EINVAL;
+ return (-1);
+ }
-PSTATUS *
-walk_ptable(int start)
+ if (item != NULL) {
+ if (*list == NULL)
+ *list = (void **)calloc(__list_increment,
+ sizeof (void *));
+
+ if (*list == NULL)
+ return (-1);
+
+ for (count = 0; (*list)[count] != NULL; count++);
+
+ if ((count + 1) % __list_increment == 0) { /* expand the list */ void **new_list = NULL;
+ int new_size = (((count + 1) / __list_increment) + 1) *
+ __list_increment;
+
+ new_list = (void **)calloc(new_size, sizeof (void *));
+ if (new_list == NULL)
+ return (-1);
+
+ for (count = 0; (*list)[count] != NULL; count++)
+ new_list[count] = (*list)[count];
+ free(*list);
+ *list = new_list;
+ }
+
+ (*list)[count] = item;
+ }
+
+ return (0);
+}
+
+void
+list_remove(void ***list, void *item)
{
- static PSTATUS *psend,
- *ps = 0;
+ int i, count;
+ void **tmp = NULL;
+
+ if ((list == NULL) || (*list == NULL) || (item == NULL))
+ return;
+
+ for (count = 0; (*list)[count] != NULL; count++)
+ ;
- if (start || !ps) {
- ps = PStatus;
- psend = PStatus + PT_Size;
+ if (count > 0) {
+ int new_size = (((count + 1) / __list_increment) + 1) *
+ __list_increment;
+
+ if ((tmp = (void **)calloc(new_size, sizeof (void *))) == NULL)
+ tmp = *list;
+
+ /* copy up to item */
+ for (i = 0; (((*list)[i] != NULL) && ((*list)[i] != item)); i++)
+ tmp[i] = (*list)[i];
+ /* copy after item */
+ if ((*list)[i] == item)
+ for (++i; ((*list)[i] != NULL); i++)
+ tmp[i-1] = (*list)[i];
}
- while (ps < psend && !ps->printer->name)
- ps++;
+ /* replace the list */
+ if (tmp != *list) {
+ free(*list);
+ *list = tmp;
+ }
+}
- if (ps >= psend)
- return (ps = 0);
- else
- return (ps++);
+void
+free_exec(EXEC *ep)
+{
+ if (ep != NULL) {
+ free(ep);
+ list_remove((void ***)&Exec_Table, (void *)ep);
+ }
}
-FSTATUS *
-walk_ftable(int start)
+EXEC *
+new_exec(int type, void *ex)
+{
+ EXEC *result = calloc(1, sizeof (*result));
+
+ if (result != NULL) {
+ result->type = type;
+ switch (type) {
+ case EX_ALERT:
+ case EX_INTERF:
+ case EX_FAULT_MESSAGE:
+ result->ex.printer = ex;
+ break;
+ case EX_FALERT:
+ result->ex.form = ex;
+ break;
+ case EX_PALERT:
+ result->ex.pwheel = ex;
+ break;
+ case EX_SLOWF:
+ case EX_NOTIFY:
+ break;
+ }
+ list_append((void ***)&Exec_Table, (void *)result);
+ }
+
+ return (result);
+}
+
+void
+free_alert(ALERT *ap)
{
- static FSTATUS *psend,
- *ps = 0;
+ if (ap != NULL) {
+ if (ap->msgfile != NULL)
+ free(ap->msgfile);
+ if (ap->exec != NULL)
+ free_exec(ap->exec);
+ free(ap);
+ }
+}
- if (start || !ps) {
- ps = FStatus;
- psend = FStatus + FT_Size;
+ALERT *
+new_alert(char *fmt, int i)
+{
+ ALERT *result = calloc(1, sizeof (*result));
+
+ if (result != NULL) {
+ char buf[15];
+
+ snprintf(buf, sizeof (buf), fmt, i);
+ result->msgfile = makepath(Lp_Temp, buf, (char *)0);
+ (void) Unlink(result->msgfile);
}
- while (ps < psend && !ps->form->name)
- ps++;
+ return (result);
+}
- if (ps >= psend)
- return (ps = 0);
- else
- return (ps++);
+void
+free_pstatus(PSTATUS *psp)
+{
+ if (psp != NULL) {
+ if (psp->alert != NULL)
+ free_alert(psp->alert);
+ if (psp->exec != NULL)
+ free_exec(psp->exec);
+ if (psp->fault_exec != NULL)
+ free_exec(psp->fault_exec);
+ if (psp->printer != NULL)
+ freeprinter(psp->printer);
+ if (psp->pwheel_name != NULL)
+ free(psp->pwheel_name);
+ if (psp->dis_reason != NULL)
+ free(psp->dis_reason);
+ if (psp->rej_reason != NULL)
+ free(psp->rej_reason);
+ if (psp->users_allowed != NULL)
+ unload_list(&psp->users_allowed);
+ if (psp->users_denied != NULL)
+ unload_list(&psp->users_denied);
+ if (psp->forms_allowed != NULL)
+ unload_list(&psp->forms_allowed);
+ if (psp->forms_denied != NULL)
+ unload_list(&psp->forms_denied);
+ if (psp->cpi != NULL)
+ free(psp->cpi);
+ if (psp->lpi != NULL)
+ free(psp->lpi);
+ if (psp->plen != NULL)
+ free(psp->plen);
+ if (psp->pwid != NULL)
+ free(psp->pwid);
+ if (psp->fault_reason != NULL)
+ free(psp->fault_reason);
+ if (psp->paper_allowed != NULL)
+ unload_list(&psp->paper_allowed);
+ free(psp);
+ }
+}
+
+void
+pstatus_add_printer(PSTATUS *ps, PRINTER *p)
+{
+ if ((ps != NULL) && (p != NULL)) {
+ char **paperDenied = NULL;
+
+ ps->printer = p;
+ load_userprinter_access(p->name, &(ps->users_allowed),
+ &(ps->users_denied));
+ load_formprinter_access(p->name, &(ps->forms_allowed),
+ &(ps->forms_denied));
+ load_paperprinter_access(p->name, &ps->paper_allowed,
+ &paperDenied);
+ freelist(paperDenied);
+ load_sdn(&(ps->cpi), p->cpi);
+ load_sdn(&(ps->lpi), p->lpi);
+ load_sdn(&(ps->plen), p->plen);
+ load_sdn(&(ps->pwid), p->pwid);
+ }
+}
+
+PSTATUS *
+new_pstatus(PRINTER *p)
+{
+ PSTATUS *result = calloc(1, sizeof (*result));
+
+ if (result != NULL) {
+ static int i = 0;
+ char **paperDenied = NULL;
+
+ result->alert = new_alert("A-%d", i++);
+ result->alert->exec = new_exec(EX_ALERT, result);
+ result->exec = new_exec(EX_INTERF, result);
+ result->fault_exec = new_exec(EX_FAULT_MESSAGE, result);
+
+ if (p != NULL)
+ pstatus_add_printer(result, p);
+
+ list_append((void ***)&PStatus, (void *)result);
+ }
+
+ return (result);
+}
+
+void
+free_cstatus(CSTATUS *csp)
+{
+ if (csp != NULL) {
+ if (csp->rej_reason != NULL)
+ free(csp->rej_reason);
+ if (csp->class != NULL)
+ freeclass(csp->class);
+ free(csp);
+ }
}
CSTATUS *
-walk_ctable (int start)
+new_cstatus(CLASS *c)
{
- static CSTATUS *psend,
- *ps = 0;
+ CSTATUS *result = calloc(1, sizeof (*result));
+
+ if (result != NULL) {
+ if (c != NULL)
+ result->class = c;
+ else
+ result->class = calloc(1, sizeof (CLASS));
- if (start || !ps) {
- ps = CStatus;
- psend = CStatus + CT_Size;
+ list_append((void ***)&CStatus, result);
}
- while (ps < psend && !ps->class->name)
- ps++;
+ return (result);
+}
- if (ps >= psend)
- return (ps = 0);
- else
- return (ps++);
+void
+free_fstatus(FSTATUS *fsp)
+{
+ if (fsp != NULL) {
+ if (fsp->form != NULL)
+ free_form(fsp->form);
+ if (fsp->alert != NULL)
+ free_alert(fsp->alert);
+ if (fsp->users_allowed != NULL)
+ unload_list(&fsp->users_allowed);
+ if (fsp->users_denied != NULL)
+ unload_list(&fsp->users_denied);
+ if (fsp->cpi != NULL)
+ free(fsp->cpi);
+ if (fsp->lpi != NULL)
+ free(fsp->lpi);
+ if (fsp->plen != NULL)
+ free(fsp->plen);
+ if (fsp->pwid != NULL)
+ free(fsp->pwid);
+ free(fsp);
+ }
+}
+
+FSTATUS *
+new_fstatus(_FORM *f)
+{
+ FSTATUS *result = calloc(1, sizeof (*result));
+
+ if (result != NULL) {
+ static int i = 0;
+
+ if (f != NULL)
+ result->form = f;
+ else
+ result->form = calloc(1, sizeof (_FORM));
+
+ result->alert = new_alert("F-%d", i++);
+ result->alert->exec = new_exec(EX_FALERT, result);
+ result->trigger = result->form->alert.Q;
+
+ if (f != NULL) {
+ load_userform_access(f->name, &(result->users_allowed),
+ &(result->users_denied));
+ load_sdn (&(result->cpi), f->cpi);
+ load_sdn (&(result->lpi), f->lpi);
+ load_sdn (&(result->plen), f->plen);
+ load_sdn (&(result->pwid), f->pwid);
+ }
+
+ list_append((void ***)&FStatus, (void *)result);
+ }
+
+ return (result);
+}
+
+void
+free_pwstatus(PWSTATUS *pwp)
+{
+ if (pwp != NULL) {
+ if (pwp->pwheel)
+ freepwheel(pwp->pwheel);
+ if (pwp->alert != NULL)
+ free_alert(pwp->alert);
+ free(pwp);
+ }
}
PWSTATUS *
-walk_pwtable(int start)
+new_pwstatus(PWHEEL *p)
{
- static PWSTATUS *psend,
- *ps = 0;
+ PWSTATUS *result = calloc(1, sizeof (*result));
+
+ if (result != NULL) {
+ static int i = 0;
- if (start || !ps) {
- ps = PWStatus;
- psend = PWStatus + PWT_Size;
+ if (p != NULL)
+ result->pwheel = p;
+ else
+ result->pwheel = calloc(1, sizeof (*result));
+
+ result->alert = new_alert("P-%d", i++);
+ result->alert->exec = new_exec(EX_PALERT, result);
+ result->trigger = result->pwheel->alert.Q;
+
+ list_append((void ***)&PWStatus, (void *)result);
}
- while (ps < psend && !ps->pwheel->name)
- ps++;
+ return (result);
+}
- if (ps >= psend)
- return (ps = 0);
- else
- return (ps++);
+void
+free_rstatus(RSTATUS *rsp)
+{
+ if (rsp != NULL) {
+ remover(rsp);
+
+ if (rsp->request != NULL)
+ freerequest(rsp->request);
+ if (rsp->secure != NULL)
+ freesecure(rsp->secure);
+ if (rsp->req_file)
+ Free (rsp->req_file);
+ if (rsp->slow)
+ Free (rsp->slow);
+ if (rsp->fast)
+ Free (rsp->fast);
+ if (rsp->pwheel_name)
+ Free (rsp->pwheel_name);
+ if (rsp->printer_type)
+ Free (rsp->printer_type);
+ if (rsp->output_type)
+ Free (rsp->output_type);
+ if (rsp->cpi)
+ Free (rsp->cpi);
+ if (rsp->lpi)
+ Free (rsp->lpi);
+ if (rsp->plen)
+ Free (rsp->plen);
+ if (rsp->pwid)
+ Free (rsp->pwid);
+ free(rsp);
+ }
}
+RSTATUS *
+new_rstatus(REQUEST *r, SECURE *s)
+{
+ RSTATUS *result = calloc(1, sizeof (*result));
+
+ if (result != NULL) {
+ if ((result->request = r) == NULL)
+ result->request = calloc(1, sizeof (REQUEST));
+ if ((result->secure = s) == NULL)
+ result->secure = calloc(1, sizeof (SECURE));
+ }
+
+ return (result);
+}
/**
- ** search_ptable() - SEARCH PRINTER TABLE
- ** search_ftable() - SEARCH FORMS TABLE
- ** search_ctable() - SEARCH CLASS TABLE
- ** search_pwtable() - SEARCH PRINT WHEEL TABLE
+ ** search_pstatus() - SEARCH PRINTER TABLE
+ ** search_fstatus() - SEARCH FORMS TABLE
+ ** search_cstatus() - SEARCH CLASS TABLE
+ ** search_pwstatus() - SEARCH PRINT WHEEL TABLE
**/
PSTATUS *
-search_ptable(register char *name)
+search_pstatus(register char *name)
{
- register PSTATUS *ps,
- *psend;
+ PSTATUS *ps = NULL;
- for (
- ps = & PStatus[0], psend = & PStatus[PT_Size];
- ps < psend && !SAME(ps->printer->name, name);
- ps++
- )
- ;
+ if (name != NULL) {
+ if (PStatus != NULL) {
+ int i;
- if (ps >= psend)
- ps = 0;
+ for (i = 0; ((PStatus[i] != NULL) && (ps == NULL)); i++)
+ if (SAME(PStatus[i]->printer->name, name))
+ ps = PStatus[i];
+ }
+ } else
+ ps = new_pstatus(NULL);
return (ps);
}
FSTATUS *
-search_ftable(register char *name)
+search_fstatus(register char *name)
{
- register FSTATUS *ps, *psend;
+ FSTATUS *ps = NULL;
- for (ps = & FStatus[0], psend = & FStatus[FT_Size];
- ps < psend && !SAME(ps->form->name, name); ps++);
+ if (name != NULL) {
+ if (FStatus != NULL) {
+ int i;
- if (ps >= psend)
- ps = 0;
+ for (i = 0; ((FStatus[i] != NULL) && (ps == NULL)); i++)
+ if (SAME(FStatus[i]->form->name, name))
+ ps = FStatus[i];
+ }
+ } else
+ ps = new_fstatus(NULL);
return (ps);
}
@@ -174,55 +488,54 @@ search_ftable(register char *name)
FSTATUS *
search_fptable(register char *paper)
{
- register FSTATUS *ps,*cand, *psend;
-
- cand = NULL;
- for (ps = & FStatus[0], psend = & FStatus[FT_Size]; ps < psend; ps++)
- if (SAME(ps->form->paper, paper)) {
- if (ps->form->isDefault) {
- cand = ps;
- break;
- } else if (!cand)
- cand = ps;
- }
+ FSTATUS *ps = NULL;
+ int i;
+
+ if (FStatus != NULL) {
+ for (i = 0; ((FStatus[i] != NULL) && (ps == NULL)); i++)
+ if (SAME(FStatus[i]->form->paper, paper)) {
+ if (ps->form->isDefault)
+ ps = FStatus[i];
+ }
+ }
- return (cand);
+ return (ps);
}
CSTATUS *
-search_ctable(register char *name)
+search_cstatus(register char *name)
{
- register CSTATUS *ps,
- *psend;
+ CSTATUS *ps = NULL;
- for (
- ps = & CStatus[0], psend = & CStatus[CT_Size];
- ps < psend && !SAME(ps->class->name, name);
- ps++
- )
- ;
+ if (name != NULL) {
+ if (CStatus != NULL) {
+ int i;
- if (ps >= psend)
- ps = 0;
+ for (i = 0; ((CStatus[i] != NULL) && (ps == NULL)); i++)
+ if (SAME(CStatus[i]->class->name, name))
+ ps = CStatus[i];
+ }
+ } else
+ ps = new_cstatus(NULL);
return (ps);
}
PWSTATUS *
-search_pwtable(register char *name)
+search_pwstatus(register char *name)
{
- register PWSTATUS *ps,
- *psend;
+ PWSTATUS *ps = NULL;
- for (
- ps = & PWStatus[0], psend = & PWStatus[PWT_Size];
- ps < psend && !SAME(ps->pwheel->name, name);
- ps++
- )
- ;
+ if (name != NULL) {
+ if (PWStatus != NULL) {
+ int i;
- if (ps >= psend)
- ps = 0;
+ for (i = 0; ((PWStatus[i] != NULL) && (ps == NULL)); i++)
+ if (SAME(PWStatus[i]->pwheel->name, name))
+ ps = PWStatus[i];
+ }
+ } else
+ ps = new_pwstatus(NULL);
return (ps);
}
@@ -299,7 +612,7 @@ load_sdn(char **p, SCALED sdn)
_FORM *
Getform(char *form)
{
- static _FORM _formbuf;
+ _FORM *_form;
FORM formbuf;
@@ -316,29 +629,30 @@ Getform(char *form)
if (ret == -1)
return (0);
- _formbuf.plen = formbuf.plen;
- _formbuf.pwid = formbuf.pwid;
- _formbuf.lpi = formbuf.lpi;
- _formbuf.cpi = formbuf.cpi;
- _formbuf.np = formbuf.np;
- _formbuf.chset = formbuf.chset;
- _formbuf.mandatory = formbuf.mandatory;
- _formbuf.rcolor = formbuf.rcolor;
- _formbuf.comment = formbuf.comment;
- _formbuf.conttype = formbuf.conttype;
- _formbuf.name = formbuf.name;
- _formbuf.paper = formbuf.paper;
- _formbuf.isDefault = formbuf.isDefault;
-
- if ((_formbuf.alert.shcmd = alertbuf.shcmd) != NULL) {
- _formbuf.alert.Q = alertbuf.Q;
- _formbuf.alert.W = alertbuf.W;
+ _form = calloc(1, sizeof (*_form));
+ _form->plen = formbuf.plen;
+ _form->pwid = formbuf.pwid;
+ _form->lpi = formbuf.lpi;
+ _form->cpi = formbuf.cpi;
+ _form->np = formbuf.np;
+ _form->chset = formbuf.chset;
+ _form->mandatory = formbuf.mandatory;
+ _form->rcolor = formbuf.rcolor;
+ _form->comment = formbuf.comment;
+ _form->conttype = formbuf.conttype;
+ _form->name = formbuf.name;
+ _form->paper = formbuf.paper;
+ _form->isDefault = formbuf.isDefault;
+
+ if ((_form->alert.shcmd = alertbuf.shcmd) != NULL) {
+ _form->alert.Q = alertbuf.Q;
+ _form->alert.W = alertbuf.W;
} else {
- _formbuf.alert.Q = 0;
- _formbuf.alert.W = 0;
+ _form->alert.Q = 0;
+ _form->alert.W = 0;
}
- return (&_formbuf);
+ return (_form);
}
/**
@@ -348,7 +662,6 @@ Getform(char *form)
** Getclass()
** Getpwheel()
** Getsecure()
- ** Getsystem()
** Loadfilters()
**/
@@ -516,7 +829,7 @@ Putsecure(char *file, SECURE *secbufp)
* location to both structures making the following compare
* meaningless.
* Therefore test for this condition to prevent us from
- * calling freesecure which will destroy uid, system and
+ * calling freesecure which will destroy uid and
* req_id fields in the strucure
*/
@@ -558,11 +871,6 @@ Putsecure(char *file, SECURE *secbufp)
continue;
}
- if (strcmp(pls->system, secbufp->system) != 0) {
- rmsecure(file);
- status = 9;
- continue;
- }
freesecure(pls);
}
break;
diff --git a/usr/src/cmd/lp/cmd/lpsched/init.c b/usr/src/cmd/lp/cmd/lpsched/init.c
index 2138111e91..fe318e1e81 100644
--- a/usr/src/cmd/lp/cmd/lpsched/init.c
+++ b/usr/src/cmd/lp/cmd/lpsched/init.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,48 +28,22 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.10.1.8 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "lpsched.h"
#include <syslog.h>
-CSTATUS *CStatus; /* Status of same */
-EXEC *Exec_Table; /* Running processes */
-EXEC *Exec_Slow; /* Slow filters */
-EXEC *Exec_Notify; /* Notifications */
-FSTATUS *FStatus; /* status of same */
-PSTATUS *PStatus; /* Status of same */
-PWSTATUS *PWStatus; /* Status of same */
-RSTATUS *Request_List; /* Queue of print requests */
-
-int CT_Size,
- ET_Size,
- ET_SlowSize = 1,
- ET_NotifySize = 1,
- FT_Size,
- PT_Size,
- PWT_Size;
-
-static ALERT *Alert_Table; /* Printer fault alerts */
-static ALERT *FAlert_Table; /* Form mount alerts */
-static ALERT *PAlert_Table; /* PrintWheel mount alerts */
-static CLASS *Class_Table; /* Known classes */
-static _FORM *Form_Table; /* Known forms */
-static PRINTER *Printer_Table; /* Known printers */
-static PWHEEL *PrintWheel_Table; /* Known print wheels */
-
-/*
-**
-** CLRMEM clears memory pointed to by <addr> over the range of
-** <addr>[<cnt> .. <size>]. <datum> is the size of an element of <addr>.
-**
-*/
-# define CLRMEM(addr, cnt, size, datum) \
- (void) memset((char *)(addr + cnt), 0, \
- (int)((size - cnt ) * sizeof(datum)))
-
-#define ACLUSTERSIZE 10
+CSTATUS **CStatus = NULL; /* Status of same */
+PSTATUS **PStatus = NULL; /* Status of same */
+FSTATUS **FStatus = NULL; /* status of same */
+PWSTATUS **PWStatus = NULL; /* Status of same */
+EXEC **Exec_Table = NULL; /* Running processes */
+EXEC **Exec_Slow = NULL; /* Slow filters */
+EXEC **Exec_Notify = NULL; /* Notifications */
+RSTATUS *Request_List = NULL; /* Queue of print requests */
+int ET_SlowSize = 1,
+ ET_NotifySize = 1;
static void init_printers(),
init_classes(),
@@ -78,16 +52,16 @@ static void init_printers(),
init_exec();
-static RSTATUS *init_requests();
+static void init_requests();
void
init_memory(void)
{
+ init_exec();
init_printers();
init_classes();
init_forms();
init_pwheels();
- init_exec();
/*
* Load the status after the basic structures have been loaded,
@@ -99,422 +73,119 @@ init_memory(void)
Loadfilters(Lp_A_Filters);
- Request_List = init_requests();
+ init_requests();
}
static void
init_printers()
{
PRINTER *p;
- PRINTER *pt_pointer;
- int pt_allocation;
- int at_allocation;
- int PT_Count;
- int i;
- char **paperDenied;
-
-
- PT_Size = 10;
- PT_Count = 0;
- pt_allocation = PT_Size * sizeof(PRINTER);
+ int i = 0;
- Printer_Table = (PRINTER *)Malloc(pt_allocation);
-
- CLRMEM(Printer_Table, PT_Count, PT_Size, PRINTER);
-
- pt_pointer = Printer_Table;
-
while((p = Getprinter(NAME_ALL)) != NULL || errno != ENOENT) {
- if (!p)
- continue;
-
- if (p->remote) /* this is remote, ignore it */
+ if ((!p) || (p->remote)) /* NULL or this is remote, ignore it */
continue;
- syslog(LOG_DEBUG, "Loaded printer: %s\n", p->name);
-
- *pt_pointer = *p;
- pt_pointer++;
-
- if (++PT_Count < PT_Size)
- continue;
-
- PT_Size += 10;
- pt_allocation = PT_Size * sizeof(PRINTER);
-
- Printer_Table = (PRINTER *)Realloc(Printer_Table, pt_allocation);
-
- CLRMEM(Printer_Table, PT_Count, PT_Size, PRINTER);
-
- pt_pointer = Printer_Table + PT_Count;
- }
-
- PT_Size = PT_Count + 40;
-
- pt_allocation = PT_Size * sizeof(PRINTER);
-
- Printer_Table = (PRINTER *)Realloc(Printer_Table, pt_allocation);
-
- CLRMEM(Printer_Table, PT_Count, PT_Size, PRINTER);
-
- at_allocation = PT_Size * sizeof(ALERT);
-
- Alert_Table = (ALERT *)Malloc(at_allocation);
-
- CLRMEM(Alert_Table, 0, PT_Size, ALERT);
-
- pt_allocation = PT_Size * sizeof(PSTATUS);
-
- PStatus = (PSTATUS *)Malloc(pt_allocation);
-
- CLRMEM(PStatus, 0, PT_Size, PSTATUS);
-
- for (i = 0; i < PT_Size; i++)
- {
- char buf[15];
- PSTATUS *psp;
-
- psp = PStatus + i;
- p = psp->printer = Printer_Table + i;
- psp->alert = Alert_Table + i;
- sprintf(buf, "A-%d", i);
- Alert_Table[i].msgfile = makepath(Lp_Temp, buf, (char *)0);
- (void) Unlink(Alert_Table[i].msgfile);
- if (i < PT_Count)
- {
- load_userprinter_access (
- p->name,
- &(psp->users_allowed),
- &(psp->users_denied)
- );
- load_formprinter_access (
- p->name,
- &(psp->forms_allowed),
- &(psp->forms_denied)
- );
- load_paperprinter_access (
- p->name,
- &psp->paper_allowed,
- &paperDenied
- );
- freelist(paperDenied);
- load_sdn (&(psp->cpi), p->cpi);
- load_sdn (&(psp->lpi), p->lpi);
- load_sdn (&(psp->plen), p->plen);
- load_sdn (&(psp->pwid), p->pwid);
- }
+ (void) new_pstatus(p);
+ syslog(LOG_DEBUG, "Loaded printer: %s", p->name);
}
}
static void
init_classes()
{
- CLASS *p;
- CLASS *ct_pointer;
- int ct_allocation;
- int CT_Count;
- int i;
-
-
- CT_Size = 10;
- CT_Count = 0;
- ct_allocation = CT_Size * sizeof(CLASS);
-
- Class_Table = (CLASS *)Malloc(ct_allocation);
-
- CLRMEM(Class_Table, CT_Count, CT_Size, CLASS);
-
- ct_pointer = Class_Table;
-
- while((p = Getclass(NAME_ALL)) != NULL || errno != ENOENT)
- {
- if (!p)
- continue;
-
- *ct_pointer = *p;
- ct_pointer++;
-
- if (++CT_Count < CT_Size)
- continue;
-
- CT_Size += 10;
- ct_allocation = CT_Size * sizeof(CLASS);
-
- Class_Table = (CLASS *)Realloc(Class_Table, ct_allocation);
-
- CLRMEM(Class_Table, CT_Count, CT_Size, CLASS);
-
- ct_pointer = Class_Table + CT_Count;
+ CLASS *c;
+ while((c = Getclass(NAME_ALL)) != NULL) {
+ (void) new_cstatus(c);
+ syslog(LOG_DEBUG, "Loaded class: %s", c->name);
}
-
- CT_Size = CT_Count + 40;
-
- ct_allocation = CT_Size * sizeof(CLASS);
-
- Class_Table = (CLASS *)Realloc(Class_Table, ct_allocation);
-
- CLRMEM(Class_Table, CT_Count, CT_Size, CLASS);
-
- ct_allocation = CT_Size * sizeof(CSTATUS);
-
- CStatus = (CSTATUS *)Malloc(ct_allocation);
-
- CLRMEM(CStatus, 0, CT_Size, CSTATUS);
-
- for (i = 0; i < CT_Size; i++)
- CStatus[i].class = Class_Table + i;
}
static void
init_forms()
{
- _FORM *ft_pointer,
- *f;
- int at_allocation;
- int ft_allocation;
- int FT_Count;
- int i;
-
-
- FT_Size = 10;
- FT_Count = 0;
- ft_allocation = FT_Size * sizeof(_FORM);
-
- Form_Table = (_FORM *)Malloc(ft_allocation);
-
- CLRMEM(Form_Table, FT_Count, FT_Size, _FORM);
-
- ft_pointer = Form_Table;
-
- ft_pointer->plen.val = 0.0;
- ft_pointer->plen.sc = 'i';
- ft_pointer->pwid.val = 0.0;
- ft_pointer->pwid.sc = 'i';
- ft_pointer->lpi.val = 0.0;
- ft_pointer->lpi.sc = 'i';
- ft_pointer->cpi.val = 0.0;
- ft_pointer->cpi.sc = 'i';
- ft_pointer->np = 0;
- ft_pointer->chset = NULL;
- ft_pointer->mandatory = 0;
- ft_pointer->rcolor = NULL;
- ft_pointer->comment = NULL;
- ft_pointer->conttype = NULL;
- ft_pointer->name = NULL;
- ft_pointer->alert.shcmd = NULL;
- ft_pointer->alert.Q = 0;
- ft_pointer->alert.W = 0;
- ft_pointer->paper = NULL;
- ft_pointer->isDefault = 0;
-
- ft_pointer++;
- FT_Count++;
+ _FORM *f;
+ int i = 0;
while ((f = Getform(NAME_ALL)) != NULL) {
- *(ft_pointer++) = *f;
-
- if (++FT_Count < FT_Size)
- continue;
-
- FT_Size += 10;
- ft_allocation = FT_Size * sizeof(_FORM);
-
- Form_Table = (_FORM *)Realloc(Form_Table, ft_allocation);
-
- CLRMEM(Form_Table, FT_Count, FT_Size, _FORM);
-
- ft_pointer = Form_Table + FT_Count;
+ (void) new_fstatus(f);
+ syslog(LOG_DEBUG, "Loaded form: %s", f->name);
}
-
- FT_Size = FT_Count + 40;
-
- ft_allocation = FT_Size * sizeof(_FORM);
-
- Form_Table = (_FORM *)Realloc(Form_Table, ft_allocation);
-
- CLRMEM(Form_Table, FT_Count, FT_Size, _FORM);
-
- at_allocation = FT_Size * sizeof(ALERT);
-
- FAlert_Table = (ALERT *)Malloc(at_allocation);
-
- CLRMEM(FAlert_Table, 0, FT_Size, ALERT);
-
- ft_allocation = FT_Size * sizeof(FSTATUS);
-
- FStatus = (FSTATUS *)Malloc(ft_allocation);
-
- CLRMEM(FStatus, 0, FT_Size, FSTATUS);
-
- for (i = 0; i < FT_Size; i++) {
- char buf[15];
-
- FStatus[i].form = Form_Table + i;
- FStatus[i].alert = FAlert_Table + i;
- FStatus[i].trigger = Form_Table[i].alert.Q;
- sprintf(buf, "F-%d", i);
- FAlert_Table[i].msgfile = makepath(Lp_Temp, buf, (char *)0);
- (void) Unlink(FAlert_Table[i].msgfile);
-
- if (i < FT_Count) {
- load_userform_access (
- Form_Table[i].name,
- &(FStatus[i].users_allowed),
- &(FStatus[i].users_denied)
- );
- load_sdn (&(FStatus[i].cpi), Form_Table[i].cpi);
- load_sdn (&(FStatus[i].lpi), Form_Table[i].lpi);
- load_sdn (&(FStatus[i].plen), Form_Table[i].plen);
- load_sdn (&(FStatus[i].pwid), Form_Table[i].pwid);
- }
- }
- FStatus[0].users_denied = Calloc(2,sizeof(char *));
- /* for BSD_FORM, make sure it denies no one */
}
static void
init_pwheels()
{
- PWHEEL *pwt_pointer;
PWHEEL *p;
- int at_allocation;
- int pwt_allocation;
- int PWT_Count;
- int i;
+ int i = 0;
-
- PWT_Count = 0;
- PWT_Size = 10;
- pwt_allocation = PWT_Size * sizeof(PWHEEL);
-
- PrintWheel_Table = (PWHEEL *)Malloc(pwt_allocation);
-
- CLRMEM(PrintWheel_Table, PWT_Count, PWT_Size, PWHEEL);
-
- pwt_pointer = PrintWheel_Table;
-
while((p = Getpwheel(NAME_ALL)) != NULL || errno != ENOENT)
{
- if (!p)
+ if (!p) /* NULL, ignore it. */
continue;
- *pwt_pointer = *p;
- pwt_pointer++;
-
- if (++PWT_Count < PWT_Size)
- continue;
-
- PWT_Size += 10;
- pwt_allocation = PWT_Size * sizeof(PWHEEL);
-
- PrintWheel_Table = (PWHEEL *)Realloc(PrintWheel_Table, pwt_allocation);
-
- CLRMEM(PrintWheel_Table, PWT_Count, PWT_Size, PWHEEL);
-
- pwt_pointer = &PrintWheel_Table[PWT_Count];
-
- }
-
- PWT_Size = PWT_Count + 40;
-
- pwt_allocation = PWT_Size * sizeof(PWHEEL);
-
- PrintWheel_Table = (PWHEEL *)Realloc(PrintWheel_Table, pwt_allocation);
-
- CLRMEM(PrintWheel_Table, PWT_Count, PWT_Size, PWHEEL);
-
- at_allocation = PWT_Size * sizeof(ALERT);
-
- PAlert_Table = (ALERT *)Malloc(at_allocation);
-
- CLRMEM(PAlert_Table, 0, PWT_Size, ALERT);
-
- pwt_allocation = PWT_Size * sizeof(PWSTATUS);
-
- PWStatus = (PWSTATUS *)Malloc(pwt_allocation);
-
- CLRMEM(PWStatus, 0, PWT_Size, PWSTATUS);
-
- for (i = 0; i < PWT_Size; i++)
- {
- char buf[15];
-
- PWStatus[i].pwheel = PrintWheel_Table + i;
- PWStatus[i].trigger = PrintWheel_Table[i].alert.Q;
- PWStatus[i].alert = PAlert_Table + i;
- sprintf(buf, "P-%d", i);
- PAlert_Table[i].msgfile = makepath(Lp_Temp, buf, (char *)0);
- (void) Unlink(PAlert_Table[i].msgfile);
+ (void) new_pwstatus(p);
+ syslog(LOG_DEBUG, "Loaded print-wheel: %s", p->name);
}
}
-static RSTATUS *
+static void
init_requests(void)
{
+ RSTATUS **table = NULL;
REQUEST *r;
- RSTATUS **table;
- RSTATUS *rp = NULL;
SECURE *s;
char *name;
char *sysdir;
char *sysname;
char *reqfile = NULL;
- int count;
- int i;
long addr = -1;
long sysaddr = -1;
- unsigned long size;
short vr_ret;
- size = 20;
- count = 0;
-
-
- table = (RSTATUS **)Malloc(size * sizeof(RSTATUS *));
-
while((sysname = next_dir(Lp_Requests, &addr)) != NULL) {
-
+ RSTATUS *rsp;
+
sysdir = makepath(Lp_Requests, sysname, NULL);
while((name = next_file(sysdir, &sysaddr)) != NULL) {
- table[count] = allocr();
-
reqfile = makepath(sysname, name, NULL);
Free(name);
- syslog(LOG_DEBUG, "Loaded request: %s\n", reqfile);
if ((s = Getsecure(reqfile)) == NULL) {
- table[count]->req_file = reqfile; /* fix for 1103890 */
- reqfile = NULL; /* fix for 1103890 */
- rmfiles(table[count], 0);
- freerstatus(table[count]);
+ RSTATUS tmp;
+
+ memset(&tmp, 0, sizeof (tmp));
+ tmp.req_file = reqfile; /* fix for 1103890 */
+ rmfiles(&tmp, 0);
+ free(tmp.req_file);
continue;
}
- *(table[count]->secure) = *s;
- table[count]->secure->req_id = Strdup(s->req_id);
- table[count]->secure->user = Strdup(s->user);
- table[count]->secure->system = Strdup(s->system);
- freesecure(s);
+ syslog(LOG_DEBUG, "Loaded request: %s", reqfile);
if((r = Getrequest(reqfile)) == NULL) {
- rmfiles(table[count], 0);
- freerstatus(table[count]);
- Free(reqfile);
+ RSTATUS tmp;
+
+ memset(&tmp, 0, sizeof (tmp));
+ tmp.req_file = reqfile; /* fix for 1103890 */
+ rmfiles(&tmp, 0);
+ freesecure(s);
+ free(tmp.req_file);
continue;
}
- r->outcome &= ~RS_ACTIVE; /* it can't be! */
- *(table[count]->request) = *r;
+ syslog(LOG_DEBUG, "Loaded secure: %s", s->req_id);
- table[count]->req_file = reqfile;
- reqfile = NULL;
+ rsp = new_rstatus(r, s);
+
+ r->outcome &= ~RS_ACTIVE; /* it can't be! */
+ rsp->req_file = reqfile;
if ((r->outcome & (RS_CANCELLED|RS_FAILED)) &&
- !(r->outcome & RS_NOTIFY))
- {
- rmfiles(table[count], 0);
- freerstatus(table[count]);
- continue;
+ !(r->outcome & RS_NOTIFY)) {
+ rmfiles(rsp, 0);
+ free_rstatus(rsp);
+ continue;
}
/*
@@ -530,16 +201,16 @@ init_requests(void)
* of determining what to say in the message.
*/
if (r->outcome & RS_NOTIFY) {
- char *file = makereqerr(table[count]);
+ char *file = makereqerr(rsp);
if (Access(file, F_OK) == -1) {
if (!(r->outcome & RS_CANCELLED)) {
Free(file);
- rmfiles(table[count], 0);
- freerstatus(table[count]);
+ rmfiles(rsp, 0);
+ free_rstatus(rsp);
continue;
}
- notify(table[count], NULL, 0, 0, 0);
+ notify(rsp, NULL, 0, 0, 0);
}
Free(file);
}
@@ -557,112 +228,54 @@ init_requests(void)
* is if the printer is NULL, so test for it
*/
- if ((vr_ret=validate_request(table[count], NULL, 1)) != MOK) {
- if (vr_ret == MNODEST || (table[count]->printer == NULL)) {
- rmfiles(table[count], 0);
- freerstatus(table[count]);
+ if ((vr_ret=validate_request(rsp, NULL, 1)) != MOK) {
+ if (vr_ret == MNODEST || (rsp->printer == NULL)) {
+ rmfiles(rsp, 0);
+ free_rstatus(rsp);
continue;
}
- cancel(table[count], 1);
+ cancel(rsp, 1);
}
-
- if (++count < size)
- continue;
-
- size += 20;
-
- table = (RSTATUS **)Realloc((char *)table, size * sizeof(RSTATUS *));
+ list_append((void ***)&table, (void *)rsp);
}
Free(sysdir);
Free(sysname);
sysaddr = -1;
}
-
- if (!count)
- Free ((char *)table);
- else
- if ((size = count) > 0) {
- table = (RSTATUS **)Realloc((char *)table,
- size * sizeof(RSTATUS *));
-
- qsort((void *)table, size, sizeof(RSTATUS *),
- (int (*)(const void * , const void *))rsort);
+
+ if (table != NULL) {
+ unsigned long i;
- for (i = 0; i < size - 1; i++) {
- table[i]->next = table[i + 1];
- table[i + 1]->prev = table[i];
- }
-
- table[0]->prev = 0;
- table[size - 1]->next = 0;
+ for (i = 0; table[i] != NULL; i++);
- rp = *table;
- Free(table);
+ qsort((void *)table, i, sizeof(RSTATUS *),
+ (int (*)(const void * , const void *))rsort);
+ for (i = 0; table[i] != NULL; i++) {
+ table[i]->next = table[i + 1];
+ if (table[i + 1] != NULL)
+ table[i + 1]->prev = table[i];
}
- return(rp);
+ Request_List = *table;
+ Free(table);
+ }
}
static void
init_exec()
{
- EXEC *et_pointer;
- int et_allocation;
+ EXEC *ep;
int i;
- ET_Size = ET_SlowSize
- + ET_NotifySize
- + PT_Size * 3 /* 1 each for interface, alert, fault msg */
- + PWT_Size
- + FT_Size;
-
- et_allocation = ET_Size * sizeof(EXEC);
-
- Exec_Table = (EXEC *)Malloc(et_allocation);
-
- CLRMEM(Exec_Table, 0, ET_Size, EXEC);
-
- et_pointer = Exec_Table;
-
- Exec_Slow = et_pointer;
- for (i = 0; i < ET_SlowSize; i++)
- (et_pointer++)->type = EX_SLOWF;
-
- Exec_Notify = et_pointer;
- for (i = 0; i < ET_NotifySize; i++)
- (et_pointer++)->type = EX_NOTIFY;
-
- for (i = 0; i < PT_Size; i++) {
- PStatus[i].exec = et_pointer;
- et_pointer->type = EX_INTERF;
- et_pointer->ex.printer = PStatus + i;
- et_pointer++;
-
- PStatus[i].alert->exec = et_pointer;
- et_pointer->type = EX_ALERT;
- et_pointer->ex.printer = PStatus + i;
- et_pointer++;
-
- PStatus[i].fault_exec = et_pointer;
- et_pointer->type = EX_FAULT_MESSAGE;
- et_pointer->ex.printer = PStatus + i;
- et_pointer++;
- }
-
- for (i = 0; i < PWT_Size; i++) {
- PWStatus[i].alert->exec = et_pointer;
- et_pointer->type = EX_PALERT;
- et_pointer->ex.pwheel = PWStatus + i;
- et_pointer++;
+ for (i = 0; i < ET_SlowSize; i++) {
+ ep = new_exec(EX_SLOWF, NULL);
+ list_append((void ***)&Exec_Slow, (void *)ep);
}
- for (i = 0; i < FT_Size; i++) {
- FStatus[i].alert->exec = et_pointer;
- et_pointer->type = EX_FALERT;
- et_pointer->ex.form = FStatus + i;
- et_pointer++;
+ for (i = 0; i < ET_NotifySize; i++) {
+ ep = new_exec(EX_NOTIFY, NULL);
+ list_append((void ***)&Exec_Notify, (void *)ep);
}
-
}
diff --git a/usr/src/cmd/lp/cmd/lpsched/log.c b/usr/src/cmd/lp/cmd/lpsched/log.c
index bb9a95e4bb..7c2041de70 100644
--- a/usr/src/cmd/lp/cmd/lpsched/log.c
+++ b/usr/src/cmd/lp/cmd/lpsched/log.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.
@@ -19,19 +18,21 @@
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
/*
- * Copyright (c) 2001 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
#pragma ident "%Z%%M% %I% %E% SMI"
#include "stdarg.h"
#include "lpsched.h"
+#include <syslog.h>
static void log(char *, va_list);
@@ -112,6 +113,8 @@ log(char *format, va_list ap)
static int nodate = 0;
char buf[BUFSIZ];
+ vsyslog(LOG_DEBUG, format, ap);
+
if (!am_in_background) {
fd = 1;
close_it = 0;
diff --git a/usr/src/cmd/lp/cmd/lpsched/lpfsck.c b/usr/src/cmd/lp/cmd/lpsched/lpfsck.c
index dedf589248..3175ae2d17 100644
--- a/usr/src/cmd/lp/cmd/lpsched/lpfsck.c
+++ b/usr/src/cmd/lp/cmd/lpsched/lpfsck.c
@@ -93,8 +93,6 @@ proto (D, 1, Lp_Tmp, Local_System, NULL, 0775, Lp_Uid, Lp_Gid);
* DIRECTORIES: not described in the packaging
*/
proto (D, 0, Lp_Spooldir, FIFOSDIR, NULL, 0775, Lp_Uid, Lp_Gid);
-proto (D, 1, Lp_Private_FIFOs, NULL, 0771, Lp_Uid, Lp_Gid);
-proto (D, 1, Lp_Public_FIFOs, NULL, 0773, Lp_Uid, Lp_Gid);
/*
* THE MAIN FIFO:
diff --git a/usr/src/cmd/lp/cmd/lpsched/lpsched.c b/usr/src/cmd/lp/cmd/lpsched/lpsched.c
index 2cbb82730e..f4c8d7fad4 100644
--- a/usr/src/cmd/lp/cmd/lpsched/lpsched.c
+++ b/usr/src/cmd/lp/cmd/lpsched/lpsched.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
@@ -54,10 +55,6 @@ int Reserve_Fds = 0;
char *Local_System = 0;
char *SHELL = 0;
-char *LP_TRAY_UNMOUNT = NULL;
-char *LP_KILL_NO_PAPER = NULL;
-char *LP_ALL_NEW = NULL;
-
gid_t Lp_Gid;
uid_t Lp_Uid;
@@ -105,56 +102,15 @@ main(int argc, char *argv[])
openlog(cp, LOG_PID|LOG_NDELAY|LOG_NOWAIT, LOG_LPR);
SHELL = DEFAULT_SHELL;
- LP_TRAY_UNMOUNT = getenv("LP_TRAY_UNMOUNT");
- LP_KILL_NO_PAPER = getenv("LP_KILL_NO_PAPER");
- LP_ALL_NEW = getenv("LP_ALL_NEW");
opterr = 0;
- while((c = getopt(argc, (char * const *)argv, "D:dsf:n:r:M:p:")) != EOF)
+ while((c = getopt(argc, (char * const *)argv, "dsf:n:r:M:p:")) != EOF)
switch(c)
{
# if defined (DEBUG)
case 'd':
debug = DB_ALL;
- syslog(LOG_DEBUG, "debug = DB_ALL\n");
- goto SkipD;
- case 'D':
- if (*optarg == '?') {
- note (
-"-D flag[,flag...] (all logs \"foo\" are in /var/lp/logs,\n"
-" although \"lpsched\" goes to stdout if SDB)\n"
-"\n"
-" EXEC (log all exec's in \"exec\")\n"
-" DONE (log just exec finishes in \"exec\")\n"
-" INIT (log initialization info in \"lpsched\" or stdout)\n"
-" ABORT (issue abort(2) on fatal error)\n"
-" SCHEDLOG (log additional debugging info in \"lpsched\")\n"
-" SDB (don't start lpsched as background process)\n"
-" MESSAGES (log all message traffic in \"messages\")\n"
- );
- note ("\
- ALL (all of the above; equivalent to -d)\n"
- );
- exit (0);
- }
- while ((cp = strtok(optarg, ", "))) {
-#define IFSETDB(P,S,F) if (STREQU(P, S)) debug |= F
- IFSETDB (cp, "EXEC", DB_EXEC);
- else IFSETDB (cp, "DONE", DB_DONE);
- else IFSETDB (cp, "INIT", DB_INIT);
- else IFSETDB (cp, "ABORT", DB_ABORT);
- else IFSETDB (cp, "SCHEDLOG", DB_SCHEDLOG);
- else IFSETDB (cp, "SDB", DB_SDB);
- else IFSETDB (cp, "MESSAGES", DB_MESSAGES);
- else IFSETDB (cp, "ALL", DB_ALL);
- else {
- note ("-D flag not recognized; try -D?\n");
- exit (1);
- }
- optarg = 0;
- }
- syslog(LOG_DEBUG, "-D set\n");
-SkipD:
+ syslog(LOG_DEBUG, "debug = DB_ALL");
break;
case 's':
@@ -165,25 +121,25 @@ SkipD:
case 'f':
if ((ET_SlowSize = atoi(optarg)) < 1)
ET_SlowSize = 1;
- syslog(LOG_DEBUG, "-f option is %d\n", ET_SlowSize);
+ syslog(LOG_DEBUG, "-f option is %d", ET_SlowSize);
break;
case 'n':
if ((ET_NotifySize = atoi(optarg)) < 1)
ET_NotifySize = 1;
- syslog(LOG_DEBUG, "-n option is %d\n", ET_NotifySize);
+ syslog(LOG_DEBUG, "-n option is %d", ET_NotifySize);
break;
case 'r':
if ((Reserve_Fds = atoi(optarg)) < 0)
Reserve_Fds = 0;
- syslog(LOG_DEBUG, "-r option is %d\n", Reserve_Fds);
+ syslog(LOG_DEBUG, "-r option is %d", Reserve_Fds);
break;
case 'p':
if ((fd_limit = atoi(optarg)) < 16)
fd_limit = 4096;
- syslog(LOG_DEBUG, "-p option is %d\n", fd_limit);
+ syslog(LOG_DEBUG, "-p option is %d", fd_limit);
break;
case '?':
@@ -299,8 +255,8 @@ lpshut(int immediate)
*/
if (!Shutdown) {
mputm (Net_md, S_SHUTDOWN, 1);
- for (i = 0; i < ET_Size; i++)
- terminate (&Exec_Table[i]);
+ for (i = 0; Exec_Table != NULL && Exec_Table[i] != NULL; i++)
+ terminate (Exec_Table[i]);
alarm (0);
Shutdown = (immediate? 2 : 1);
}
@@ -335,8 +291,9 @@ lpshut(int immediate)
static void
process()
{
- register FSTATUS *pfs;
- register PWSTATUS *ppws;
+ FSTATUS *pfs;
+ PWSTATUS *ppws;
+ int i;
/*
@@ -346,12 +303,12 @@ process()
* Calling them now will kick off any necessary alerts.
*/
isStartingForms = 1;
- for (pfs = walk_ftable(1); pfs; pfs = walk_ftable(0))
- check_form_alert (pfs, (_FORM *)0);
+ for (i = 0; FStatus != NULL && FStatus[i] != NULL; i++)
+ check_form_alert (FStatus[i], (_FORM *)0);
isStartingForms = 0;
- for (ppws = walk_pwtable(1); ppws; ppws = walk_pwtable(0))
- check_pwheel_alert (ppws, (PWHEEL *)0);
+ for (i = 0; PWStatus != NULL && PWStatus[i] != NULL; i++)
+ check_pwheel_alert (PWStatus[i], (PWHEEL *)0);
/*
* Clear the alarm, then schedule an EV_ALARM. This will clear
@@ -431,7 +388,6 @@ usage: lpsched [ options ]\n\
#if defined(DEBUG)
note ("\
- [ -D flag[,flag...] ] (debug modes; use -D? for usage info.)\n\
[ -d ] (same as -D ALL)\n\
[ -s ] (don't trap most signals)\n"
);
diff --git a/usr/src/cmd/lp/cmd/lpsched/lpsched.h b/usr/src/cmd/lp/cmd/lpsched/lpsched.h
index cb8571fbd9..c9a4d95b99 100644
--- a/usr/src/cmd/lp/cmd/lpsched/lpsched.h
+++ b/usr/src/cmd/lp/cmd/lpsched/lpsched.h
@@ -134,12 +134,8 @@
#define EV_LATER 4
#define EV_ALARM 5
#define EV_MESSAGE 6
-#define EV_CHECKCHILD 7
-#define EV_SYSTEM 8
-#define EV_ENABLE 9
-#define EV_POLLBSDSYSTEMS 10
-#define EV_FORM_MESSAGE 11
-#define EV_STATUS 12
+#define EV_ENABLE 7
+#define EV_FORM_MESSAGE 8
/*
* How long to wait before retrying an event:
@@ -186,16 +182,6 @@
((PRS)->slow && !((PRS)->request->outcome & RS_FILTERED))
/*
- * Where requests are handled:
- */
-
-#define PRINTING_AT(PRS,PSS) \
- ((PRS)->printer->system == (PSS))
-
-#define ORIGINATING_AT(PRS,PSS) \
- STREQU((PRS)->secure->system, (PSS)->system->name)
-
-/*
* Misc:
*/
@@ -203,8 +189,7 @@
#define makereqerr(PRS) \
makepath( \
- Lp_Tmp, \
- (PRS)->secure->system, \
+ Lp_Temp, \
getreqno((PRS)->secure->req_id), \
(char *)0 \
)
@@ -223,6 +208,7 @@
#define DROP_MD(MD) if (MD) { \
mlistendel (MD); \
mdisconnect (MD); \
+ MD = 0; \
} else /*EMPTY*/
#else
#define DROP_MD(MD) if (MD) { \
@@ -230,6 +216,7 @@
if ((MD)->writefd == (MD)->readfd) \
(MD)->writefd = -1; \
(MD)->readfd = -1; \
+ MD = 0; \
} else /*EMPTY*/
#endif
@@ -241,37 +228,19 @@ typedef int (*qchk_fnc_type)( RSTATUS * );
CLASS * Getclass ( char * );
-CSTATUS * search_ctable ( char * );
-CSTATUS * walk_ctable ( int );
-
-
-FSTATUS * search_fptable(register char *);
-FSTATUS * search_ftable ( char * );
-FSTATUS * walk_ftable ( int );
-
extern void GetRequestFiles(REQUEST *req, char *buffer, int length);
PRINTER * Getprinter ( char * );
-PSTATUS * search_ptable ( char * );
-PSTATUS * walk_ptable ( int );
-
PWHEEL * Getpwheel ( char * );
-PWSTATUS * search_pwtable ( char * );
-PWSTATUS * walk_pwtable ( int );
REQUEST * Getrequest ( char * );
-RSTATUS * allocr ( void );
RSTATUS * request_by_id ( char * );
RSTATUS * request_by_id_num ( long );
RSTATUS * request_by_jobid ( char * , char * );
-RSTATUS * walk_req_by_dest ( RSTATUS ** , char * );
-RSTATUS * walk_req_by_form ( RSTATUS ** , FSTATUS * );
-RSTATUS * walk_req_by_printer ( RSTATUS ** , PSTATUS * );
-RSTATUS * walk_req_by_pwheel ( RSTATUS ** , char * );
SECURE * Getsecure ( char * );
@@ -279,7 +248,7 @@ USER * Getuser ( char * );
_FORM * Getform ( char * );
-char * _alloc_files ( int , char * , uid_t , gid_t, char * );
+char * _alloc_files ( int , char * , uid_t , gid_t);
char * dispatchName(int);
char * statusName(int);
char * getreqno ( char * );
@@ -362,6 +331,32 @@ void update_req ( char * , long );
int isFormMountedOnPrinter ( PSTATUS *, FSTATUS * );
int isFormUsableOnPrinter ( PSTATUS *, FSTATUS * );
char *allTraysWithForm ( PSTATUS *, FSTATUS * );
+extern int list_append(void ***, void *);
+extern void list_remove(void ***, void *);
+
+extern RSTATUS *new_rstatus(REQUEST *, SECURE *);
+extern PSTATUS *new_pstatus(PRINTER *);
+extern CSTATUS *new_cstatus(CLASS *);
+extern FSTATUS *new_fstatus(_FORM *f);
+extern PWSTATUS *new_pwstatus(PWHEEL *p);
+extern ALERT *new_alert(char *fmt, int i);
+extern EXEC *new_exec(int type, void *ex);
+
+extern void pstatus_add_printer(PSTATUS *, PRINTER *);
+
+extern void free_exec(EXEC *);
+extern void free_alert(ALERT *);
+extern void free_pwstatus(PWSTATUS *);
+extern void free_fstatus(FSTATUS *);
+extern void free_cstatus(CSTATUS *);
+extern void free_pstatus(PSTATUS *);
+extern void free_rstatus(RSTATUS *);
+
+extern CSTATUS *search_cstatus ( char * );
+extern FSTATUS *search_fptable(register char *);
+extern FSTATUS *search_fstatus ( char * );
+extern PSTATUS *search_pstatus ( char * );
+extern PWSTATUS *search_pwstatus ( char * );
/*
* Things that can't be passed as parameters:
@@ -375,42 +370,24 @@ extern char *pwheel_in_question;
** External tables, lists:
**/
-extern CSTATUS *CStatus; /* Status of classes */
-
-extern EXEC *Exec_Table; /* Running processes */
+extern CSTATUS **CStatus; /* Status of classes */
+extern PSTATUS **PStatus; /* Status of printers */
+extern FSTATUS **FStatus; /* Status of forms */
+extern PWSTATUS **PWStatus; /* Status of print wheels */
-extern FSTATUS *FStatus; /* Status of forms */
-
-extern PSTATUS *PStatus; /* Status of printers */
-
-extern PWSTATUS *PWStatus; /* Status of print wheels */
+extern EXEC **Exec_Table; /* Running processes */
+extern EXEC **Exec_Slow, /* First slow filter exec */
+ **Exec_Notify; /* First notification exec */
extern RSTATUS *Request_List; /* Queue of print requests */
-extern RSTATUS *Status_List; /* Queue of fake requests */
extern RSTATUS *NewRequest; /* Not in Request_List yet */
-extern EXEC *Exec_Slow, /* First slow filter exec */
- *Exec_Notify; /* First notification exec */
-
-extern int CT_Size, /* Size of class table */
- ET_Size, /* Size of exec table */
- ET_SlowSize, /* Number of filter execs */
- ET_NotifySize, /* Number of notify execs */
- FT_Size, /* Size of form table */
- PT_Size, /* Size of printer table */
- PWT_Size, /* Size of print wheel table */
- ST_Size, /* Size of system status table */
- ST_Count; /* No. active entries in above */
+extern int ET_SlowSize, /* Number of filter execs */
+ ET_NotifySize; /* Number of notify execs */
#if defined(DEBUG)
-#define DB_EXEC 0x00000001
-#define DB_DONE 0x00000002
-#define DB_INIT 0x00000004
#define DB_ABORT 0x00000008
-#define DB_SCHEDLOG 0x00000010
#define DB_SDB 0x00000020
-#define DB_MESSAGES 0x00000040
-#define DB_MALLOC 0x00000080
#define DB_ALL 0xFFFFFFFF
extern unsigned long debug;
diff --git a/usr/src/cmd/lp/cmd/lpsched/msgs.c b/usr/src/cmd/lp/cmd/lpsched/msgs.c
index ea467731f5..a9e51c6224 100644
--- a/usr/src/cmd/lp/cmd/lpsched/msgs.c
+++ b/usr/src/cmd/lp/cmd/lpsched/msgs.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,7 +28,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9.1.5 */
+#pragma ident "%Z%%M% %I% %E% SMI"
# include <stdarg.h>
# include <limits.h>
@@ -64,7 +64,7 @@ MESG *Net_md;
void take_message(void)
{
int bytes;
- int slot;
+ int i;
MESG * md;
for (EVER) { /* not really forever...returns are in the loop */
@@ -100,13 +100,13 @@ void take_message(void)
* notification, etc. Otherwise, it must be
* a network child.
*/
- for (slot = 0; slot < ET_Size; slot++)
- if (Exec_Table[slot].md == md)
+ for (i = 0; Exec_Table[i] != NULL; i++)
+ if (Exec_Table[i]->md == md)
break;
- if (slot < ET_Size) {
+ if (Exec_Table[i] != NULL) {
(void) putmessage(Message, S_CHILD_DONE,
- Exec_Table[slot].key, slot, 0, 0);
+ Exec_Table[i]->key, 0, 0);
} else {
(void) putmessage(Message, S_SHUTDOWN, 1);
}
@@ -155,19 +155,6 @@ do_msg(MESG *md)
{
int type = mtype(Message);
-#if defined(DEBUG)
- if (debug & DB_MESSAGES) {
- int size = stoh(Message + MESG_SIZE);
- int ntype = stoh(Message + MESG_TYPE);
-
- syslog(LOG_DEBUG, "RECV: type %d size %d: %-.*s\n", ntype, size,
- size, Message);
- }
-# endif
-
-#if defined(DEBUG)
- syslog(LOG_DEBUG,"MESSAGE ACCEPTED: client %#0x", md);
-#endif
if (type != S_GOODBYE) {
md->wait = 0;
dispatch (type, Message, md);
@@ -235,21 +222,8 @@ init_messages(void)
calculate_nopen ();
- if (cmd = makestr(RMCMD, " ", Lp_Public_FIFOs, "/*", (char *)0))
- {
- (void) system(cmd);
- Free(cmd);
- }
- if (cmd = makestr(RMCMD, " ", Lp_Private_FIFOs, "/*", (char *)0))
- {
- (void) system(cmd);
- Free(cmd);
- }
-
Message = (char *)Malloc(MSGMAX);
- (void) Chmod(Lp_Public_FIFOs, 0773);
- (void) Chmod(Lp_Private_FIFOs, 0771);
(void) Chmod(Lp_Tmp, 0711);
if ((md = mcreate(Lp_FIFO)) == NULL)
@@ -272,7 +246,6 @@ shutdown_messages(void)
{
MESG *md;
- (void) Chmod(Lp_Public_FIFOs, 0770);
(void) Chmod(Lp_Tmp, 0700);
(void) Chmod(Lp_FIFO, 0600);
md = mlistenreset();
diff --git a/usr/src/cmd/lp/cmd/lpsched/nodes.h b/usr/src/cmd/lp/cmd/lpsched/nodes.h
index 906321466d..3ace135c23 100644
--- a/usr/src/cmd/lp/cmd/lpsched/nodes.h
+++ b/usr/src/cmd/lp/cmd/lpsched/nodes.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,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -39,8 +38,6 @@ typedef struct pfstat_node PFSTATUS;
typedef struct pstat_node PSTATUS;
typedef struct pwstat_node PWSTATUS;
typedef struct rstat_node RSTATUS;
-typedef struct waiting_node WAITING;
-typedef struct susp_node SUSPENDED;
struct alert_node
{
@@ -75,19 +72,6 @@ struct exec_node
} ex;
};
-struct waiting_node
-{
- WAITING *next;
- MESG *md;
-};
-
-struct susp_node
-{
- SUSPENDED *next;
- char *message;
- MESG *md;
-};
-
#define EX_INTERF 1 /* exec interface for ex.printer */
#define EX_SLOWF 2 /* exec slow filter for ex.request */
#define EX_ALERT 3 /* exec alert for ex.printer */
@@ -97,18 +81,9 @@ struct susp_node
#define EX_FAULT_MESSAGE 7 /* exec fault message*/
#define EX_FORM_MESSAGE 8 /* form fault message*/
-#define REX_INTERF 1 /* send print request to remote */
-#define REX_CANCEL 2 /* send cancellation to remote */
-#define REX_NOTIFY 3 /* send job termination note to remote */
-#define REX_STATUS 4 /* send status request to remote */
-#define REX_FAULT_MESSAGE 5 /* fault message to remote */
-#define REX_FORM_MESSAGE 6 /* form message to remote */
-
#define EXF_RESTART 0x0001 /* restart the exec */
#define EXF_KILLED 0x0002 /* terminate() has killed the exec */
#define EXF_GONE 0x0004 /* child has disappeared */
-#define EXF_WAITCHILD 0x0008 /* waiting for R_NEW_CHILD */
-#define EXF_WAITJOB 0x0010 /* waiting for R_SEND_JOB */
/*
** Possible values for FLT.type
@@ -162,7 +137,6 @@ struct pstat_node
time_t rej_date;
short last_dial_rc; /* last exit from dial() */
short nretry; /* number of dial attempts */
- char *remote_name;
short nrequests; /* TEMP ONLY! (used variously) */
char *fault_reason;
EXEC *fault_exec;
@@ -180,45 +154,11 @@ struct pwstat_node
short mounted;
};
-#if defined(OLD_MSG_STUFF)
-
-#define CLIENT_NEW 1
-#define CLIENT_PROTOCOL 2
-#define CLIENT_TALKING 3
-
-struct mque_node
-{
- char *msgbuf;
- unsigned int size;
- struct mque_node *next;
-};
-
-struct client_node
-{
- ushort uid; /* User id of client */
- ushort gid; /* Group id of client */
- char admin; /* Non-zero if client is admin */
- char state; /* (CLIENT_... value) */
- FLT *flt; /* Linked list of fault actions */
- char *fifo; /* Name of client's fifo */
- char *system; /* Name of client's system */
- int fd; /* File-descriptor of open fifo */
- char authcode[HEAD_AUTHCODE_LEN];
- /* ``Password'' to verify client*/
- MQUE *mque; /* Linked list of pending msgs. */
-};
-
-#else
-
-#define NODE MESG
#define send mputm
-#endif
-
struct rstat_node
{
long status;
- long rank;
MESG *md;
char *req_file;
@@ -249,12 +189,7 @@ struct rstat_node
char *formName; /* for mounting forms remotely */
};
-# define RSS_MARK 0x00000001
-# define RSS_RANK 0x00000002
-# define RSS_SENDREMOTE 0x00000004 /* request needs to be sent */
# define RSS_PWMAND 0x00000008 /* pwheel must be mounted */
-# define RSS_GETSTATUS 0x00000010 /* get remote status */
-# define RSS_RECVSTATUS 0x00000020 /* waiting for remote status */
# define RSS_SEND_FAULT_MESSAGE 0x00000040 /* need to send message*/
# define RSS_SEND_FORM_MESSAGE 0x00000080 /* need to send form message*/
@@ -275,52 +210,3 @@ struct form_node
char *paper;
short isDefault;
};
-
-# define LP_EXEC 0
-# define LP_SCHED 1
-# define LP_NET 2
-# define LP_FILTER 3
-# define LP_PRINTER 4
-# define LP_ALERT 5
-# define LP_NOTIFY 6
-# define LP_SYSTEM 7
-# define LP_PWHEEL 8
-# define LP_FORM 9
-# define LP_LATER 10
-# define LP_ALARM 11
-
-# define LP_ACTIVE 0x080
-# define LP_ALERTING 0x100
-
-# define MINUTES (60)
-
-# define USER_STATUS_EXPIRED (3 * MINUTES)
-
-# define SYSTEM_STATUS_EXPIRED (10 * MINUTES)
-
-#define BEGIN_WALK_LOOP(PRS, CONDITION) \
- _BEGIN_WALK_LOOP("WALK", PRS, CONDITION)
-
-#define _BEGIN_WALK_LOOP(X, PRS, CONDITION) \
- { \
- register RSTATUS *pnext = 0; \
- for (PRS = Request_List; PRS; PRS = pnext) { \
- pnext = PRS->next; \
- if (CONDITION) {
-
-#define END_WALK_LOOP \
- } \
- } \
- }
-
-#define BEGIN_WALK_BY_PRINTER_LOOP(PRS, PPS) \
- _BEGIN_WALK_LOOP("WALK_BY_PRINTER", PRS, PRS->printer == PPS)
-
-#define BEGIN_WALK_BY_DEST_LOOP(PRS, DEST) \
- _BEGIN_WALK_LOOP("WALK_BY_DEST", PRS, STREQU(PRS->request->destination, DEST))
-
-#define BEGIN_WALK_BY_FORM_LOOP(PRS, PFS) \
- _BEGIN_WALK_LOOP("WALK_BY_FORM", PRS, PRS->form == PFS)
-
-#define BEGIN_WALK_BY_PWHEEL_LOOP(PRS, NAME) \
- _BEGIN_WALK_LOOP("WALK_BY_PWHEEL", PRS, PRS->pwheel_name && STREQU(PRS->pwheel_name, NAME))
diff --git a/usr/src/cmd/lp/cmd/lpsched/notify.c b/usr/src/cmd/lp/cmd/lpsched/notify.c
index 6dd329b1e1..bd5987718b 100644
--- a/usr/src/cmd/lp/cmd/lpsched/notify.c
+++ b/usr/src/cmd/lp/cmd/lpsched/notify.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 1997 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,7 +27,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2.1.3 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "lpsched.h"
@@ -130,8 +129,8 @@ notify(register RSTATUS *prs, char *errbuf, int k, int e, int slow)
GetRequestFiles(prs->request, file, sizeof(file));
fdprintf(fd, "\nThe job title was:\t%s\n", file);
- fdprintf(fd, " submitted from:\t%s\n",
- prs->secure->system);
+ fdprintf(fd, " submitted by:\t%s\n",
+ prs->request->user);
fdprintf(fd, " at:\t%s\n",
ctime(&prs->secure->date));
}
diff --git a/usr/src/cmd/lp/cmd/lpsched/print-svc b/usr/src/cmd/lp/cmd/lpsched/print-svc
index e2941b1e0d..9cd6a07c17 100644
--- a/usr/src/cmd/lp/cmd/lpsched/print-svc
+++ b/usr/src/cmd/lp/cmd/lpsched/print-svc
@@ -30,7 +30,7 @@
. /lib/svc/share/smf_include.sh
# SERVICE = parent service name
-SERVICE=`echo $SMF_FMRI | /usr/sbin/cut -f1,2 -d":"`
+SERVICE=`echo $SMF_FMRI | /usr/bin/cut -f1,2 -d":"`
case "$1" in
'start')
diff --git a/usr/src/cmd/lp/cmd/lpsched/requeue.c b/usr/src/cmd/lp/cmd/lpsched/requeue.c
index 871d9a057a..47798de6b3 100644
--- a/usr/src/cmd/lp/cmd/lpsched/requeue.c
+++ b/usr/src/cmd/lp/cmd/lpsched/requeue.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.
@@ -19,11 +18,17 @@
*
* CDDL HEADER END
*/
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
-#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6.1.4 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "lpsched.h"
@@ -80,7 +85,7 @@ queue_attract(PSTATUS *pps, int (*qchk_p)(RSTATUS *), int attract_just_one)
#define SAMECLASS(PRS,PPS) \
( \
- ((pcs = search_ctable(PRS->request->destination)) != NULL) \
+ ((pcs = search_cstatus(PRS->request->destination)) != NULL) \
&& searchlist(PPS->printer->name, pcs->class->members) \
)
@@ -137,7 +142,6 @@ queue_repel(PSTATUS *pps, int move_off, int (*qchk_p)(RSTATUS *))
register int all_can = 1;
register PSTATUS *stop_pps = (move_off? pps : 0);
-
/*
* Reevaluate all requests that are assigned to this
* printer, to see if there's another printer that
@@ -149,7 +153,9 @@ queue_repel(PSTATUS *pps, int move_off, int (*qchk_p)(RSTATUS *))
* (Currently this is only used when deciding if a printer
* can be deleted.)
*/
- BEGIN_WALK_BY_PRINTER_LOOP (prs, pps)
+ for (prs = Request_List; prs != NULL; prs = prs->next) {
+ if (prs->printer != pps)
+ continue;
/*
* "all_can" keeps track of whether all of the requests
@@ -191,7 +197,7 @@ queue_repel(PSTATUS *pps, int move_off, int (*qchk_p)(RSTATUS *))
else
prs->reason = MOK;
}
- END_WALK_LOOP
+ }
return (all_can);
}
diff --git a/usr/src/cmd/lp/cmd/lpsched/rstatus.c b/usr/src/cmd/lp/cmd/lpsched/rstatus.c
index 8b09aa4f4a..791ba432a0 100644
--- a/usr/src/cmd/lp/cmd/lpsched/rstatus.c
+++ b/usr/src/cmd/lp/cmd/lpsched/rstatus.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,88 +28,12 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7.1.4 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "lpsched.h"
/**
- ** freerstatus()
- **/
-
-void
-freerstatus(register RSTATUS *r)
-{
- if (r->exec) {
- if (r->exec->pid > 0)
- terminate (r->exec);
- r->exec->ex.request = 0;
- }
-
- remover (r);
-
- if (r->req_file)
- Free (r->req_file);
- if (r->slow)
- Free (r->slow);
- if (r->fast)
- Free (r->fast);
- if (r->pwheel_name)
- Free (r->pwheel_name);
- if (r->printer_type)
- Free (r->printer_type);
- if (r->output_type)
- Free (r->output_type);
- if (r->cpi)
- Free (r->cpi);
- if (r->lpi)
- Free (r->lpi);
- if (r->plen)
- Free (r->plen);
- if (r->pwid)
- Free (r->pwid);
-
- if (r->secure) {
- freesecure(r->secure);
- Free(r->secure);
- }
-
- if (r->request) {
- freerequest (r->request);
- Free(r->request);
- }
- Free(r);
-
- return;
-}
-
-/**
- ** allocr()
- **/
-
-RSTATUS *
-allocr(void)
-{
- register RSTATUS *prs;
- register REQUEST *req;
- register SECURE *sec;
-
- prs = (RSTATUS *)Malloc(sizeof(RSTATUS));
- req = (REQUEST *)Malloc(sizeof(REQUEST));
- sec = (SECURE *)Malloc(sizeof(SECURE));
-
- if (prs == NULL || req == NULL || sec == NULL) {
- fail("allocr: Malloc failed");
- }
-
- memset ((char *)prs, 0, sizeof(RSTATUS));
- memset ((char *)(prs->request = req), 0, sizeof(REQUEST));
- memset ((char *)(prs->secure = sec), 0, sizeof(SECURE));
-
- return (prs);
-}
-
-/**
** insertr()
**/
@@ -186,14 +110,12 @@ request_by_id_num( long num )
{
register RSTATUS *prs;
- for (prs = Request_List; prs; prs = prs->next)
- if (STREQU(Local_System, prs->secure->system) &&
- strncmp(prs->secure->req_id, "(fake)", strlen("(fake)"))) {
- char *tmp = strrchr(prs->secure->req_id, '-');
+ for (prs = Request_List; prs; prs = prs->next) {
+ char *tmp = strrchr(prs->secure->req_id, '-');
- if (tmp && (num == atol(++tmp)))
- return (prs);
- }
+ if (tmp && (num == atol(++tmp)))
+ return (prs);
+ }
return(0);
}
diff --git a/usr/src/cmd/lp/cmd/lpsched/schedule.c b/usr/src/cmd/lp/cmd/lpsched/schedule.c
index ba02ce5d51..01fbe4213a 100644
--- a/usr/src/cmd/lp/cmd/lpsched/schedule.c
+++ b/usr/src/cmd/lp/cmd/lpsched/schedule.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,7 +28,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.15.1.7 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#include "stdarg.h"
#include "lpsched.h"
@@ -56,17 +56,15 @@ static void ev_form_message(FSTATUS *);
static int ev_slowf(RSTATUS *);
static int ev_notify(RSTATUS *);
-static EXEC *find_exec_slot(EXEC *, int);
+static EXEC *find_exec_slot(EXEC **);
static char *_event_name(int event)
{
static char *_names[] = {
"", "EV_SLOWF", "EV_INTERF", "EV_NOTIFY", "EV_LATER", "EV_ALARM",
- "EV_MESSAGE", "EV_CHECKCHILD"," EV_SYSTEM", "EV_ENABLE",
- "EV_POLLBSDSYSTEMS", "EV_FORM_MESSAGE", "EV_STATUS",
- NULL };
+ "EV_MESSAGE", "EV_ENABLE", "EV_FORM_MESSAGE", NULL };
- if ((event < 0) || (event > EV_STATUS))
+ if ((event < 0) || (event > EV_FORM_MESSAGE))
return ("BAD_EVENT");
else
return (_names[event]);
@@ -90,6 +88,7 @@ schedule(int event, ...)
register RSTATUS * prs;
register FSTATUS * pfs;
+ int i;
/*
* If we're in the process of shutting down, don't
* schedule anything.
@@ -159,8 +158,8 @@ schedule(int event, ...)
ev_interf (pps);
else
- for (pps = walk_ptable(1); pps; pps = walk_ptable(0))
- ev_interf (pps);
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
+ ev_interf (PStatus[i]);
break;
@@ -194,8 +193,8 @@ schedule(int event, ...)
if ((pps = va_arg(ap, PSTATUS *)) != NULL)
enable (pps);
else
- for (pps = walk_ptable(1); pps; pps = walk_ptable(0))
- enable (pps);
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
+ enable (PStatus[i]);
break;
case EV_SLOWF:
@@ -355,7 +354,6 @@ static void
ev_message(PSTATUS *pps)
{
register RSTATUS *prs;
- char *systemName;
char toSelf;
syslog(LOG_DEBUG, "ev_message(%s)",
@@ -363,33 +361,28 @@ ev_message(PSTATUS *pps)
pps->request->req_file : "NULL"));
toSelf = 0;
- BEGIN_WALK_BY_PRINTER_LOOP (prs, pps)
- note("prs (%d) pps (%d)\n", prs, pps);
- systemName = (prs->secure ? prs->secure->system : NULL);
- if ((!systemName) || STREQU(systemName, Local_System))
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if (prs->printer == pps) {
+ note("prs (%d) pps (%d)\n", prs, pps);
if (!toSelf) {
toSelf = 1;
exec(EX_FAULT_MESSAGE, pps, prs);
}
- END_WALK_LOOP
+ }
}
static void
ev_form_message_body(FSTATUS *pfs, RSTATUS *prs, char *toSelf, char ***sysList)
{
- char *systemName;
- systemName = (prs && prs->secure ? prs->secure->system : NULL);
-
- syslog(LOG_DEBUG, "ev_form_message_body(%s, %s, %d, 0x%x)",
+ syslog(LOG_DEBUG, "ev_form_message_body(%s, %d, 0x%x)",
(pfs && pfs->form && pfs->form->name ? pfs->form->name : "NULL"),
- (systemName ? systemName : "NULL"), (toSelf ? *toSelf : 0),
+ (toSelf ? *toSelf : 0),
sysList);
- if ((!systemName) || STREQU(systemName, Local_System))
- if (!*toSelf) {
- *toSelf = 1;
- exec(EX_FORM_MESSAGE, pfs);
- }
+ if (!*toSelf) {
+ *toSelf = 1;
+ exec(EX_FORM_MESSAGE, pfs);
+ }
}
static void
@@ -405,9 +398,11 @@ ev_form_message(FSTATUS *pfs)
toSelf = 0;
sysList = NULL;
- BEGIN_WALK_BY_FORM_LOOP (prs, pfs)
- ev_form_message_body(pfs, prs, &toSelf, &sysList);
- END_WALK_LOOP
+
+ for (prs = Request_List; prs != NULL; prs = prs->next)
+ if (prs->form == pfs)
+ ev_form_message_body(pfs, prs, &toSelf, &sysList);
+
if (NewRequest && (NewRequest->form == pfs))
ev_form_message_body(pfs, NewRequest, &toSelf, &sysList);
@@ -462,27 +457,25 @@ ev_interf(PSTATUS *pps)
if (pps->request || pps->status & (PS_DISABLED|PS_LATER|PS_BUSY))
return;
- BEGIN_WALK_BY_PRINTER_LOOP (prs, pps)
- /*
- * Just because the printer isn't busy and the
- * request is assigned to this printer, don't get the
- * idea that the request can't be printing (RS_ACTIVE),
- * because another printer may still have the request
- * attached but we've not yet heard from the child
- * process controlling that printer.
- */
- if (qchk_waiting(prs))
-
- if (isFormUsableOnPrinter(pps, prs->form) && MATCH(prs, pps)) {
- /*
- * We have the waiting request, we have
- * the ready (local) printer. If the exec fails
- * because the fork failed, schedule a
- * try later and claim we succeeded. The
- * later attempt will sort things out,
- * e.g. will re-schedule if the fork fails
- * again.
- */
+ for (prs = Request_List; prs != NULL; prs = prs->next) {
+ if ((prs->printer == pps) && (qchk_waiting(prs)) &&
+ isFormUsableOnPrinter(pps, prs->form) && MATCH(prs, pps)) {
+ /*
+ * Just because the printer isn't busy and the
+ * request is assigned to this printer, don't get the
+ * idea that the request can't be printing (RS_ACTIVE),
+ * because another printer may still have the request
+ * attached but we've not yet heard from the child
+ * process controlling that printer.
+ *
+ * We have the waiting request, we have
+ * the ready (local) printer. If the exec fails
+ * because the fork failed, schedule a
+ * try later and claim we succeeded. The
+ * later attempt will sort things out,
+ * e.g. will re-schedule if the fork fails
+ * again.
+ */
pps->request = prs;
if (exec(EX_INTERF, pps) == 0) {
pps->status |= PS_BUSY;
@@ -495,7 +488,7 @@ ev_interf(PSTATUS *pps)
return;
}
}
- END_WALK_LOOP
+ }
return;
}
@@ -517,8 +510,11 @@ ev_slowf(RSTATUS *prs)
* or if it's unwise to execute any more (fork failed).
*/
- if (!(ep = find_exec_slot(Exec_Slow, ET_SlowSize)))
+ if (!(ep = find_exec_slot(Exec_Slow))) {
+ syslog(LOG_DEBUG, "ev_slowf(%s): no slot",
+ (prs && prs->req_file ? prs->req_file : "NULL"));
return (-1);
+ }
if (!(prs->request->outcome & (RS_DONE|RS_HELD|RS_ACTIVE)) &&
NEEDS_FILTERING(prs)) {
@@ -570,7 +566,7 @@ ev_notify(RSTATUS *prs)
* to run at the same time, so we may not be able to
* do it.
*/
- } else if (!(ep = find_exec_slot(Exec_Notify, ET_NotifySize)))
+ } else if (!(ep = find_exec_slot(Exec_Notify)))
return (-1);
else if (prs->request->outcome & RS_NOTIFY &&
@@ -595,14 +591,15 @@ ev_notify(RSTATUS *prs)
*/
static EXEC *
-find_exec_slot(EXEC *exec_table, int size)
+find_exec_slot(EXEC **exec_table)
{
- register EXEC * ep;
- register EXEC * last_ep = exec_table + size - 1;
+ int i;
- for (ep = exec_table; ep <= last_ep; ep++)
- if (ep->pid == 0)
- return (ep);
+ for (i = 0; exec_table[i] != NULL; i++)
+ if (exec_table[i]->pid == 0)
+ return (exec_table[i]);
+ syslog(LOG_DEBUG, "find_exec_slot(0x%8.8x): after %d, no slots",
+ exec_table, i);
return (0);
}
diff --git a/usr/src/cmd/lp/cmd/lpsched/status.c b/usr/src/cmd/lp/cmd/lpsched/status.c
index b0311ddacb..893ffa3c05 100644
--- a/usr/src/cmd/lp/cmd/lpsched/status.c
+++ b/usr/src/cmd/lp/cmd/lpsched/status.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.
@@ -19,15 +18,15 @@
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
/*
- * Copyright (c) 2001 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
#pragma ident "%Z%%M% %I% %E% SMI"
#include "stdlib.h"
@@ -39,8 +38,6 @@
#define NCMP(X,Y) (STRNEQU((X), (Y), sizeof(Y)-1))
-extern char *LP_TRAY_UNMOUNT;
-
static void load_pstatus ( void );
static void load_fault_status ( void );
static void load_cstatus ( void );
@@ -192,7 +189,7 @@ load_pstatus(void)
case PST_PWHEEL:
if (*buf) {
- ppws = search_pwtable(buf);
+ ppws = search_pwstatus(buf);
pwheel_name = Strdup(buf);
} else {
ppws = 0;
@@ -213,7 +210,7 @@ load_pstatus(void)
}
if ((tmp != NULL) && name &&
- (pps = search_ptable(name))) {
+ (pps = search_pstatus(name))) {
pps->rej_date = rej_date;
pps->status |= status;
pps->forms = ppfs;
@@ -255,14 +252,14 @@ load_pstatus(void)
close(fd);
}
- for (i = 0; i < PT_Size; i++)
- if (PStatus[i].printer->name && !PStatus[i].rej_reason) {
- PStatus[i].dis_reason = Strdup(CUZ_NEW_PRINTER);
- PStatus[i].rej_reason = Strdup(CUZ_NEW_DEST);
- PStatus[i].fault_reason = Strdup(CUZ_PRINTING_OK);
- PStatus[i].dis_date = now;
- PStatus[i].rej_date = now;
- PStatus[i].status |= PS_DISABLED | PS_REJECTED;
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
+ if (PStatus[i]->printer->name && !PStatus[i]->rej_reason) {
+ PStatus[i]->dis_reason = Strdup(CUZ_NEW_PRINTER);
+ PStatus[i]->rej_reason = Strdup(CUZ_NEW_DEST);
+ PStatus[i]->fault_reason = Strdup(CUZ_PRINTING_OK);
+ PStatus[i]->dis_date = now;
+ PStatus[i]->rej_date = now;
+ PStatus[i]->status |= PS_DISABLED | PS_REJECTED;
}
return;
@@ -275,8 +272,6 @@ load_pstatus(void)
static void
load_fault_status(void)
{
- PSTATUS *pps;
-
char *fault_reason = NULL,
buf[BUFSIZ],
*fault_status,
@@ -290,8 +285,10 @@ load_fault_status(void)
int fd;
- for (i = 0; i < PT_Size; i++) {
- printerName = PStatus[i].printer->name;
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++) {
+ PSTATUS *pps = PStatus[i];
+
+ printerName = pps->printer->name;
if (printerName) {
fault_status = makepath(Lp_A_Printers, printerName,
FAULT_MESSAGE_FILE , (char *) 0);
@@ -314,7 +311,7 @@ load_fault_status(void)
}
if (fault_reason &&
- (pps = search_ptable(printerName))) {
+ (pps = search_pstatus(printerName))) {
p = fault_reason + strlen(fault_reason)
- 1;
if (*p == '\n')
@@ -421,7 +418,7 @@ load_cstatus(void)
}
if ((tmp != NULL) && name &&
- (pcs = search_ctable(name))) {
+ (pcs = search_cstatus(name))) {
pcs->rej_reason = rej_reason;
pcs->rej_date = rej_date;
pcs->status |= status;
@@ -444,11 +441,11 @@ load_cstatus(void)
close(fd);
}
- for (i = 0; i < CT_Size; i++)
- if (CStatus[i].class->name && !CStatus[i].rej_reason) {
- CStatus[i].status |= CS_REJECTED;
- CStatus[i].rej_reason = Strdup(CUZ_NEW_DEST);
- CStatus[i].rej_date = now;
+ for (i = 0; CStatus != NULL && CStatus[i] != NULL; i++)
+ if (CStatus[i]->class->name && !CStatus[i]->rej_reason) {
+ CStatus[i]->status |= CS_REJECTED;
+ CStatus[i]->rej_reason = Strdup(CUZ_NEW_DEST);
+ CStatus[i]->rej_date = now;
}
return;
@@ -473,7 +470,8 @@ showForms(PSTATUS *pps)
for (i = 0; i < numForms; i++) {
pfs = ppfs[i].form;
snprintf(buf, sizeof (buf), "%s%c",
- (pfs ? pfs->form->name : ""), *LP_SEP);
+ (pfs ? pfs->form->name : ""),
+ ((i + 1 < numForms) ? *LP_SEP : '\0'));
if (addstring(&formList,buf)) { /* allocation failed */
if (formList) {
@@ -542,9 +540,8 @@ parseFormList(char *formList, short *num)
ptr = formList;
for (i = 0; endPtr && (i < numForms); i++) {
*endPtr = 0;
- ppfs[i].form = pfs = search_ftable(ptr);
- ppfs[i].isAvailable =
- ((pfs || (!LP_TRAY_UNMOUNT)) ? 1 : 0);
+ ppfs[i].form = pfs = search_fstatus(ptr);
+ ppfs[i].isAvailable = (pfs ? 1 : 0);
ptr = endPtr+1;
endPtr = strchr(ptr,*LP_SEP);
}
@@ -567,7 +564,7 @@ dump_pstatus(void)
int fd;
register PSTATUS *pps;
register int f;
-
+ int i;
if (!pstatus)
pstatus = makepath(Lp_System, PSTATUSFILE, (char *)0);
@@ -576,7 +573,9 @@ dump_pstatus(void)
return;
}
- for (pps = PStatus, ppsend = &PStatus[PT_Size]; pps < ppsend; pps++)
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++) {
+ PSTATUS *pps = PStatus[i];
+
if (pps->printer->name)
for (f = 0; f < PST_MAX; f++) switch (f) {
case PST_BRK:
@@ -616,7 +615,7 @@ dump_pstatus(void)
break;
}
}
-
+ }
close(fd);
return;
@@ -636,7 +635,7 @@ dump_fault_status(PSTATUS *pps)
fault_status = makepath(Lp_A_Printers, printerName, FAULT_MESSAGE_FILE,
(char *) 0);
if ((fd = open_locked(fault_status, "w", MODE_READ)) < 0) {
- syslog(LOG_DEBUG, "Can't open file %s (%m)\n", fault_status);
+ syslog(LOG_DEBUG, "Can't open file %s (%m)", fault_status);
} else {
fdprintf(fd, "%s\n", pps->fault_reason);
close(fd);
@@ -654,20 +653,21 @@ dump_fault_status(PSTATUS *pps)
void
dump_cstatus(void)
{
- CSTATUS *pcsend;
int fd;
- register CSTATUS *pcs;
register int f;
+ int i;
if (!cstatus)
cstatus = makepath(Lp_System, CSTATUSFILE, (char *)0);
if ((fd = open_locked(cstatus, "w", MODE_READ)) < 0) {
- syslog(LOG_DEBUG, "Can't open file %s (%m)\n", cstatus);
+ syslog(LOG_DEBUG, "Can't open file %s (%m)", cstatus);
return;
}
- for (pcs = CStatus, pcsend = &CStatus[CT_Size]; pcs < pcsend; pcs++)
+ for (i = 0; CStatus != NULL && CStatus[i] != NULL; i++) {
+ CSTATUS *pcs = CStatus[i];
+
if (pcs->class->name)
for (f = 0; f < CST_MAX; f++) switch (f) {
case CST_BRK:
@@ -690,7 +690,7 @@ dump_cstatus(void)
put_multi_line(fd, pcs->rej_reason);
break;
}
-
+ }
close(fd);
return;
diff --git a/usr/src/cmd/lp/cmd/lpsched/terminate.c b/usr/src/cmd/lp/cmd/lpsched/terminate.c
index db0727e397..919123115f 100644
--- a/usr/src/cmd/lp/cmd/lpsched/terminate.c
+++ b/usr/src/cmd/lp/cmd/lpsched/terminate.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.
@@ -19,15 +18,16 @@
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
/*
- * Copyright 2000-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
#pragma ident "%Z%%M% %I% %E% SMI"
#include "lpsched.h"
@@ -49,13 +49,6 @@ terminate(register EXEC *ep)
if (ep->pid <= 0)
return;
-#if defined(DEBUG)
- if (debug & DB_EXEC)
- execlog("KILL: pid %d%s%s\n", ep->pid,
- ((ep->flags & EXF_KILLED)? ", second time" : ""),
- (kill(ep->pid, 0) == -1? ", but child is GONE!" : ""));
-#endif
-
if (ep->flags & EXF_KILLED)
return;
ep->flags |= EXF_KILLED;
diff --git a/usr/src/cmd/lp/cmd/lpsched/validate.c b/usr/src/cmd/lp/cmd/lpsched/validate.c
index 2791428e06..6c5ab47ab4 100644
--- a/usr/src/cmd/lp/cmd/lpsched/validate.c
+++ b/usr/src/cmd/lp/cmd/lpsched/validate.c
@@ -82,6 +82,7 @@ _validate(RSTATUS *prs, PSTATUS *pps, PSTATUS *stop_pps, char **prefixp,
single;
size_t n;
+ int i;
short ret;
@@ -109,12 +110,10 @@ _validate(RSTATUS *prs, PSTATUS *pps, PSTATUS *stop_pps, char **prefixp,
}
lp_or_root = 0;
- if (STREQU(prs->secure->system, Local_System))
- if (bangequ(prs->secure->user, "root") ||
- bangequ(prs->secure->user, "lp"))
+ if (bangequ(prs->secure->user, "root") ||
+ bangequ(prs->secure->user, "lp"))
lp_or_root = 1;
-
if (prefixp)
*prefixp = prs->request->destination;
@@ -124,8 +123,8 @@ _validate(RSTATUS *prs, PSTATUS *pps, PSTATUS *stop_pps, char **prefixp,
*/
if (!pps && prs->request->destination &&
!STREQU(prs->request->destination, NAME_ANY))
- if (((pps = search_ptable(prs->request->destination)) != NULL) ||
- ((pcs = search_ctable(prs->request->destination)) != NULL) &&
+ if (((pps = search_pstatus(prs->request->destination)) != NULL) ||
+ ((pcs = search_cstatus(prs->request->destination)) != NULL) &&
pcs->class->members)
/*EMPTY*/;
else {
@@ -149,7 +148,7 @@ _validate(RSTATUS *prs, PSTATUS *pps, PSTATUS *stop_pps, char **prefixp,
* form knowledge.
*/
if (prs && prs->request && prs->request->form && (pps || pcs)) {
- if ((pfs = search_ftable(prs->request->form))) {
+ if ((pfs = search_fstatus(prs->request->form))) {
if (lp_or_root || allowed(prs->secure->user,
pfs->users_allowed, pfs->users_denied))
/*EMPTY*/;
@@ -400,9 +399,7 @@ _validate(RSTATUS *prs, PSTATUS *pps, PSTATUS *stop_pps, char **prefixp,
if (pcs)
n = lenlist(pcs->class->members);
else {
- n = 0;
- for (pps = walk_ptable(1); pps; pps = walk_ptable(0))
- n++;
+ for (n = 0; PStatus != NULL && PStatus[n] != NULL; n++) ;
}
pcend = arena = (CANDIDATE *)Calloc(n, sizeof(CANDIDATE));
@@ -416,16 +413,19 @@ _validate(RSTATUS *prs, PSTATUS *pps, PSTATUS *stop_pps, char **prefixp,
for (pn = pcs->class->members; *pn; pn++)
if (
- ((pps = search_ptable(*pn)) != NULL)
+ ((pps = search_pstatus(*pn)) != NULL)
&& pps != stop_pps
)
(pcend++)->pps = pps;
} else
- for (pps = walk_ptable(1); pps; pps = walk_ptable(0))
+ for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++) {
+ pps = PStatus[i];
+
if (CHKACCEPT(prs, pps) && pps != stop_pps)
(pcend++)->pps = pps;
+ }
if (pcend == arena) {
ret = MERRDEST;
@@ -537,11 +537,6 @@ _validate(RSTATUS *prs, PSTATUS *pps, PSTATUS *stop_pps, char **prefixp,
*/
#define CHKFREE(PPS) (!((PPS)->status & (PS_BUSY|PS_LATER)))
- /*
- * Is the printer local?
- */
-#define CHKLOCAL(PPS) (!((PPS)->status & (PS_REMOTE)))
-
{
register CANDIDATE *pcend2;
@@ -566,8 +561,6 @@ _validate(RSTATUS *prs, PSTATUS *pps, PSTATUS *stop_pps, char **prefixp,
pc->weight += WEIGHT_MOUNTED;
if (CHKCHSET(prs, pc->pps))
pc->weight += WEIGHT_SELECTS;
- if (CHKLOCAL(pc->pps))
- pc->weight += WEIGHT_LOCAL;
#if defined(FILTER_EARLY_OUT)
if (pc->weight == WEIGHT_MAX) {
diff --git a/usr/src/cmd/lp/cmd/lpsched/validate.h b/usr/src/cmd/lp/cmd/lpsched/validate.h
index cfd3113206..cf415a0b0b 100644
--- a/usr/src/cmd/lp/cmd/lpsched/validate.h
+++ b/usr/src/cmd/lp/cmd/lpsched/validate.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,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,7 +27,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1.1.2 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* The old LP Spooler would take a job destined for a class of printers
@@ -65,14 +64,12 @@ typedef struct candidate {
#define WEIGHT_ENABLED 4
#define WEIGHT_MOUNTED 8
#define WEIGHT_SELECTS 16
-#define WEIGHT_LOCAL 32
#define WEIGHT_MAX ( \
WEIGHT_NOFILTER \
+ WEIGHT_FREE \
+ WEIGHT_ENABLED \
+ 2 * WEIGHT_MOUNTED \
+ WEIGHT_SELECTS \
- + WEIGHT_LOCAL \
)
extern int pick_filter();
diff --git a/usr/src/cmd/lp/include/lp.h b/usr/src/cmd/lp/include/lp.h
index 372c592335..50cef37ade 100644
--- a/usr/src/cmd/lp/include/lp.h
+++ b/usr/src/cmd/lp/include/lp.h
@@ -214,7 +214,6 @@ typedef struct FALERT {
#define CUZ_LOGIN_PRINTER "disabled by Spooler: login terminal"
#define CUZ_MOUNTING "mounting a form"
#define CUZ_NOFORK "can't fork"
-#define CUZ_NOREMOTE "remote system no longer defined"
#define CUZ_PRINTING_OK "ready and printing"
#define TIMEOUT_FAULT \
@@ -356,8 +355,6 @@ extern char Lp_Spooldir[],
Lp_Logs[],
Lp_ReqLog[],
Lp_Model[],
- Lp_Private_FIFOs[],
- Lp_Public_FIFOs[],
Lp_Requests[],
Lp_Secure[],
Lp_Schedlock[],
diff --git a/usr/src/cmd/lp/include/msgs.h b/usr/src/cmd/lp/include/msgs.h
index 7fa704603e..90d1f3f186 100644
--- a/usr/src/cmd/lp/include/msgs.h
+++ b/usr/src/cmd/lp/include/msgs.h
@@ -27,7 +27,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.18 */
+#pragma ident "%Z%%M% %I% %E% SMI"
# include <sys/types.h>
# include <poll.h>
@@ -43,8 +43,8 @@
* I.E R_... MESSAGE FOR A S_... MESSAGE IS (S_... + 1)
*/
# define R_BAD_MESSAGE 0
-# define S_NEW_QUEUE 1
-# define R_NEW_QUEUE 2
+/* # define S_NEW_QUEUE 1 DEFUNCT */
+/* # define R_NEW_QUEUE 2 DEFUNCT */
# define S_ALLOC_FILES 3
# define R_ALLOC_FILES 4
# define S_PRINT_REQUEST 5
@@ -55,8 +55,8 @@
# define R_END_CHANGE_REQUEST 10
# define S_CANCEL_REQUEST 11
# define R_CANCEL_REQUEST 12
-# define S_INQUIRE_REQUEST 13
-# define R_INQUIRE_REQUEST 14
+/* # define S_INQUIRE_REQUEST 13 DEFUNCT */
+/* # define R_INQUIRE_REQUEST 14 DEFUNCT */
# define S_LOAD_PRINTER 15
# define R_LOAD_PRINTER 16
# define S_UNLOAD_PRINTER 17
@@ -101,8 +101,8 @@
# define R_LOAD_FORM 56
# define S_UNLOAD_FORM 57
# define R_UNLOAD_FORM 58
-# define S_GETSTATUS 59
-# define R_GETSTATUS 60
+/* # define S_GETSTATUS 59 DEFUNCT */
+/* # define R_GETSTATUS 60 DEFUNCT */
# define S_QUIET_ALERT 61
# define R_QUIET_ALERT 62
# define S_SEND_FAULT 63
@@ -117,27 +117,27 @@
*/
# define I_GET_TYPE 69
# define I_QUEUE_CHK 70
-# define R_CONNECT 71
+/* # define R_CONNECT 71 DEFUNCT */
-# define S_GET_STATUS 72
-# define R_GET_STATUS 73
+/* # define S_GET_STATUS 72 DEFUNCT */
+/* # define R_GET_STATUS 73 DEFUNCT */
# define S_INQUIRE_REQUEST_RANK 74
# define R_INQUIRE_REQUEST_RANK 75
# define S_CANCEL 76
# define R_CANCEL 77
-# define S_NEW_CHILD 78
-# define R_NEW_CHILD 79
-# define S_SEND_JOB 80
-# define R_SEND_JOB 81
-# define S_JOB_COMPLETED 82
-# define R_JOB_COMPLETED 83
-# define S_INQUIRE_REMOTE_PRINTER 84
-# define R_INQUIRE_REMOTE_PRINTER 20
-# define S_CHILD_SYNC 85
-# define S_LOAD_SYSTEM 86
-# define R_LOAD_SYSTEM 87
-# define S_UNLOAD_SYSTEM 88
-# define R_UNLOAD_SYSTEM 89
+/* # define S_NEW_CHILD 78 DEFUNCT */
+/* # define R_NEW_CHILD 79 DEFUNCT */
+/* # define S_SEND_JOB 80 DEFUNCT */
+/* # define R_SEND_JOB 81 DEFUNCT */
+/* # define S_JOB_COMPLETED 82 DEFUNCT */
+/* # define R_JOB_COMPLETED 83 DEFUNCT */
+/* # define S_INQUIRE_REMOTE_PRINTER 84 DEFUNCT */
+/* # define R_INQUIRE_REMOTE_PRINTER 20 DEFUNCT */
+/* # define S_CHILD_SYNC 85 DEFUNCT */
+/* # define S_LOAD_SYSTEM 86 DEFUNCT */
+/* # define R_LOAD_SYSTEM 87 DEFUNCT */
+/* # define S_UNLOAD_SYSTEM 88 DEFUNCT */
+/* # define R_UNLOAD_SYSTEM 89 DEFUNCT */
/* new messages */
# define S_CLEAR_FAULT 90
# define R_CLEAR_FAULT 91
diff --git a/usr/src/cmd/lp/include/printers.h b/usr/src/cmd/lp/include/printers.h
index fb89ed6ec8..baf8698645 100644
--- a/usr/src/cmd/lp/include/printers.h
+++ b/usr/src/cmd/lp/include/printers.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.
@@ -24,7 +23,7 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -76,7 +75,6 @@
#define PS_FAULTED 0x004
#define PS_BUSY 0x008
#define PS_LATER 0x010 /* Printer is scheduled for service */
-#define PS_REMOTE 0x020
#define PS_SHOW_FAULT 0x100 /* set if exMess should be run when fault */
#define PS_USE_AS_KEY 0x200 /* to insure that status used as key is non 0 */
#define PS_FORM_FAULT 0x400 /* set a form fault rather a printer fault*/
diff --git a/usr/src/cmd/lp/include/requests.h b/usr/src/cmd/lp/include/requests.h
index d6c54be7b4..feaae89232 100644
--- a/usr/src/cmd/lp/include/requests.h
+++ b/usr/src/cmd/lp/include/requests.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,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,7 +27,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.13 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#if !defined(_LP_REQUESTS_H)
#define _LP_REQUESTS_H
@@ -58,7 +57,6 @@
# define RQ_RAW 14
# define RQ_FAST 15
# define RQ_STAT 16
-# define RQ_VERSION 17
/**
** The internal copy of a request as seen by the rest of the world:
@@ -84,13 +82,8 @@ typedef struct REQUEST {
char *input_type; /* type of content */
char *user; /* user name of person submitting */
ushort outcome; /* success/fauilure */
- ushort version; /* version of system sending job*/
} REQUEST;
-#define BSD_FORM "=bsdForm=" /* form name given to jobs from bsd */
-#define VERSION_BSD 0
-#define VERSION_OLD_LP 1
-#define VERSION_NEW_LP 2
/*
* Bit flags for the "actions" member:
@@ -122,10 +115,8 @@ typedef struct REQUEST {
#define RS_CANCELLED 0x0040 /* request was cancelled */
#define RS_IMMEDIATE 0x0080 /* should be next to print */
#define RS_FAILED 0x0100 /* slow filter or interface failed */
-#define RS_SENDING 0x0200 /* Request is in transit to a remote */
#define RS_NOTIFY 0x0400 /* user is to be notified (alert) */
#define RS_NOTIFYING 0x0800 /* notification (alert) is running */
-#define RS_SENT 0x1000 /* Request accepted on remote system */
#define RS_ADMINHELD 0x2000 /* administrator placed RS_HELD */
#define RS_REFILTER 0x4000 /* had to change filters */
#define RS_STOPPED 0x8000 /* temporarily stopped the request */
@@ -135,11 +126,9 @@ typedef struct REQUEST {
*
* RS_DONE request is finished printing or was cancelled
* RS_ACTIVE request is being handled, can be skipped
- * RS_GONEREMOTE request is being or has been sent to remote
*/
#define RS_DONE (RS_CANCELLED|RS_PRINTED|RS_FAILED)
#define RS_ACTIVE (RS_FILTERING|RS_PRINTING|RS_CHANGING|RS_NOTIFYING)
-#define RS_GONEREMOTE (RS_SENT|RS_SENDING)
/**
** Various routines.
diff --git a/usr/src/cmd/lp/include/secure.h b/usr/src/cmd/lp/include/secure.h
index ee95ff89db..c1ff7f8657 100644
--- a/usr/src/cmd/lp/include/secure.h
+++ b/usr/src/cmd/lp/include/secure.h
@@ -27,7 +27,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */
+#pragma ident "%Z%%M% %I% %E% SMI"
#if !defined(_LP_SECURE_H)
#define _LP_SECURE_H
@@ -41,15 +41,14 @@
/*
* There are 8 fields in the secure request file.
*/
-#define SC_MAX 8
+#define SC_MAX 7
# define SC_REQID 0 /* Original request id */
# define SC_UID 1 /* Originator's user ID */
# define SC_USER 2 /* Originator's real login name */
# define SC_GID 3 /* Originator's group ID */
# define SC_SIZE 4 /* Total size of the request data */
# define SC_DATE 5 /* Date submitted (in seconds) */
-# define SC_SYSTEM 6 /* Originating system */
-# define SC_SLABEL 7 /* Sensitivity Label */
+# define SC_SLABEL 6 /* Sensitivity Label */
/**
** The internal copy of a request as seen by the rest of the world:
@@ -60,7 +59,6 @@ typedef struct SECURE {
gid_t gid;
off_t size;
time_t date;
- char *system;
char *user;
char *req_id;
char *slabel;
diff --git a/usr/src/cmd/lp/lib/class/freeclass.c b/usr/src/cmd/lp/lib/class/freeclass.c
index a3c2435784..dc6fd9f448 100644
--- a/usr/src/cmd/lp/lib/class/freeclass.c
+++ b/usr/src/cmd/lp/lib/class/freeclass.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.
@@ -19,13 +18,20 @@
*
* CDDL HEADER END
*/
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
-#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/* LINTLIBRARY */
+#include <syslog.h>
#include "lp.h"
#include "class.h"
@@ -45,8 +51,11 @@ freeclass (clsbufp)
{
if (!clsbufp)
return;
+ syslog(LOG_DEBUG, "freeclass(%s)", clsbufp->name ? clsbufp->name : "");
if (clsbufp->name)
Free (clsbufp->name);
freelist (clsbufp->members);
+ Free(clsbufp);
+
return;
}
diff --git a/usr/src/cmd/lp/lib/class/getclass.c b/usr/src/cmd/lp/lib/class/getclass.c
index 92ca9a99f6..ad888370f4 100644
--- a/usr/src/cmd/lp/lib/class/getclass.c
+++ b/usr/src/cmd/lp/lib/class/getclass.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,13 +28,14 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "stdio.h"
#include "string.h"
#include "errno.h"
#include "sys/types.h"
+#include <syslog.h>
#include "lp.h"
#include "class.h"
@@ -48,13 +49,14 @@ getclass(char *name)
{
static long lastdir = -1;
- static CLASS clsbuf;
+ CLASS *clsp;
char *file,
buf[BUFSIZ];
int fd;
+ syslog(LOG_DEBUG, "getclass(%s)", name ? name : "");
if (!name || !*name) {
errno = EINVAL;
@@ -84,34 +86,39 @@ getclass(char *name)
}
Free (file);
- if (!(clsbuf.name = Strdup(name))) {
+ clsp = (CLASS *)calloc(sizeof (*clsp), 1);
+
+ if (!(clsp->name = Strdup(name))) {
+ Free (clsp);
close(fd);
errno = ENOMEM;
return (0);
}
- clsbuf.members = 0;
+ clsp->members = 0;
errno = 0;
while (fdgets(buf, BUFSIZ, fd)) {
buf[strlen(buf) - 1] = 0;
- addlist (&clsbuf.members, buf);
+ addlist (&clsp->members, buf);
}
if (errno != 0) {
int save_errno = errno;
- freelist (clsbuf.members);
- Free (clsbuf.name);
+ freelist (clsp->members);
+ Free (clsp->name);
+ Free (clsp);
close(fd);
errno = save_errno;
return (0);
}
close(fd);
- if (!clsbuf.members) {
- Free (clsbuf.name);
+ if (!clsp->members) {
+ Free (clsp->name);
+ Free (clsp);
errno = EBADF;
return (0);
}
- return (&clsbuf);
+ return (clsp);
}
diff --git a/usr/src/cmd/lp/lib/lp/getpaths.c b/usr/src/cmd/lp/lib/lp/getpaths.c
index 88611d0f93..f664beaed5 100644
--- a/usr/src/cmd/lp/lib/lp/getpaths.c
+++ b/usr/src/cmd/lp/lib/lp/getpaths.c
@@ -38,8 +38,6 @@
char Lp_Spooldir[] = SPOOLDIR;
char Lp_Admins[] = SPOOLDIR "/admins";
char Lp_FIFO[] = SPOOLDIR "/fifos/FIFO";
-char Lp_Private_FIFOs[] = SPOOLDIR "/fifos/private";
-char Lp_Public_FIFOs[] = SPOOLDIR "/fifos/public";
char Lp_Requests[] = SPOOLDIR "/requests";
char Lp_Schedlock[] = SPOOLDIR "/SCHEDLOCK";
char Lp_System[] = SPOOLDIR "/system";
diff --git a/usr/src/cmd/lp/lib/msgs/msgfmts.c b/usr/src/cmd/lp/lib/msgs/msgfmts.c
index efe7bfc9ea..100f0b9730 100644
--- a/usr/src/cmd/lp/lib/msgs/msgfmts.c
+++ b/usr/src/cmd/lp/lib/msgs/msgfmts.c
@@ -27,7 +27,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.18 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/* LINTLIBRARY */
char *_lp_msg_fmts[] =
@@ -100,7 +100,7 @@ char *_lp_msg_fmts[] =
"H", /* 65 - S_SHUTDOWN */
"H", /* 66 - R_SHUTDOWN */
"", /* 67 - S_GOODBYE */
- "LHHH", /* 68 - S_CHILD_DONE */
+ "LHH", /* 68 - S_CHILD_DONE */
"", /* 69 - I_GET_TYPE */
"", /* 70 - I_QUEUE_CHK */
"SH", /* 71 - R_CONNECT */
diff --git a/usr/src/cmd/lp/lib/papi/lpsched-jobs.c b/usr/src/cmd/lp/lib/papi/lpsched-jobs.c
index a4fea773a5..08d7f68524 100644
--- a/usr/src/cmd/lp/lib/papi/lpsched-jobs.c
+++ b/usr/src/cmd/lp/lib/papi/lpsched-jobs.c
@@ -69,7 +69,8 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r,
"job-sheets", "lp-charset", "lp-modes", "number-up",
"orienttation-requested", "page-ranges", "pr-filter",
"pr-indent", "pr-title", "pr-width", "priority",
- "requesting-user-name", NULL };
+ "requesting-user-name", "job-originating-host-name",
+ NULL };
if (attributes == NULL)
return (PAPI_BAD_ARGUMENT);
@@ -146,6 +147,8 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r,
if ((uid == 0) || (uid == 71)) { /* root/lp can forge this */
papiAttributeListGetString(attributes, NULL,
+ "job-originating-host-name", &host);
+ papiAttributeListGetString(attributes, NULL,
"job-host", &host);
papiAttributeListGetString(attributes, NULL,
"job-originating-user-name", &user);
@@ -207,7 +210,7 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r,
/* add burst page information */
s = NULL;
papiAttributeListGetString(attributes, NULL, "job-sheets", &s);
- if ((s != NULL) && (strcasecmp(s, "none") == 0)) {
+ if ((s != NULL) && (strcasecmp(s, "none") != 0)) {
char buf[128];
char *class = NULL;
char *job_name = NULL;
@@ -351,6 +354,28 @@ lpsched_request_outcome_to_attributes(papi_attribute_t ***attributes,
}
/*
+ * convert user[@host] to papi attributes
+ */
+static void
+lpsched_user_to_job_attributes(papi_attribute_t ***list, char *user)
+{
+ if ((list != NULL) && (user != NULL) && (user[0] != NULL)) {
+ char *host = strrchr(user, '@');
+
+ if (host != NULL) {
+ *host = NULL;
+ papiAttributeListAddString(list, PAPI_ATTR_REPLACE,
+ "job-originating-user-name", user);
+ papiAttributeListAddString(list, PAPI_ATTR_REPLACE,
+ "job-originating-host-name", host + 1);
+ *host = '@';
+ } else
+ papiAttributeListAddString(list, PAPI_ATTR_REPLACE,
+ "job-originating-user-name", user);
+ }
+}
+
+/*
* Convert REQUEST structure to the equivalent PAPI attribute representation.
*/
void
@@ -413,8 +438,7 @@ lpsched_request_to_job_attributes(REQUEST *r, job_t *j)
/* input_type */
/* user */
- papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE,
- "job-originating-user-name", r->user);
+ lpsched_user_to_job_attributes(&j->attributes, r->user);
/* outcome */
lpsched_request_outcome_to_attributes(&j->attributes, r->outcome);
@@ -439,8 +463,7 @@ job_status_to_attributes(job_t *job, char *req_id, char *user, char *slabel,
char buf[BUFSIZ];
char *p;
- papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE,
- "job-originating-user-name", user);
+ lpsched_user_to_job_attributes(&job->attributes, user);
papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
"job-k-octets", size/1024);
papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
diff --git a/usr/src/cmd/lp/lib/papi/lpsched-msgs.c b/usr/src/cmd/lp/lib/papi/lpsched-msgs.c
index 5f5806276b..b7646151b0 100644
--- a/usr/src/cmd/lp/lib/papi/lpsched-msgs.c
+++ b/usr/src/cmd/lp/lib/papi/lpsched-msgs.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
@@ -124,7 +125,6 @@ lpsched_status_to_papi_status(int status)
case MNOOPEN:
return (PAPI_DOCUMENT_ACCESS_ERROR);
case MERRDEST:
- return (PAPI_DEVICE_ERROR);
case MDENYDEST:
return (PAPI_NOT_ACCEPTING);
case MNOMEDIA:
@@ -161,7 +161,7 @@ lpsched_status_string(short status)
case MNOOPEN:
return (gettext("lpsched: could not open request"));
case MERRDEST:
- return (gettext("An error occured in submission"));
+ return (gettext("queue disabled"));
case MDENYDEST:
return (gettext("destination denied request"));
case MNOMEDIA:
@@ -487,9 +487,11 @@ lpsched_remove_printer(papi_service_t handle, char *dest)
return (PAPI_SERVICE_UNAVAILABLE);
/* remove from any classes */
- while ((cls = getclass(NAME_ALL)) != NULL)
+ while ((cls = getclass(NAME_ALL)) != NULL) {
if (searchlist(dest, cls->members) != 0)
remove_from_class(handle, dest, cls);
+ freeclass(cls);
+ }
/* reset the default if it needs to be done */
if (((dflt = getdefault()) != NULL) &&
diff --git a/usr/src/cmd/lp/lib/papi/mapfile b/usr/src/cmd/lp/lib/papi/mapfile
index a10fae2acf..0377e300ec 100644
--- a/usr/src/cmd/lp/lib/papi/mapfile
+++ b/usr/src/cmd/lp/lib/papi/mapfile
@@ -141,6 +141,9 @@ SUNWprivate_1.0 {
list_append = FUNCTION FILTER libpapi-common.so ;
list_concatenate = FUNCTION FILTER libpapi-common.so ;
+ # NS
+ getprinterbyname = FUNCTION FILTER libpapi-common.so ;
+
# extra Attribute Calls
copy_attributes = FUNCTION FILTER libpapi-common.so ;
split_and_copy_attributes = FUNCTION FILTER libpapi-common.so ;
diff --git a/usr/src/cmd/lp/lib/printers/freeprinter.c b/usr/src/cmd/lp/lib/printers/freeprinter.c
index a30d277fa5..e915885dd0 100644
--- a/usr/src/cmd/lp/lib/printers/freeprinter.c
+++ b/usr/src/cmd/lp/lib/printers/freeprinter.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.
@@ -19,11 +18,17 @@
*
* CDDL HEADER END
*/
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
-#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "sys/types.h"
@@ -31,6 +36,7 @@
#include "lp.h"
#include "printers.h"
+#include <syslog.h>
/**
** freeprinter() - FREE MEMORY ALLOCATED FOR PRINTER STRUCTURE
@@ -41,12 +47,16 @@ void freeprinter (pp)
{
if (!pp)
return;
+
+ syslog(LOG_DEBUG, "freeprinter(%s)", pp->name ? pp->name : "");
if (pp->name)
Free (pp->name);
if (pp->char_sets)
freelist (pp->char_sets);
if (pp->input_types)
freelist (pp->input_types);
+ if (pp->options)
+ freelist (pp->options);
if (pp->device)
Free (pp->device);
if (pp->dial_info)
@@ -73,5 +83,7 @@ void freeprinter (pp)
#endif
if (pp->printer_types)
freelist (pp->printer_types);
+ Free (pp);
+
return;
}
diff --git a/usr/src/cmd/lp/lib/printers/getprinter.c b/usr/src/cmd/lp/lib/printers/getprinter.c
index 7bb0386f83..058d1ae2d7 100644
--- a/usr/src/cmd/lp/lib/printers/getprinter.c
+++ b/usr/src/cmd/lp/lib/printers/getprinter.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.
@@ -19,15 +18,15 @@
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
#pragma ident "%Z%%M% %I% %E% SMI"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
@@ -37,6 +36,7 @@
#include "errno.h"
#include "sys/types.h"
#include "stdlib.h"
+#include <syslog.h>
#include "lp.h"
#include "printers.h"
@@ -56,7 +56,7 @@ getprinter(char *name)
{
static long lastdir = -1;
- static PRINTER prbuf;
+ PRINTER *prp;
char buf[BUFSIZ];
@@ -81,6 +81,7 @@ getprinter(char *name)
return (0);
}
+ syslog(LOG_DEBUG, "getprinter(%s)", name ? name : "");
/*
* Getting ``all''? If so, jump into the directory
* wherever we left off.
@@ -136,14 +137,14 @@ getprinter(char *name)
* after reading the file, because sometimes the file
* contains an empty header to FORCE a null/empty value.
*/
- (void)memset ((char *)&prbuf, 0, sizeof(prbuf));
- prbuf.name = Strdup(name);
+ prp = calloc(sizeof (*prp), 1);
+ prp->name = Strdup(name);
if (isNameAll)
Free(name);
- prbuf.printer_types = getlist(NAME_UNKNOWN, LP_WS, LP_SEP);
- prbuf.input_types = getlist(NAME_SIMPLE, LP_WS, LP_SEP);
+ prp->printer_types = getlist(NAME_UNKNOWN, LP_WS, LP_SEP);
+ prp->input_types = getlist(NAME_SIMPLE, LP_WS, LP_SEP);
#if defined(CAN_DO_MODULES)
- prbuf.modules = getlist(NAME_DEFAULT, LP_WS, LP_SEP);
+ prp->modules = getlist(NAME_DEFAULT, LP_WS, LP_SEP);
#endif
/*
@@ -184,81 +185,81 @@ getprinter(char *name)
if ((pp = getlist(p, LP_WS, ":"))) {
if (pp[0] != NULL) {
if (strcmp(pp[0], NAME_OPTIONAL) == 0)
- prbuf.banner = BAN_OPTIONAL;
+ prp->banner = BAN_OPTIONAL;
else if (strcmp(pp[0], NAME_OFF) == 0)
- prbuf.banner = BAN_NEVER;
+ prp->banner = BAN_NEVER;
else if (strcmp(pp[0], NAME_ON) == 0)
- prbuf.banner = BAN_ALWAYS;
+ prp->banner = BAN_ALWAYS;
else /* default to the LP default */
- prbuf.banner = BAN_ALWAYS;
+ prp->banner = BAN_ALWAYS;
}
if (pp[1] && CS_STREQU(pp[1], NAME_ALWAYS))
- prbuf.banner |= BAN_ALWAYS;
+ prp->banner |= BAN_ALWAYS;
freelist (pp);
}
break;
case PR_LOGIN:
- prbuf.login = LOG_IN;
+ prp->login = LOG_IN;
break;
case PR_CPI:
- prbuf.cpi = getcpi(p);
+ prp->cpi = getcpi(p);
break;
case PR_LPI:
- prbuf.lpi = getsdn(p);
+ prp->lpi = getsdn(p);
break;
case PR_LEN:
- prbuf.plen = getsdn(p);
+ prp->plen = getsdn(p);
break;
case PR_WIDTH:
- prbuf.pwid = getsdn(p);
+ prp->pwid = getsdn(p);
break;
case PR_CS:
- ppp = &(prbuf.char_sets);
+ ppp = &(prp->char_sets);
goto CharStarStar;
case PR_ITYPES:
- ppp = &(prbuf.input_types);
+ ppp = &(prp->input_types);
CharStarStar: if (*ppp)
freelist (*ppp);
*ppp = getlist(p, LP_WS, LP_SEP);
break;
case PR_DEV:
- pp = &(prbuf.device);
+ pp = &(prp->device);
goto CharStar;
case PR_DIAL:
- pp = &(prbuf.dial_info);
+ pp = &(prp->dial_info);
goto CharStar;
case PR_RECOV:
- pp = &(prbuf.fault_rec);
+ pp = &(prp->fault_rec);
goto CharStar;
case PR_INTFC:
- pp = &(prbuf.interface);
+ pp = &(prp->interface);
goto CharStar;
case PR_PTYPE:
- ppp = &(prbuf.printer_types);
+ ppp = &(prp->printer_types);
goto CharStarStar;
case PR_REMOTE:
- pp = &(prbuf.remote);
+ pp = &(prp->remote);
goto CharStar;
case PR_SPEED:
- pp = &(prbuf.speed);
+ pp = &(prp->speed);
goto CharStar;
case PR_STTY:
- pp = &(prbuf.stty);
+ pp = &(prp->stty);
CharStar: if (*pp)
Free (*pp);
*pp = Strdup(p);
@@ -266,18 +267,18 @@ CharStar: if (*pp)
#if defined(CAN_DO_MODULES)
case PR_MODULES:
- ppp = &(prbuf.modules);
+ ppp = &(prp->modules);
goto CharStarStar;
#endif
case PR_OPTIONS:
- ppp = &(prbuf.options);
+ ppp = &(prp->options);
goto CharStarStar;
break;
case PR_PPD:
{
- pp = &(prbuf.ppd);
+ pp = &(prp->ppd);
goto CharStar;
}
}
@@ -286,7 +287,7 @@ CharStar: if (*pp)
if (errno != 0) {
int save_errno = errno;
- freeprinter (&prbuf);
+ freeprinter (prp);
close(fd);
errno = save_errno;
return (0);
@@ -296,11 +297,11 @@ CharStar: if (*pp)
/*
* Get the printer description (if it exists).
*/
- if (!(path = getprinterfile(prbuf.name, COMMENTFILE)))
+ if (!(path = getprinterfile(prp->name, COMMENTFILE)))
return (0);
- if (!(prbuf.description = loadstring(path)) && errno != ENOENT) {
+ if (!(prp->description = loadstring(path)) && errno != ENOENT) {
Free (path);
- freeprinter (&prbuf);
+ freeprinter (prp);
return (0);
}
Free (path);
@@ -310,7 +311,7 @@ CharStar: if (*pp)
* read it because of access permission UNLESS we're "root"
* or "lp"
*/
- if (!(pa = getalert(Lp_A_Printers, prbuf.name))) {
+ if (!(pa = getalert(Lp_A_Printers, prp->name))) {
if (
errno != ENOENT
&& (
@@ -319,18 +320,18 @@ CharStar: if (*pp)
|| STREQU(getname(), LPUSER) /* we be lp */
)
) {
- freeprinter (&prbuf);
+ freeprinter (prp);
return (0);
}
} else
- prbuf.fault_alert = *pa;
+ prp->fault_alert = *pa;
/*
* Now go through the structure and see if we have
* anything strange.
*/
- if (!okprinter(prbuf.name, &prbuf, 0)) {
- freeprinter (&prbuf);
+ if (!okprinter(prp->name, prp, 0)) {
+ freeprinter (prp);
errno = EBADF;
return (0);
}
@@ -339,22 +340,22 @@ CharStar: if (*pp)
* Just in case somebody tried to pull a fast one
* by giving a printer type header by itself....
*/
- if (!prbuf.printer_types)
- prbuf.printer_types = getlist(NAME_UNKNOWN, LP_WS, LP_SEP);
+ if (!prp->printer_types)
+ prp->printer_types = getlist(NAME_UNKNOWN, LP_WS, LP_SEP);
/*
* If there are more than one printer type, then we can't
* have any input types, except perhaps ``simple''.
*/
if (
- lenlist(prbuf.printer_types) > 1
- && prbuf.input_types
+ lenlist(prp->printer_types) > 1
+ && prp->input_types
&& (
- lenlist(prbuf.input_types) > 1
- || !STREQU(NAME_SIMPLE, *prbuf.input_types)
+ lenlist(prp->input_types) > 1
+ || !STREQU(NAME_SIMPLE, *prp->input_types)
)
) {
- freeprinter (&prbuf);
+ freeprinter (prp);
badprinter = BAD_ITYPES;
errno = EBADF;
return (0);
@@ -365,10 +366,10 @@ CharStar: if (*pp)
* be ``unknown''.
*/
if (
- lenlist(prbuf.printer_types) > 1
- && searchlist(NAME_UNKNOWN, prbuf.printer_types)
+ lenlist(prp->printer_types) > 1
+ && searchlist(NAME_UNKNOWN, prp->printer_types)
) {
- freeprinter (&prbuf);
+ freeprinter (prp);
badprinter = BAD_PTYPES;
errno = EBADF;
return (0);
@@ -378,15 +379,15 @@ CharStar: if (*pp)
* All the printer types had better agree on whether the
* printer takes print wheels!
*/
- prbuf.daisy = -1;
- for (pp = prbuf.printer_types; *pp; pp++) {
+ prp->daisy = -1;
+ for (pp = prp->printer_types; *pp; pp++) {
tidbit (*pp, "daisy", &daisy);
if (daisy == -1)
daisy = 0;
- if (prbuf.daisy == -1)
- prbuf.daisy = daisy;
- else if (prbuf.daisy != daisy) {
- freeprinter (&prbuf);
+ if (prp->daisy == -1)
+ prp->daisy = daisy;
+ else if (prp->daisy != daisy) {
+ freeprinter (prp);
badprinter = BAD_DAISY;
errno = EBADF;
return (0);
@@ -397,7 +398,7 @@ CharStar: if (*pp)
* Help out those who are still using the obsolete
* "printer_type" member.
*/
- prbuf.printer_type = Strdup(*prbuf.printer_types);
+ prp->printer_type = Strdup(*prp->printer_types);
- return (&prbuf);
+ return (prp);
}
diff --git a/usr/src/cmd/lp/lib/printers/printwheels.c b/usr/src/cmd/lp/lib/printers/printwheels.c
index 4ba754be71..e553404fc4 100644
--- a/usr/src/cmd/lp/lib/printers/printwheels.c
+++ b/usr/src/cmd/lp/lib/printers/printwheels.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.
@@ -19,10 +18,12 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
@@ -54,7 +55,7 @@ getpwheel (name)
{
static long lastdir = -1;
- static PWHEEL pwheel;
+ PWHEEL *pwp;
register FALERT *pa;
@@ -91,10 +92,11 @@ getpwheel (name)
return (0);
}
- pwheel.alert = *pa;
- pwheel.name = Strdup(name);
+ pwp = calloc(1, sizeof (*pwp));
+ pwp->alert = *pa;
+ pwp->name = Strdup(name);
- return (&pwheel);
+ return (pwp);
}
/**
@@ -241,5 +243,7 @@ freepwheel (ppw)
Free (ppw->name);
if (ppw->alert.shcmd)
Free (ppw->alert.shcmd);
+ Free (ppw);
+
return;
}
diff --git a/usr/src/cmd/lp/lib/requests/freerequest.c b/usr/src/cmd/lp/lib/requests/freerequest.c
index 820c52d48a..cff15480ac 100644
--- a/usr/src/cmd/lp/lib/requests/freerequest.c
+++ b/usr/src/cmd/lp/lib/requests/freerequest.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.
@@ -19,11 +18,17 @@
*
* CDDL HEADER END
*/
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
-#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "sys/types.h"
@@ -70,5 +75,7 @@ freerequest (reqbufp)
Free (reqbufp->input_type);
if (reqbufp->user)
Free (reqbufp->user);
+ Free (reqbufp);
+
return;
}
diff --git a/usr/src/cmd/lp/lib/requests/getrequest.c b/usr/src/cmd/lp/lib/requests/getrequest.c
index 1058bb34b1..7aa5933395 100644
--- a/usr/src/cmd/lp/lib/requests/getrequest.c
+++ b/usr/src/cmd/lp/lib/requests/getrequest.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.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,7 +28,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.14 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "stdio.h"
@@ -59,7 +59,7 @@ getrequest (file)
char *file;
#endif
{
- static REQUEST reqbuf;
+ REQUEST *reqp;
char buf[BUFSIZ],
*path,
@@ -105,22 +105,9 @@ getrequest (file)
}
Free (path);
- reqbuf.copies = 1;
- reqbuf.destination = 0;
- reqbuf.file_list = 0;
- reqbuf.form = 0;
- reqbuf.actions = 0;
- reqbuf.alert = 0;
- reqbuf.options = 0;
- reqbuf.priority = -1;
- reqbuf.pages = 0;
- reqbuf.charset = 0;
- reqbuf.modes = 0;
- reqbuf.title = 0;
- reqbuf.input_type = 0;
- reqbuf.user = 0;
- reqbuf.outcome = 0;
- reqbuf.version = VERSION_OLD_LP;
+ reqp = calloc(sizeof (*reqp), 1);
+ reqp->copies = 1;
+ reqp->priority = -1;
errno = 0;
while (fdgets(buf, BUFSIZ, fd)) {
@@ -152,89 +139,85 @@ getrequest (file)
switch (fld) {
case RQ_COPIES:
- reqbuf.copies = atoi(p);
+ reqp->copies = atoi(p);
break;
case RQ_DEST:
- reqbuf.destination = Strdup(p);
+ reqp->destination = Strdup(p);
break;
case RQ_FILE:
- appendlist (&reqbuf.file_list, p);
+ appendlist (&reqp->file_list, p);
break;
case RQ_FORM:
if (!STREQU(p, NAME_ANY))
- reqbuf.form = Strdup(p);
+ reqp->form = Strdup(p);
break;
case RQ_HANDL:
if (STREQU(p, NAME_RESUME))
- reqbuf.actions |= ACT_RESUME;
+ reqp->actions |= ACT_RESUME;
else if (STREQU(p, NAME_HOLD))
- reqbuf.actions |= ACT_HOLD;
+ reqp->actions |= ACT_HOLD;
else if (STREQU(p, NAME_IMMEDIATE))
- reqbuf.actions |= ACT_IMMEDIATE;
+ reqp->actions |= ACT_IMMEDIATE;
break;
case RQ_NOTIFY:
if (STREQU(p, "M"))
- reqbuf.actions |= ACT_MAIL;
+ reqp->actions |= ACT_MAIL;
else if (STREQU(p, "W"))
- reqbuf.actions |= ACT_WRITE;
+ reqp->actions |= ACT_WRITE;
else if (STREQU(p, "N"))
- reqbuf.actions |= ACT_NOTIFY;
+ reqp->actions |= ACT_NOTIFY;
else
- reqbuf.alert = Strdup(p);
+ reqp->alert = Strdup(p);
break;
case RQ_OPTS:
- reqbuf.options = Strdup(p);
+ reqp->options = Strdup(p);
break;
case RQ_PRIOR:
- reqbuf.priority = atoi(p);
+ reqp->priority = atoi(p);
break;
case RQ_PAGES:
- reqbuf.pages = Strdup(p);
+ reqp->pages = Strdup(p);
break;
case RQ_CHARS:
if (!STREQU(p, NAME_ANY))
- reqbuf.charset = Strdup(p);
+ reqp->charset = Strdup(p);
break;
case RQ_TITLE:
- reqbuf.title = Strdup(p);
+ reqp->title = Strdup(p);
break;
case RQ_MODES:
- reqbuf.modes = Strdup(p);
+ reqp->modes = Strdup(p);
break;
case RQ_TYPE:
- reqbuf.input_type = Strdup(p);
+ reqp->input_type = Strdup(p);
break;
case RQ_USER:
- reqbuf.user = Strdup(p);
+ reqp->user = Strdup(p);
break;
case RQ_RAW:
- reqbuf.actions |= ACT_RAW;
+ reqp->actions |= ACT_RAW;
break;
case RQ_FAST:
- reqbuf.actions |= ACT_FAST;
+ reqp->actions |= ACT_FAST;
break;
case RQ_STAT:
- reqbuf.outcome = (ushort)strtol(p, (char **)0, 16);
- break;
-
- case RQ_VERSION:
- reqbuf.version = atoi(p);
+ reqp->outcome = (ushort)strtol(p, (char **)0, 16);
break;
}
@@ -254,13 +237,13 @@ getrequest (file)
* anything strange.
*/
if (
- reqbuf.copies <= 0
- || !reqbuf.file_list || !*(reqbuf.file_list)
- || reqbuf.priority < -1 || 39 < reqbuf.priority
- || STREQU(reqbuf.input_type, NAME_ANY)
- || STREQU(reqbuf.input_type, NAME_TERMINFO)
+ reqp->copies <= 0
+ || !reqp->file_list || !*(reqp->file_list)
+ || reqp->priority < -1 || 39 < reqp->priority
+ || STREQU(reqp->input_type, NAME_ANY)
+ || STREQU(reqp->input_type, NAME_TERMINFO)
) {
- freerequest (&reqbuf);
+ freerequest (reqp);
errno = EBADF;
return (0);
}
@@ -268,16 +251,16 @@ getrequest (file)
/*
* Guarantee some return values won't be null or empty.
*/
- if (!reqbuf.destination || !*reqbuf.destination) {
- if (reqbuf.destination)
- Free (reqbuf.destination);
- reqbuf.destination = Strdup(NAME_ANY);
+ if (!reqp->destination || !*reqp->destination) {
+ if (reqp->destination)
+ Free (reqp->destination);
+ reqp->destination = Strdup(NAME_ANY);
}
- if (!reqbuf.input_type || !*reqbuf.input_type) {
- if (reqbuf.input_type)
- Free (reqbuf.input_type);
- reqbuf.input_type = Strdup(NAME_SIMPLE);
+ if (!reqp->input_type || !*reqp->input_type) {
+ if (reqp->input_type)
+ Free (reqp->input_type);
+ reqp->input_type = Strdup(NAME_SIMPLE);
}
- return (&reqbuf);
+ return (reqp);
}
diff --git a/usr/src/cmd/lp/lib/requests/putrequest.c b/usr/src/cmd/lp/lib/requests/putrequest.c
index 0cf5633f7a..a426562057 100644
--- a/usr/src/cmd/lp/lib/requests/putrequest.c
+++ b/usr/src/cmd/lp/lib/requests/putrequest.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 1997 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,7 +27,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.11 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "stdio.h"
@@ -219,10 +218,6 @@ putrequest (file, reqbufp)
(void)fdprintf(fd, "%s%#6.4x\n", HEAD, reqbufp->outcome);
break;
- case RQ_VERSION:
- (void)fdprintf(fd, "%s%d\n", HEAD, reqbufp->version);
- break;
-
}
close(fd);
diff --git a/usr/src/cmd/lp/lib/secure/secure.c b/usr/src/cmd/lp/lib/secure/secure.c
index 09796dec5e..81fac7b656 100644
--- a/usr/src/cmd/lp/lib/secure/secure.c
+++ b/usr/src/cmd/lp/lib/secure/secure.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
@@ -27,7 +28,7 @@
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.14 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "string.h"
@@ -45,7 +46,7 @@
SECURE *
getsecure(char *file)
{
- static SECURE secbuf;
+ SECURE *secp;
char buf[BUFSIZ],
*path;
@@ -68,7 +69,9 @@ getsecure(char *file)
}
Free (path);
- secbuf.user = 0;
+ secp = calloc(sizeof (*secp), 1);
+
+ secp->user = 0;
errno = 0;
for (
fld = 0;
@@ -79,42 +82,38 @@ getsecure(char *file)
switch (fld) {
case SC_REQID:
- secbuf.req_id = Strdup(buf);
+ secp->req_id = Strdup(buf);
break;
case SC_UID:
- secbuf.uid = (uid_t)atol(buf);
+ secp->uid = (uid_t)atol(buf);
break;
case SC_USER:
- secbuf.user = Strdup(buf);
+ secp->user = Strdup(buf);
break;
case SC_GID:
- secbuf.gid = (gid_t)atol(buf);
+ secp->gid = (gid_t)atol(buf);
break;
case SC_SIZE:
- secbuf.size = (size_t)atol(buf);
+ secp->size = (size_t)atol(buf);
break;
case SC_DATE:
- secbuf.date = (time_t)atol(buf);
- break;
-
- case SC_SYSTEM:
- secbuf.system = Strdup(buf);
+ secp->date = (time_t)atol(buf);
break;
case SC_SLABEL:
- secbuf.slabel = Strdup(buf);
+ secp->slabel = Strdup(buf);
break;
}
}
if (errno != 0 || fld != SC_MAX) {
int save_errno = errno;
- freesecure (&secbuf);
+ freesecure (secp);
close(fd);
errno = save_errno;
return (0);
@@ -126,18 +125,18 @@ getsecure(char *file)
* anything strange.
*/
if (
- secbuf.uid > MAXUID || secbuf.uid < -1
- || !secbuf.user
- || secbuf.gid > MAXUID || secbuf.gid < -1
- || secbuf.size == 0
- || secbuf.date <= 0
+ secp->uid > MAXUID || secp->uid < -1
+ || !secp->user
+ || secp->gid > MAXUID || secp->gid < -1
+ || secp->size == 0
+ || secp->date <= 0
) {
- freesecure (&secbuf);
+ freesecure (secp);
errno = EBADF;
return (0);
}
- return (&secbuf);
+ return (secp);
}
/**
@@ -200,10 +199,6 @@ putsecure(char *file, SECURE *secbufp)
(void)fdprintf(fd, "%ld\n", secbufp->date);
break;
- case SC_SYSTEM:
- (void)fdprintf(fd, "%s\n", secbufp->system);
- break;
-
case SC_SLABEL:
if (secbufp->slabel == NULL) {
if (is_system_labeled()) {
@@ -268,8 +263,8 @@ freesecure(SECURE *secbufp)
Free (secbufp->req_id);
if (secbufp->user)
Free (secbufp->user);
- if (secbufp->system)
- Free (secbufp->system);
+ Free (secbufp);
+
return;
}
diff --git a/usr/src/cmd/print/Makefile b/usr/src/cmd/print/Makefile
index 27ccdf43ad..66edd4fa74 100644
--- a/usr/src/cmd/print/Makefile
+++ b/usr/src/cmd/print/Makefile
@@ -37,13 +37,11 @@ PRINT_SUBDIRS = \
lpset \
conv_fix \
printer-info \
- gateway \
bsd-sysv-commands
SUBDIRS = $(PRINT_SUBDIRS) $(JAVA_SUBDIRS)
-ROOTDIRS = $(ROOTLIB)/print \
- $(ROOTLIB)/print/bsd-adaptor
+ROOTDIRS = $(ROOTLIB)/print
all := TARGET= all
install := TARGET= install
diff --git a/usr/src/cmd/print/bsd-sysv-commands/Makefile b/usr/src/cmd/print/bsd-sysv-commands/Makefile
index ee16f07879..6599510e04 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/Makefile
+++ b/usr/src/cmd/print/bsd-sysv-commands/Makefile
@@ -25,16 +25,20 @@
# ident "%Z%%M% %I% %E% SMI"
#
+include ../Makefile.sp
+
UCBPROGS = lpr lpq lprm lpc
BINPROGS = lp lpstat cancel enable disable $(UCBPROGS)
SBINPROGS = accept reject lpmove
+LIBPRINTPROGS = in.lpd
-OBJS = $(BINPROGS:=.o) $(SBINPROGS:=.o) common.o
+OBJS = $(BINPROGS:=.o) $(SBINPROGS:=.o) $(LIBPRINTPROGS:=.o) common.o
ROOTBINPROGS = $(BINPROGS:%=$(ROOTBIN)/%)
ROOTUSRSBINPROGS = $(SBINPROGS:%=$(ROOTUSRSBIN)/%)
+ROOTLIBPRINTPROGS = $(LIBPRINTPROGS:%=$(ROOTLIBPRINT)/%)
FILEMODE = 0555
@@ -42,13 +46,20 @@ OWNER = root
include ../../Makefile.cmd
+MANIFEST= rfc1179.xml
+ROOTMANIFESTDIR= $(ROOTSVCAPPLICATIONPRINT)
+$(ROOTMANIFEST) := FILEMODE= 444
+
CFLAGS += $(CCVERBOSE)
CPPFLAGS += -I.
CPPFLAGS += -I../../../lib/print/libpapi-common/common
+CPPFLAGS += -I$(ROOT)/usr/include
LDLIBS += -lpapi -lc
+in.lpd:= CFLAGS += -DSOLARIS_PRIVATE_POST_0_9
+in.lpd:= LDLIBS += -lnsl -lsocket
# each program needs common.o as well
-$(BINPROGS) $(SBINPROGS): $(BINPROGS:%=%.c) $(SBINPROGS:%=%.c) common.o
+$(BINPROGS) $(SBINPROGS) $(LIBPRINTPROGS): $(BINPROGS:%=%.c) $(SBINPROGS:%=%.c) $(LIBPRINTPROGS:%=%.c) common.o
$(LINK.c) -o $@ $@.c common.o $(LDLIBS)
$(POST_PROCESS)
@@ -72,12 +83,15 @@ $(ROOTUSRLIBSYMLINKS):
all: $(BINPROGS) $(SBINPROGS)
install: $(BINPROGS) $(SBINPROGS) $(ROOTBINPROGS) $(ROOTUSRSBINPROGS) \
+ $(ROOTLIBPRINT) $(ROOTLIBPRINTPROGS) $(ROOTMANIFEST) \
$(ROOTUCBSYMLINKS) $(ROOTUSRLIBSYMLINKS)
+check: $(CHKMANIFEST)
+
clean:
$(RM) $(OBJS)
-CLOBBERFILES += $(BINPROGS) $(SBINPROGS)
+CLOBBERFILES += $(BINPROGS) $(SBINPROGS) $(LIBPRINTPROGS)
lint:
diff --git a/usr/src/cmd/print/bsd-sysv-commands/common.c b/usr/src/cmd/print/bsd-sysv-commands/common.c
index 5d70752563..73483957ff 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/common.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/common.c
@@ -32,6 +32,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <alloca.h>
#include <string.h>
#include <libintl.h>
@@ -74,6 +77,41 @@ match_job(int id, char *user, int ac, char *av[])
return (-1);
}
+static struct {
+ char *mime_type;
+ char *lp_type;
+} type_map[] = {
+ { "text/plain", "simple" },
+ { "application/octet-stream", "raw" },
+ { "application/octet-stream", "any" },
+ { "application/postscript", "postscript" },
+ { "application/postscript", "ps" },
+ { "application/x-cif", "cif" },
+ { "application/x-dvi", "dvi" },
+ { "application/x-plot", "plot" },
+ { "application/x-ditroff", "troff" },
+ { "application/x-troff", "otroff" },
+ { "application/x-pr", "pr" },
+ { "application/x-fortran", "fortran" },
+ { "application/x-raster", "raster" },
+ { NULL, NULL}
+};
+
+char *
+lp_type_to_mime_type(char *lp_type)
+{
+ int i;
+
+ if (lp_type == NULL)
+ return ("application/octet-stream");
+
+ for (i = 0; type_map[i].lp_type != NULL; i++)
+ if (strcasecmp(type_map[i].lp_type, lp_type) == 0)
+ return (type_map[i].mime_type);
+
+ return (lp_type);
+}
+
/*
* to support job/printer status
*/
@@ -157,6 +195,8 @@ print_job_line(FILE *fp, int count, papi_job_t job, int fmt, int ac, char *av[])
"job-id", &id);
(void) papiAttributeListGetString(list, NULL,
"job-originating-user-name", &user);
+ (void) papiAttributeListGetString(list, NULL,
+ "job-originating-host-name", &host);
/* if we are looking and it doesn't match, return early */
if ((ac > 0) && (match_job(id, user, ac, av) < 0))
@@ -226,9 +266,9 @@ berkeley_queue_report(papi_service_t svc, FILE *fp, char *dest, int fmt,
papi_job_t *jobs = NULL;
char *pattrs[] = { "printer-name", "printer-state",
"printer-state-reasons", NULL };
- char *jattrs[] = {
- "job-name", "job-octets", "job-k-octets",
- "job-originating-user-name", "job-id",
+ char *jattrs[] = { "job-name", "job-octets", "job-k-octets", "job-id",
+ "job-originating-user-name",
+ "job-originating-host-name",
"number-of-intervening-jobs", NULL };
int num_jobs = 0;
@@ -371,6 +411,35 @@ jobSubmitSTDIN(papi_service_t svc, char *printer, papi_attribute_t **list,
return (status);
}
+/*
+ * is_postscript() will detect if the file passed in contains postscript
+ * data. A one is returned if the file contains postscript, zero is returned
+ * if the file is not postscript, and -1 is returned if an error occurs
+ */
+#define PS_MAGIC "%!"
+#define PC_PS_MAGIC "^D%!"
+int
+is_postscript(const char *file)
+{
+ char buf[3];
+ int fd;
+
+ if ((fd = open(file, O_RDONLY)) < 0)
+ return (-1);
+
+ if (read(fd, buf, sizeof (buf)) < 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))
+ return (1);
+ else
+ return (0);
+}
+
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 92a2b5b66c..e8169ed0da 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/common.h
+++ b/usr/src/cmd/print/bsd-sysv-commands/common.h
@@ -56,6 +56,8 @@ extern papi_status_t jobSubmitSTDIN(papi_service_t svc, char *printer,
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 cli_auth_callback(papi_service_t svc, void *app_data);
diff --git a/usr/src/cmd/print/bsd-sysv-commands/in.lpd.c b/usr/src/cmd/print/bsd-sysv-commands/in.lpd.c
index 465189daf1..18487c51d8 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/in.lpd.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/in.lpd.c
@@ -31,13 +31,25 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <syslog.h>
#include <libintl.h>
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <sys/systeminfo.h>
#include <papi.h>
+#include <uri.h>
#include "common.h"
#define ACK(fp) { (void) fputc('\0', fp); (void) fflush(fp); }
@@ -48,7 +60,61 @@
* code assumes a BSD Socket interface to the networking side.
*/
-void
+static char *
+remote_host_name(FILE *fp)
+{
+ struct hostent *hp;
+ struct sockaddr_in6 peer;
+ socklen_t peer_len = sizeof (peer);
+ int fd = fileno(fp);
+ int error_num;
+ char myname[MAXHOSTNAMELEN], tmp_buf[INET6_ADDRSTRLEN];
+ char *hostname;
+
+ /* who is our peer ? */
+ if (getpeername(fd, (struct sockaddr *)&peer, &peer_len) < 0) {
+ if ((errno != ENOTSOCK) && (errno != EINVAL))
+ return (NULL);
+ else
+ return (strdup("localhost"));
+ }
+
+ /* get their name or return a string containing their address */
+ if ((hp = getipnodebyaddr((const char *)&peer.sin6_addr,
+ sizeof (struct in6_addr), AF_INET6,
+ &error_num)) == NULL) {
+ return (strdup(inet_ntop(peer.sin6_family,
+ &peer.sin6_addr, tmp_buf, sizeof (tmp_buf))));
+ }
+
+ /* is it "localhost" ? */
+ if (strcasecmp(hp->h_name, "localhost") == 0)
+ return (strdup("localhost"));
+
+ /* duplicate the name because gethostbyXXXX() is not reentrant */
+ hostname = strdup(hp->h_name);
+ (void) sysinfo(SI_HOSTNAME, myname, sizeof (myname));
+
+ /* is it from one of my addresses ? */
+ if ((hp = getipnodebyname(myname, AF_INET6, AI_ALL|AI_V4MAPPED,
+ &error_num)) != NULL) {
+ struct in6_addr **tmp = (struct in6_addr **)hp->h_addr_list;
+ int i = 0;
+
+ while (tmp[i] != NULL) {
+ if (memcmp(tmp[i++], &peer.sin6_addr, hp->h_length)
+ == 0) {
+ free(hostname);
+ return (strdup("localhost"));
+ }
+ }
+ }
+
+ /* It must be someone else */
+ return (hostname);
+}
+
+static void
fatal(FILE *fp, char *fmt, ...)
{
va_list ap;
@@ -57,62 +123,440 @@ fatal(FILE *fp, char *fmt, ...)
vsyslog(LOG_DEBUG, fmt, ap);
vfprintf(fp, fmt, ap);
va_end(ap);
+ exit(1);
}
static void
-cleanup(char **files)
+cleanup(char ***files, char **cf)
{
- if (files != NULL) {
+ if (*files != NULL) {
int i;
- for (i = 0; files[i] != NULL; i++)
- unlink(files[i]);
+ for (i = 0; (*files)[i] != NULL; i++) {
+ (void) unlink((*files)[i]);
+ free((*files)[i]);
+ }
+ free(*files);
+ *files = NULL;
+ }
+
+ if (*cf != NULL) {
+ free(*cf);
+ *cf = NULL;
}
}
-static void
-berkeley_receive_files(papi_service_t svc, FILE *ifp, FILE *ofp)
+static papi_attribute_t **
+parse_cf(papi_service_t svc, char *cf, char **files)
{
- char line[BUFSIZ];
- char **files = NULL; /* the job data files */
+ papi_attribute_t **list = NULL;
+ char previous = NULL,
+ *entry,
+ *s,
+ text[BUFSIZ];
+ int count = 0,
+ copies_set = 0,
+ copies = 0;
+
+ for (entry = strtok(cf, "\n"); entry != NULL;
+ entry = strtok(NULL, "\n")) {
+ char *format = NULL;
+
+ /* count the copies */
+ if ((entry[0] >= 'a') && (entry[0] <= 'z') &&
+ (copies_set == 0) && (previous == entry[0]))
+ copies++;
+ else if ((previous >= 'a') && (previous <= 'z'))
+ copies_set = 1;
+ previous = entry[0];
+
+ /* process the control message */
+ switch (entry[0]) {
+ /* RFC-1179 options */
+ case 'J': /* RFC-1179 Banner Job Name */
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "job-name", ++entry);
+ break;
+ case 'C': /* RFC-1179 Banner Class Name */
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "rfc-1179-class", ++entry);
+ break;
+ case 'L': /* RFC-1179 Banner toggle */
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "job-sheets", "standard");
+ break;
+ case 'T': /* RFC-1179 Title (pr) */
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "pr-title", ++entry);
+ break;
+ case 'H': /* RFC-1179 Host */
+ /*
+ * use the host as known by us, not by them
+ *
+ * papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ * "job-originating-host-name", ++entry);
+ */
+ break;
+ case 'P': /* RFC-1179 User */
+ ++entry;
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "requesting-user-name", entry);
+ papiServiceSetUserName(svc, entry);
+ break;
+ case 'M': /* RFC-1179 Mail to User */
+ papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL,
+ "rfc-1179-mail", 1);
+ break;
+ case 'W': /* RFC-1179 Width (pr) */
+ papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL,
+ "pr-width", atoi(++entry));
+ break;
+ case 'I': /* RFC-1179 Indent (pr) */
+ papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL,
+ "pr-indent", atoi(++entry));
+ break;
+ case 'N': /* RFC-1179 Filename */
+ /* could have HPUX extension embedded */
+ if (entry[1] != ' ') { /* real pathname */
+#ifdef DEBUG
+ papiAttributeListAddString(&list,
+ PAPI_ATTR_EXCL,
+ "flist", ++entry);
+#endif
+ } else if (entry[2] == 'O') /* HPUX lp -o options */
+ papiAttributeListFromString(&list,
+ PAPI_ATTR_APPEND, ++entry);
+ break;
+ case 'U': /* RFC-1179 Unlink */
+ break; /* ignored */
+ case '1': /* RFC-1179 TROFF Font R */
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "rfc-1179-font-r", ++entry);
+ break;
+ case '2': /* RFC-1179 TROFF Font I */
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "rfc-1179-font-i", ++entry);
+ break;
+ case '3': /* RFC-1179 TROFF Font B */
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "rfc-1179-font-b", ++entry);
+ break;
+ case '4': /* RFC-1179 TROFF Font S */
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "rfc-1179-font-s", ++entry);
+ break;
+ case 'f': /* RFC-1179 ASCII file (print) */
+ format = "text/plain";
+ if (is_postscript(files[0]) == 1)
+ format = "application/postscript";
+ break;
+ case 'l': /* RFC-1179 CATV file (print) */
+ format = "application/octet-stream";
+ if (is_postscript(files[0]) == 1)
+ format = "application/postscript";
+ break;
+ case 'o': /* RFC-1179 Postscript file (print) */
+ format = "application/postscript";
+ break;
+ case 'p': /* RFC-1179 PR file (print) */
+ format = "application/x-pr";
+ papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL,
+ "pr-filter", 1);
+ break;
+ case 't': /* RFC-1179 TROFF file (print) */
+ format = "application/x-troff";
+ break;
+ case 'n': /* RFC-1179 DITROFF file (print) */
+ format = "application/x-ditroff";
+ break;
+ case 'd': /* RFC-1179 DVI file (print) */
+ format = "application/x-dvi";
+ break;
+ case 'g': /* RFC-1179 GRAPH file (print) */
+ format = "application/x-plot";
+ break;
+ case 'c': /* RFC-1179 CIF file (print) */
+ format = "application/x-cif";
+ break;
+ case 'v': /* RFC-1179 RASTER file (print) */
+ format = "application/x-raster";
+ break;
+ case 'r': /* RFC-1179 FORTRAN file (print) */
+ format = "application/x-fortran";
+ break;
+ /* Sun Solaris Extensions */
+ case 'O':
+ ++entry;
+ do {
+ if (*entry != '"')
+ text[count++] = *entry;
+ } while (*entry++);
+ papiAttributeListFromString(&list, PAPI_ATTR_APPEND,
+ text);
+ break;
+ case '5':
+ ++entry;
+ switch (entry[0]) {
+ case 'f': /* Solaris form */
+ papiAttributeListAddString(&list,
+ PAPI_ATTR_EXCL,
+ "form", ++entry);
+ break;
+ case 'H': /* Solaris handling */
+ ++entry;
+ if (strcasecmp(entry, "hold") == 0)
+ papiAttributeListAddString(&list,
+ PAPI_ATTR_EXCL,
+ "job-hold-until", "indefinite");
+ else if (strcasecmp(entry, "release") == 0)
+ papiAttributeListAddString(&list,
+ PAPI_ATTR_EXCL,
+ "job-hold-until", "no-hold");
+ else if (strcasecmp(entry, "immediate") == 0)
+ papiAttributeListAddInteger(&list,
+ PAPI_ATTR_EXCL,
+ "job-priority", 100);
+ else
+ papiAttributeListAddString(&list,
+ PAPI_ATTR_EXCL,
+ "job-hold-until", entry);
+ break;
+ case 'p': /* Solaris notification */
+ papiAttributeListAddBoolean(&list,
+ PAPI_ATTR_EXCL, "rfc-1179-mail", 1);
+ break;
+ case 'P': /* Solaris page list */
+ papiAttributeListAddString(&list,
+ PAPI_ATTR_EXCL,
+ "page-ranges", ++entry);
+ break;
+ case 'q': { /* Solaris priority */
+ int i = atoi(optarg);
+
+ i = 99 * (39 - i) / 39 + 1;
+ if ((i < 1) || (i > 100))
+ i = 50;
+ papiAttributeListAddInteger(&list,
+ PAPI_ATTR_EXCL, "priority", i);
+ }
+ break;
+ case 'S': /* Solaris character set */
+ papiAttributeListAddString(&list,
+ PAPI_ATTR_EXCL, "lp-charset",
+ ++entry);
+ break;
+ case 'T': /* Solaris type */
+ format = lp_type_to_mime_type(++entry);
+ break;
+ case 'y': /* Solaris mode */
+ papiAttributeListAddString(&list,
+ PAPI_ATTR_APPEND, "lp-modes", ++entry);
+ break;
+ default:
+ syslog(LOG_INFO|LOG_DEBUG,
+ "Warning: cf message (%s) ignored",
+ entry);
+ break;
+ }
+ break;
+ /* Undefined Extensions: SCO, Ultrix, AIX, ... */
+
+ default:
+ syslog(LOG_INFO|LOG_DEBUG,
+ "Warning: cf message (%s) ignored", entry);
+ break;
+ }
+
+ if (format != NULL)
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "document-format", format);
+ }
- /* This should actually implement transfer job from RFC-1179 */
+ papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL,
+ "copies", ++copies);
+ papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
+ "job-sheets", "none");
+
+ return (list);
+}
+
+static papi_status_t
+submit_job(papi_service_t svc, FILE *ifp, char *printer, char *cf, char **files)
+{
+ papi_attribute_t **list = NULL;
+ papi_status_t status;
+ papi_job_t job = NULL;
+ char *format = "";
+
+ if ((list = parse_cf(svc, cf, files)) != NULL) {
+ /* use the host as known by us, not by them */
+ char *host = remote_host_name(ifp);
+
+ if (host != NULL) {
+ papiAttributeListAddString(&list, PAPI_ATTR_REPLACE,
+ "job-originating-host-name", host);
+ free(host);
+ }
+ }
+
+ status = papiJobSubmit(svc, printer, list, NULL, files, &job);
+ syslog(LOG_DEBUG, "submit: %s", papiStatusString(status));
+ if (status != PAPI_OK) {
+ char *tmp = papiServiceGetStatusMessage(svc);
+
+ syslog(LOG_DEBUG, "submit-detail: %s", tmp ? tmp : "none");
+ }
+ papiJobFree(job);
+
+ return (status);
+}
+
+static char *
+receive_control_file(papi_service_t svc, FILE *ifp, FILE *ofp, int size)
+{
+ char *ptr, *cf_data;
+
+ if ((ptr = cf_data = calloc(1, size + 1)) == NULL) {
+ NACK(ofp);
+ return (NULL);
+ } else
+ ACK(ofp);
+
+ while (size > 0) {
+ int rc;
+
+ if (((rc = fread(ptr, 1, size, ifp)) == 0) &&
+ (feof(ifp) != 0)) {
+ free(cf_data);
+ return (NULL);
+ } else {
+ ptr += rc;
+ size -= rc;
+ }
+ }
+ syslog(LOG_DEBUG, "cf_data(%s)", cf_data);
+
+ if (fgetc(ifp) != 0) {
+ free(cf_data);
+ return (NULL);
+ }
+ ACK(ofp);
+
+ return (cf_data);
+}
+
+static char *
+receive_data_file(FILE *ifp, FILE *ofp, int size)
+{
+ char file[] = "lpdXXXXXX";
+ char buf[BUFSIZ];
+ int fd;
+
+ if ((fd = mkstemp(file)) < 0) {
+ NACK(ofp);
+ return (NULL);
+ } else
+ ACK(ofp);
+
+ while (size > 0) {
+ int rc = ((size > BUFSIZ) ? BUFSIZ : size);
+
+ if (((rc = fread(buf, 1, rc, ifp)) == 0) &&
+ (feof(ifp) != 0)) {
+ close(fd);
+ unlink(file);
+ return (NULL);
+ } else {
+ char *ptr = buf;
+
+ while (rc > 0) {
+ int wrc = write(fd, ptr, rc);
+
+ if (wrc < 0) {
+ close(fd);
+ unlink(file);
+ return(NULL);
+ }
+
+ ptr += wrc;
+ size -= wrc;
+ rc -= wrc;
+ }
+ }
+ }
+ close(fd);
+ if (fgetc(ifp) != 0) {
+ unlink(file);
+ return (NULL);
+ }
ACK(ofp);
- while (fgets(line, sizeof (line), ifp) != NULL) {
- switch (line[0]) {
+ return (strdup(file));
+}
+
+static papi_status_t
+berkeley_receive_files(papi_service_t svc, FILE *ifp, FILE *ofp, char *printer)
+{
+ papi_status_t status = PAPI_OK;
+ char *file, **files = NULL; /* the job data files */
+ char *cf = NULL;
+ char buf[BUFSIZ];
+
+ while (fgets(buf, sizeof (buf), ifp) != NULL) {
+ int size;
+
+ syslog(LOG_DEBUG, "XFER CMD: (%d)%s\n", buf[0], &buf[1]);
+#ifdef DEBUG /* translate [1-3]... messages to \[1-3] to run by hand */
+ if ((buf[0] > '0') && (buf[0] < '4'))
+ buf[0] -= '0';
+#endif
+ switch (buf[0]) {
case 0x01: /* Abort */
- cleanup(files);
+ cleanup(&files, &cf);
break;
- case 0x02: /* Receive control file */
-
+ case 0x02: { /* Receive control file */
+ cf = receive_control_file(svc, ifp, ofp, atoi(&buf[1]));
+ if (cf == NULL) {
+ cleanup(&files, &cf);
+ return (PAPI_BAD_REQUEST);
+ } else if (files != NULL) {
+ status = submit_job(svc, ifp, printer, cf,
+ files);
+ cleanup(&files, &cf);
+ }
+ }
break;
case 0x03: { /* Receive data file */
- char file[] = "lpdXXXXXX";
- int fd;
-
- fd = mkstemp(file);
-
- list_append(&files, strdup(file));
+ file = receive_data_file(ifp, ofp, atoi(&buf[1]));
+ if (file == NULL) {
+ cleanup(&files, &cf);
+ return (PAPI_TEMPORARY_ERROR);
+ }
+ list_append(&files, file);
}
break;
default:
+ cleanup(&files, &cf);
fatal(ofp, "protocol screwup");
- cleanup(files);
break;
}
}
- cleanup(files);
+ if ((cf != NULL) && (files != NULL))
+ status = submit_job(svc, ifp, printer, cf, files);
+
+ cleanup(&files, &cf);
+
+ return (status);
}
-static void
+static papi_status_t
berkeley_transfer_files(papi_service_t svc, FILE *ifp, FILE *ofp,
char *printer)
{
papi_status_t status;
papi_printer_t p = NULL;
- char *keys[] = { "printer-is-accepting", NULL };
+ char *keys[] = { "printer-is-accepting-jobs", NULL };
status = papiPrinterQuery(svc, printer, keys, NULL, &p);
if ((status == PAPI_OK) && (p != NULL)) {
@@ -120,18 +564,68 @@ berkeley_transfer_files(papi_service_t svc, FILE *ifp, FILE *ofp,
char accepting = PAPI_FALSE;
papiAttributeListGetBoolean(attrs, NULL,
- "printer-is-accepting", &accepting);
+ "printer-is-accepting-jobs", &accepting);
- if (accepting == PAPI_TRUE)
- berkeley_receive_files(svc, ifp, ofp);
- else
+ if (accepting == PAPI_TRUE) {
+ ACK(ofp);
+ status = berkeley_receive_files(svc, ifp, ofp, printer);
+ } else
NACK(ofp);
papiPrinterFree(p);
} else
NACK(ofp);
+
+ return (status);
+}
+
+static int
+cyclical_service_check(char *svc_name)
+{
+ papi_attribute_t **list;
+ char buf[BUFSIZ];
+ uri_t *uri = NULL;
+ char *s = NULL;
+
+ /* was there a printer? */
+ if (svc_name == NULL)
+ return (0);
+
+ if ((list = getprinterbyname(svc_name, NULL)) == NULL)
+ return (0); /* if it doesnt' resolve, we will fail later */
+
+ papiAttributeListGetString(list, NULL, "printer-uri-supported", &s);
+ if ((s == NULL) || (strcasecmp(svc_name, s) != 0))
+ return (0); /* they don't match */
+
+ /* is it in uri form? */
+ if (uri_from_string(s, &uri) < 0)
+ return (0);
+
+ if ((uri == NULL) || (uri->scheme == NULL) || (uri->host == NULL)) {
+ uri_free(uri);
+ return (0);
+ }
+
+ /* is it in lpd form? */
+ if (strcasecmp(uri->scheme, "lpd") != 0) {
+ uri_free(uri);
+ return (0);
+ }
+
+ /* is it the local host? */
+ sysinfo(SI_HOSTNAME, buf, sizeof (buf));
+ if ((strcasecmp(uri->host, "localhost") != 0) &&
+ (strcasecmp(uri->host, buf) != 0)) {
+ uri_free(uri);
+ return (0);
+ }
+
+ uri_free(uri);
+ return (1);
}
+
/*
* This is the entry point for this program. The program takes the
* following options:
@@ -148,20 +642,54 @@ main(int ac, char *av[])
int c;
char buf[BUFSIZ],
**args,
- *printer;
+ *printer,
+ *run_dir = "/var/run/in.lpd",
+ *run_user = NULL;
+ struct passwd *pw = NULL;
+ (void) chdir("/tmp"); /* run in /tmp by default */
openlog("bsd-gw", LOG_PID, LOG_LPR);
- while ((c = getopt(ac, av, "d")) != EOF)
+ while ((c = getopt(ac, av, "Ed:u:")) != EOF)
switch (c) {
case 'E':
encryption = PAPI_ENCRYPT_ALWAYS;
break;
- case 'd':
+ case 'd': /* run where they tell you */
+ run_dir = optarg;
+ break;
+ case 'u': /* run as */
+ run_user = optarg;
+ break;
default:
;
}
+ if (run_user != NULL) /* get the requested user info */
+ pw = getpwnam(run_user);
+
+ if (run_dir != NULL) { /* setup the run_dir */
+ (void) mkdir(run_dir, 0700);
+ if (pw != NULL)
+ (void) chown(run_dir, pw->pw_uid, pw->pw_gid);
+ }
+
+ if (pw != NULL) { /* run as the requested user */
+ syslog(LOG_DEBUG, "name: %s, uid: %d, gid: %d",
+ pw->pw_name, pw->pw_uid, pw->pw_gid);
+ initgroups(pw->pw_name, pw->pw_gid);
+ setgid(pw->pw_gid);
+ setuid(pw->pw_uid);
+ }
+
+ if (run_dir != NULL) /* move to the run_dir */
+ if (chdir(run_dir) < 0) {
+ syslog(LOG_DEBUG, "failed to chdir(%s)", run_dir);
+ exit(1);
+ }
+
+ syslog(LOG_DEBUG, "$CWD = %s", getwd(NULL));
+
if (fgets(buf, sizeof (buf), ifp) == NULL) {
if (feof(ifp) == 0)
syslog(LOG_ERR, "Error reading from connection: %s",
@@ -169,6 +697,13 @@ main(int ac, char *av[])
exit(1);
}
+ syslog(LOG_DEBUG, "CMD: (%d)%s\n", buf[0], &buf[1]);
+
+#ifdef DEBUG /* translate [1-5]... messages to \[1-5] to run by hand */
+ if ((buf[0] > '0') && (buf[0] < '6'))
+ buf[0] -= '0';
+#endif
+
if ((buf[0] < 1) || (buf[0] > 5)) {
fatal(ofp, "Invalid protocol request (%d): %c%s\n",
buf[0], buf[0], buf);
@@ -183,6 +718,11 @@ main(int ac, char *av[])
exit(1);
}
+ if (cyclical_service_check(printer) != 0) {
+ fatal(ofp, "%s is cyclical\n", printer);
+ exit(1);
+ }
+
status = papiServiceCreate(&svc, printer, NULL, NULL, NULL,
encryption, NULL);
if (status != PAPI_OK) {
@@ -191,20 +731,19 @@ main(int ac, char *av[])
exit(1);
}
-#ifdef HAVE_IS_SYSTEM_LABELED
- if (is_system_labeled()) {
- int fd = fileno(ifp);
-
- (void) papiServiceSetPeer(svc, fd);
- }
-#endif
+ /*
+ * Trusted Solaris can't be trusting of intermediaries. Pass
+ * the socket connection to the print service to retrieve the
+ * sensativity label off of a multi-level port.
+ */
+ (void) papiServiceSetPeer(svc, fileno(ifp));
switch (buf[0]) {
case '\1': /* restart printer */
ACK(ofp); /* there is no equivalent */
break;
case '\2': /* transfer job(s) */
- berkeley_transfer_files(svc, ifp, ofp, printer);
+ status = berkeley_transfer_files(svc, ifp, ofp, printer);
break;
case '\3': /* show queue (short) */
case '\4': { /* show queue (long) */
@@ -216,10 +755,18 @@ main(int ac, char *av[])
}
break;
case '\5': { /* cancel job(s) */
- char *requestor = *args++;
+ char *user = *args++;
+ char *host = remote_host_name(ifp);
int count;
- status = papiServiceSetUserName(svc, requestor);
+ if (host != NULL) {
+ char buf[BUFSIZ];
+
+ snprintf(buf, sizeof (buf), "%s@%s", user, host);
+ status = papiServiceSetUserName(svc, buf);
+ } else
+ status = papiServiceSetUserName(svc, user);
+
for (count = 0; args[count] != 0; count++);
berkeley_cancel_request(svc, ofp, printer, count, args);
@@ -234,7 +781,9 @@ main(int ac, char *av[])
syslog(LOG_DEBUG, "protocol request(%d) for %s completed: %s",
buf[0], printer, papiStatusString(status));
- syslog(LOG_DEBUG, "detail: %s", verbose_papi_message(svc, status));
+ if (status != PAPI_OK)
+ syslog(LOG_DEBUG, "detail: %s",
+ verbose_papi_message(svc, status));
papiServiceDestroy(svc);
diff --git a/usr/src/cmd/print/bsd-sysv-commands/lp.c b/usr/src/cmd/print/bsd-sysv-commands/lp.c
index 3b6631fe6a..5abe7ae7e8 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/lp.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/lp.c
@@ -62,41 +62,6 @@ usage(char *program)
exit(1);
}
-static struct {
- char *mime_type;
- char *lp_type;
-} type_map[] = {
- { "text/plain", "simple" },
- { "application/octet-stream", "raw" },
- { "application/octet-stream", "any" },
- { "application/postscript", "postscript" },
- { "application/postscript", "ps" },
- { "application/x-cif", "cif" },
- { "application/x-dvi", "dvi" },
- { "application/x-plot", "plot" },
- { "application/x-ditroff", "troff" },
- { "application/x-troff", "otroff" },
- { "application/x-pr", "pr" },
- { "application/x-fortran", "fortran" },
- { "application/x-raster", "raster" },
- { NULL, NULL}
-};
-
-static char *
-lp_type_to_mime_type(char *lp_type)
-{
- int i;
-
- if (lp_type == NULL)
- return ("application/octet-stream");
-
- for (i = 0; type_map[i].lp_type != NULL; i++)
- if (strcasecmp(type_map[i].lp_type, lp_type) == 0)
- return (type_map[i].mime_type);
-
- return (lp_type);
-}
-
int
main(int ac, char *av[])
{
@@ -161,7 +126,7 @@ main(int ac, char *av[])
break;
case 'f': /* form */
papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
- "media", optarg);
+ "form", optarg);
break;
case 'i': /* modify job */
if ((get_printer_id(optarg, &printer, &modify) < 0) ||
@@ -250,19 +215,22 @@ main(int ac, char *av[])
optind = ac;
if (modify == -1) {
- char *document_format = "application/octet-stream";
+ char *document_format = "text/plain";
-#ifdef MAGIC_MIME
if (optind != ac) {
/* get the mime type of the file data */
+#ifdef MAGIC_MIME
magic_t ms = NULL;
if ((ms = magic_open(MAGIC_MIME)) != NULL) {
document_format = magic_file(ms, av[optind]);
magic_close(ms);
}
- }
+#else
+ if (is_postscript(av[optind]) == 1)
+ document_format = "application/postscript";
#endif
+ }
papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, "copies", 1);
papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
@@ -280,6 +248,12 @@ main(int ac, char *av[])
exit(1);
}
+ if (dump != 0) {
+ printf("requesting attributes:\n");
+ papiAttributeListPrint(stdout, list, "\t");
+ printf("\n");
+ }
+
if (modify != -1)
status = papiJobModify(svc, printer, modify, list, &job);
else if (optind == ac) /* no file list, use stdin */
diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpr.c b/usr/src/cmd/print/bsd-sysv-commands/lpr.c
index 4d64ddb635..cfa66c54db 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/lpr.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/lpr.c
@@ -75,7 +75,7 @@ main(int ac, char *av[])
int validate = 0;
int remove = 0;
int copy = 1; /* default is to copy the data */
- char *document_format = "application/octet-stream";
+ char *document_format = "text/plain";
int c;
(void) setlocale(LC_ALL, "");
@@ -210,17 +210,20 @@ main(int ac, char *av[])
if (((optind + 1) == ac) && (strcmp(av[optind], "-") == 0))
optind = ac;
-#ifdef MAGIC_MIME
if (optind != ac) {
/* get the mime type of the file data */
+#ifdef MAGIC_MIME
magic_t ms;
if ((ms = magic_open(MAGIC_MIME)) != NULL) {
document_format = magic_file(ms, av[optind]);
magic_close(ms);
}
- }
+#else
+ if (is_postscript(av[optind]) == 1)
+ document_format = "application/postscript";
#endif
+ }
papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, "copies", 1);
papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c
index 466025da9a..a9ce4dc054 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c
@@ -664,9 +664,15 @@ report_job(papi_job_t job, int show_rank, int verbose)
printf(gettext(", complete"));
if (verbose == 1) {
+ char *form = NULL;
+
(void) papiAttributeListGetString(attrs, NULL,
"output-device-assigned", &destination);
printf("\n\t assigned %s", destination);
+
+ (void) papiAttributeListGetString(attrs, NULL, "form", &form);
+ if (form != NULL)
+ printf(", form %s", form);
} else if (verbose > 1) {
printf("\n");
papiAttributeListPrint(stdout, attrs, "\t");
diff --git a/usr/src/cmd/print/gateway/rfc1179.xml b/usr/src/cmd/print/bsd-sysv-commands/rfc1179.xml
index 19fa0c3be7..c9ee75e326 100644
--- a/usr/src/cmd/print/gateway/rfc1179.xml
+++ b/usr/src/cmd/print/bsd-sysv-commands/rfc1179.xml
@@ -2,15 +2,11 @@
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<!--
- Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- Use is subject to license terms.
-
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.
@@ -25,7 +21,10 @@
CDDL HEADER END
- pragma ident "%Z%%M% %I% %E% SMI"
+ Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ Use is subject to license terms.
+
+ ident "%Z%%M% %I% %E% SMI"
NOTE: This service manifest is not editable; its contents will
be overwritten by package or patch operations, including
@@ -57,10 +56,10 @@
<exec_method
type='method'
name='inetd_start'
- exec='/usr/lib/print/in.lpd'
+ exec='/usr/lib/print/in.lpd -u lp -d /var/run/in.lpd'
timeout_seconds='0'>
<method_context>
- <method_credential user='root' group='root' />
+ <method_credential user='root' group='lp' />
</method_context>
</exec_method>
diff --git a/usr/src/cmd/print/gateway/Makefile b/usr/src/cmd/print/gateway/Makefile
deleted file mode 100644
index 6f1454ca44..0000000000
--- a/usr/src/cmd/print/gateway/Makefile
+++ /dev/null
@@ -1,106 +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"
-#
-# server/gateway/adaptor/Makefile
-#
-
-MANIFEST= rfc1179.xml cleanup.xml
-SVCMETHOD= print-cleanup
-
-include ../Makefile.sp
-
-ROOTMANIFESTDIR= $(ROOTSVCAPPLICATIONPRINT)
-
-ROOTLIBPRINT= $(ROOTLIB)/print
-$(ROOTLIBPRINT) := OWNER=root
-$(ROOTLIBPRINT) := GROUP=lp
-
-PRINTDPROG= printd
-PRINTDSRCS= printd.c
-PRINTDOBJS= $(PRINTDSRCS:.c=.o)
-$(PRINTDPROG) := LDLIBS += $(LIBNPRT)
-$(ROOTLIBPRINT)/$(PRINTDPROG) := FILEMODE= 555
-
-INLPDPROG= in.lpd
-INLPDSRCS= main.c adaptor.c
-INLPDOBJS= $(INLPDSRCS:.c=.o)
-$(INLPDPROG) := LDLIBS += -lsocket -lnsl $(LIBNPRT)
-
-PROG= $(PRINTDPROG) $(INLPDPROG)
-
-SUBDIRS= translators
-
-FILEMODE= 0555
-OWNER= root
-GROUP= bin
-
-
-CPPFLAGS += -I. -I$(NPRTINC) #$(CPPFLAGS.master)
-
-.KEEP_STATE:
-
-all: $(PRINTDPROG) $(INLPDPROG) $(SUBDIRS)
-
-$(PRINTDPROG): $(PRINTDOBJS)
- $(LINK.c) $(PRINTDOBJS) -o $@ $(LDLIBS)
- $(POST_PROCESS)
-
-$(INLPDPROG): $(INLPDOBJS)
- $(LINK.c) $(INLPDOBJS) -o $@ $(LDLIBS)
- $(POST_PROCESS)
-
-ROOTLIBPRINTPROG= $(PRINTDPROG:%=$(ROOTLIBPRINT)/%) \
- $(INLPDPROG:%=$(ROOTLIBPRINT)/%)
-
-install: all $(ROOTLIBPRINTPROG) $(SUBDIRS) $(ROOTMANIFEST) \
- $(ROOTSVCMETHOD) $(ROOTLIBPRINT)
-
-check: $(CHKMANIFEST)
-
-strip: $(SUBDIRS)
- $(STRIP) $(PRINTDPROG) $(INLPDPROG)
-
-cstyle:
- cstyle $(PRINTDSRCS) $(INLPDSRCS)
-
-lint:
- $(LINT.c) $(PRINTDSRCS) $(LDLIBS)
- $(LINT.c) $(INLPDSRCS) $(LDLIBS)
-
-clean: $(SUBDIRS)
- $(RM) $(PRINTDOBJS) $(INLPDOBJS)
-
-clobber: clean $(SUBDIRS)
-
-_msg:
- @echo "Messages are made in usr/src/cmd/print"
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
-
-include $(SRC)/cmd/Makefile.targ
diff --git a/usr/src/cmd/print/gateway/adaptor.c b/usr/src/cmd/print/gateway/adaptor.c
deleted file mode 100644
index e53e92bca7..0000000000
--- a/usr/src/cmd/print/gateway/adaptor.c
+++ /dev/null
@@ -1,359 +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"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <string.h>
-#include <errno.h>
-#include <dlfcn.h>
-#include <sys/systeminfo.h>
-
-#include <syslog.h>
-
-#include <adaptor.h>
-#include <ns.h>
-
-#ifndef RTLD_GLOBAL /* for OSF/1 */
-#define RTLD_GLOBAL 0
-#endif
-
-/*
- * This file contains the implementation of the API used by the front half
- * of the BSD Print protocol adaptor to select and glue in the back half of
- * the print protocol adaptor dynamically. Most of the functions in this
- * file are hollow shells that pick a back end, load it, and call the "real"
- * function from the loaded object, with the arguments passed in. The loaded
- * functions have the naming convention {paradigm}_{function}.
- * These functions are in NO WAY MT-Safe. They are intended to be used by
- * a single threaded adaptor, that is/may be called via inetd concurrently.
- */
-
-
-static void *paradigm_handle = NULL;
-static char *paradigm_name = NULL;
-static int paradigm_version = -1;
-static ns_printer_t *printer_object = NULL;
-static char *primary_name = NULL;
-
-static int
-is_localhost(char *name)
-{
- char buf[BUFSIZ];
-
- if (name == NULL)
- return (0);
-
- if (strcasecmp(name, "localhost") == 0)
- return (0);
-
- (void) sysinfo(SI_HOSTNAME, buf, sizeof (buf));
-
- return (strcasecmp(name, buf));
-}
-
-int
-syn_name(const char *str)
-{
- register char *p;
-
- if (!str || !*str)
- return (0);
-
- if (strlen(str) > (size_t)14)
- return (0);
-
- for (p = (char *)str; *p; p++)
- if (!isalnum(*p) && *p != '_' && *p != '-')
- return (0);
-
- return (1);
-}
-
-/*
- * A hack for performance. This will look for a local LP based printer in
- * the most efficient manner. If found, it will circumvent all future
- * adaptor resolution and load the default lpsched translation module.
- */
-static int
-lpsched_adaptor_available(const char *printer)
-{
- char buf[BUFSIZ], buf2[BUFSIZ];
-
- syslog(LOG_DEBUG, "in.lpd:lpsched_adaptor_available: entry\n");
-
- if (!syn_name(printer))
- return (-1);
-
- (void) snprintf(buf, sizeof (buf), "/etc/lp/interfaces/%s", printer);
- (void) snprintf(buf2, sizeof (buf2), "/etc/lp/classes/%s", printer);
- syslog(LOG_DEBUG,
- "in.lpd:lpsched_adaptor_available: printer is %s\n",
- printer);
- if ((access(buf, F_OK) < 0) && (access(buf2, F_OK) < 0))
- return (-1);
-
- syslog(LOG_DEBUG,
- "in.lpd:lpsched_adaptor_available: printer %s local\n",
- printer);
-
- paradigm_handle = dlopen("/usr/lib/print/bsd-adaptor/bsd_lpsched.so",
- RTLD_NOW|RTLD_GLOBAL);
- if (paradigm_handle == NULL)
- return (-1);
-
- paradigm_name = LPSCHED;
- return (0);
-}
-
-/*
- * adaptor_avaliable() takes in the name of a printer, looks it up in the
- * name service, and dynamically loads backend support for the print paradigm
- * the printer is defined in. If the printer is undefined, UNDEFINED is
- * returned. If the spooling paradigm is not defined, and the printer is
- * remote, a "cascade" capability is loaded.
- */
-int
-adaptor_available(const char *printer)
-{
- char *path,
- *dir,
- *tmp,
- *tmp_path;
- ns_bsd_addr_t *addr;
-
- /*
- * for performance, check lpsched first and foremost. This will
- * hide any NS information if there is an LP configuration, valid
- * or not.
- */
- if (lpsched_adaptor_available(printer) == 0)
- return (0);
-
- errno = 0;
- if (((printer_object = ns_printer_get_name(printer,
- NS_SVC_ETC)) == NULL) &&
- (endprinterentry() == 0) &&
- ((printer_object = ns_printer_get_name(printer, NULL)) == NULL)) {
- errno = ENOENT;
- return (-1);
- }
-
- if ((addr = ns_get_value(NS_KEY_BSDADDR, printer_object)) != NULL)
- primary_name = addr->printer;
-
- if ((paradigm_name = ns_get_value_string(NS_KEY_ADAPTOR_NAME,
- printer_object)) == NULL) {
- if ((addr != NULL) && (is_localhost(addr->server) == 0))
- paradigm_name = LPSCHED;
- else
- paradigm_name = CASCADE;
- }
-
- if ((tmp = strrchr(paradigm_name, ',')) != NULL) {
- *tmp++ = NULL;
- paradigm_version = atoi(tmp);
- }
-
- if ((path = ns_get_value_string(NS_KEY_ADAPTOR_PATH, printer_object))
- == NULL)
- path = ADAPTOR_PATH;
-
- tmp_path = strdup(path);
- for (dir = strtok(tmp_path, ":,"); dir != NULL;
- dir = strtok(NULL, ":,")) {
- static char object[BUFSIZ];
-
- if (paradigm_version < 0)
- (void) snprintf(object, sizeof (object), "%s/bsd_%s.so",
- dir, paradigm_name);
- else
- (void) snprintf(object, sizeof (object),
- "%s/bsd_%s.so.%d", dir, paradigm_name,
- paradigm_version);
- if ((paradigm_handle = dlopen(object, RTLD_NOW|RTLD_GLOBAL))
- != NULL)
- break;
-#ifdef DEBUG
- syslog(LOG_DEBUG, "dlopen(%d): %s", object, dlerror());
-#endif
- }
- free(tmp_path);
-
- return (paradigm_handle == NULL);
-}
-
-
-static void *
-adaptor_function(const char *paradigm, const char *function)
-{
- char name[128];
- void *fpt = NULL;
-
- if (paradigm_handle == NULL)
- return (NULL);
-
- (void) snprintf(name, sizeof (name), "%s_%s", paradigm, function);
- if ((fpt = dlsym(paradigm_handle, name)) == NULL)
- syslog(LOG_ERR, "could not locate function: %s()", name);
-
- return (fpt);
-}
-
-
-int
-adaptor_spooler_available(const char *printer)
-{
- static int (*fpt)() = NULL;
-
- if ((fpt != NULL) ||
- ((fpt = (int (*)())adaptor_function(paradigm_name,
- "spooler_available")) != NULL))
- /*
- * in the case of cascading,
- * use the local name of the printer
- */
- if (strcmp(paradigm_name, "cascade") == 0)
- return ((int)(fpt)(printer));
- else
- return ((int)(fpt)
- (primary_name ? primary_name : printer));
-
- return (-1);
-}
-
-
-int
-adaptor_spooler_accepting_jobs(const char *printer)
-{
- static int (*fpt)() = NULL;
-
- if ((fpt != NULL) ||
- ((fpt = (int (*)())adaptor_function(paradigm_name,
- "spooler_accepting_jobs")) != NULL))
- return ((int)(fpt)(primary_name ? primary_name : printer));
-
- return (-1);
-}
-
-
-int
-adaptor_client_access(const char *printer, const char *host, int peerfd)
-{
- static int (*fpt)() = NULL;
-
- if ((fpt != NULL) ||
- ((fpt = (int (*)())adaptor_function(paradigm_name,
- "client_access")) != NULL))
- return ((int)(fpt)((primary_name ? primary_name : printer),
- host, peerfd));
-
- return (-1);
-}
-
-
-int
-adaptor_restart_printer(const char *printer)
-{
- static int (*fpt)() = NULL;
-
- /* need a cast */
- if ((fpt != NULL) ||
- ((fpt = (int (*)())adaptor_function(paradigm_name,
- "restart_printer")) != NULL))
- return ((int)(fpt)(primary_name ? primary_name : printer));
-
- return (-1);
-}
-
-
-char *
-adaptor_temp_dir(const char *printer, const char *host)
-{
- static char *(*fpt)() = NULL;
-
- /* need a cast */
- if ((fpt != NULL) ||
- ((fpt = (char *(*)())adaptor_function(paradigm_name,
- "temp_dir")) != NULL))
- return ((char *)(fpt)((primary_name ? primary_name : printer),
- host));
-
- return (NULL);
-}
-
-
-int
-adaptor_submit_job(const char *printer, const char *host, char *cf,
- char **df_list)
-{
- static int (*fpt)() = NULL;
-
- /* need a cast */
- if ((fpt != NULL) ||
- ((fpt = (int (*)())adaptor_function(paradigm_name,
- "submit_job")) != NULL))
- return ((int)(fpt)((primary_name ? primary_name : printer),
- host, cf, df_list));
-
- return (-1);
-}
-
-
-int
-adaptor_show_queue(const char *printer, FILE *ofp, const int type,
- char **list)
-{
- static int (*fpt)() = NULL;
-
- /* need a cast */
- if ((fpt != NULL) ||
- ((fpt = (int (*)())adaptor_function(paradigm_name,
- "show_queue")) != NULL))
- return ((int)(fpt)((primary_name ? primary_name : printer),
- ofp, type, list));
-
- return (-1);
-}
-
-
-int
-adaptor_cancel_job(const char *printer, FILE *ofp, const char *user,
- const char *host, char **list)
-{
- static int (*fpt)() = NULL;
-
- /* need a cast */
- if ((fpt != NULL) ||
- ((fpt = (int (*)())adaptor_function(paradigm_name,
- "cancel_job")) != NULL))
- return ((int)(fpt)((primary_name ? primary_name : printer),
- ofp, user, host, list));
-
- return (-1);
-}
diff --git a/usr/src/cmd/print/gateway/adaptor.h b/usr/src/cmd/print/gateway/adaptor.h
deleted file mode 100644
index 48ebdd6750..0000000000
--- a/usr/src/cmd/print/gateway/adaptor.h
+++ /dev/null
@@ -1,65 +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 _ADAPTOR_H
-#define _ADAPTOR_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * The API used by the BSD print protocol adaptor to glue the front end
- * request receiving code to the back end request fufilling code.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ADAPTOR_PATH "/etc/print/bsd-adaptor,/usr/lib/print/bsd-adaptor"
-#define NS_KEY_ADAPTOR_PATH "spooling-type-path"
-#define NS_KEY_ADAPTOR_NAME "spooling-type"
-#define CASCADE "cascade"
-#define LPSCHED "lpsched"
-
-extern int adaptor_available(const char *printer);
-extern int adaptor_spooler_available(const char *printer);
-extern int adaptor_spooler_accepting_jobs(const char *printer);
-extern int adaptor_client_access(const char *printer, const char *host,
- int peerfd);
-extern int adaptor_restart_printer(const char *printer);
-extern char *adaptor_temp_dir(const char *printer, const char *host);
-extern int adaptor_submit_job(const char *printer, const char *host,
- char *cf, char **df_list);
-extern int adaptor_show_queue(const char *printer, FILE *ofp,
- const int type, char **list);
-extern int adaptor_cancel_job(const char *printer, FILE *ofp,
- const char *user, const char *host,
- char **list);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _ADAPTOR_H */
diff --git a/usr/src/cmd/print/gateway/cleanup.xml b/usr/src/cmd/print/gateway/cleanup.xml
deleted file mode 100644
index 50118847d2..0000000000
--- a/usr/src/cmd/print/gateway/cleanup.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
-<!--
- Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- Use is subject to license terms.
-
- 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.
-
- 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
-
- ident "%Z%%M% %I% %E% SMI"
-
- NOTE: This service manifest is not editable; its contents will
- be overwritten by package or patch operations, including
- operating system upgrade. Make customizations in a different
- file.
--->
-
-<service_bundle type='manifest' name='SUNWpcr:printd'>
-
-<service
- name='application/print/cleanup'
- type='service'
- version='1'>
-
- <create_default_instance enabled='false' />
-
- <dependency
- name='network'
- grouping='require_any'
- restart_on='error'
- type='service'>
- <service_fmri value='svc:/network/loopback' />
- <service_fmri value='svc:/network/physical' />
- </dependency>
-
- <dependency
- name='filesystem'
- grouping='require_all'
- restart_on='none'
- type='service'>
- <service_fmri value='svc:/system/filesystem/minimal' />
- </dependency>
-
- <exec_method
- type='method'
- name='start'
- exec='/lib/svc/method/print-cleanup start'
- timeout_seconds='60' />
-
- <exec_method
- type='method'
- name='stop'
- exec=':true'
- timeout_seconds='0' />
-
- <property_group name='startd' type='framework'>
- <propval name='duration' type='astring' value='transient' />
- </property_group>
-
- <stability value='Unstable' />
-
- <template>
- <common_name>
- <loctext xml:lang='C'>
- print cleanup
- </loctext>
- </common_name>
- </template>
-</service>
-
-</service_bundle>
diff --git a/usr/src/cmd/print/gateway/main.c b/usr/src/cmd/print/gateway/main.c
deleted file mode 100644
index 198447fa2e..0000000000
--- a/usr/src/cmd/print/gateway/main.c
+++ /dev/null
@@ -1,609 +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"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <libintl.h>
-#include <sys/systeminfo.h>
-
-#include <ctype.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#include <string.h>
-#include <syslog.h>
-#include <errno.h>
-#include <libintl.h>
-
-#include <adaptor.h>
-
-#define ACK(fp) { (void) fputc(NULL, fp); (void) fflush(fp); }
-#define NACK(fp) { (void) fputc('\001', fp); (void) fflush(fp); }
-
-
-/*
- * This file contains the front-end of the BSD Print Protocol adaptor. This
- * code assumes a BSD Socket interface to the networking side.
- */
-
-/*
- * strsplit() splits a string into a NULL terminated array of substrings
- * determined by a seperator. The original string is modified, and newly
- * allocated space is only returned for the array itself. If more than
- * 1024 substrings exist, they will be ignored.
- */
-static char **
-strsplit(char *string, const char *seperators)
-{
- char *list[BUFSIZ],
- **result;
- int length = 0;
-
- if ((string == NULL) || (seperators == NULL))
- return (NULL);
-
- (void) memset(list, NULL, sizeof (list));
- for (list[length] = strtok(string, seperators);
- (list[length] != NULL) && (length < (BUFSIZ - 2));
- list[length] = strtok(NULL, seperators))
- length++;
-
- if ((result = (char **)calloc(length+1, sizeof (char *))) != NULL)
- (void) memcpy(result, list, length * sizeof (char *));
-
- return (result);
-}
-
-
-/*
- * remote_host_name() gets the hostname of the "peer" on the socket
- * connection.
- */
-static char *
-remote_host_name(FILE *fp)
-{
- struct hostent *hp;
- struct sockaddr_in6 peer;
- socklen_t peer_len = sizeof (peer);
- int fd = fileno(fp);
- int error_num;
- char myname[MAXHOSTNAMELEN], tmp_buf[INET6_ADDRSTRLEN];
- char *hostname;
-
- /* who is our peer ? */
- if (getpeername(fd, (struct sockaddr *)&peer, &peer_len) < 0) {
- if ((errno != ENOTSOCK) && (errno != EINVAL))
- return (NULL);
- else
- return (strdup("localhost"));
- }
-
- /* get their name or return a string containing their address */
- if ((hp = getipnodebyaddr((const char *)&peer.sin6_addr,
- sizeof (struct in6_addr), AF_INET6,
- &error_num)) == NULL) {
- return (strdup(inet_ntop(peer.sin6_family,
- &peer.sin6_addr, tmp_buf, sizeof (tmp_buf))));
- }
-
- /* is it "localhost" ? */
- if (strcasecmp(hp->h_name, "localhost") == 0)
- return (strdup("localhost"));
-
- /* duplicate the name because gethostbyXXXX() is not reentrant */
- hostname = strdup(hp->h_name);
- (void) sysinfo(SI_HOSTNAME, myname, sizeof (myname));
-
- /* is it from one of my addresses ? */
- if ((hp = getipnodebyname(myname, AF_INET6, AI_ALL|AI_V4MAPPED,
- &error_num)) != NULL) {
- struct in6_addr **tmp = (struct in6_addr **)hp->h_addr_list;
- int i = 0;
-
- while (tmp[i] != NULL) {
- if (memcmp(tmp[i++], &peer.sin6_addr, hp->h_length)
- == 0) {
- free(hostname);
- return (strdup("localhost"));
- }
- }
- }
-
- /* It must be someone else */
- return (hostname);
-}
-
-static int
-request_id_no(const char *filename)
-{
- int id = -1;
-
- /* get the first number embedded in the string */
- while ((filename != NULL) && (*filename != NULL) &&
- (isdigit(*filename) == 0))
- filename++;
-
- if ((filename != NULL) && (*filename != NULL))
- id = atoi(filename);
-
- return (id);
-}
-
-
-static void
-abort_transfer(char **files)
-{
- syslog(LOG_DEBUG, "abort_transfer()");
- while ((files != NULL) && (*files != NULL))
- (void) unlink(*files++);
-}
-
-static int lock_fd = -1;
-static int lock_job_id = -1;
-
-static void
-unlock_job()
-{
- syslog(LOG_DEBUG, "unlock_job(): fd = %d, id = %d\n", lock_fd,
- lock_job_id);
- if (lock_fd != -1) {
- char name[12];
-
- snprintf(name, sizeof (name), "%d", lock_job_id);
- unlink(name);
- close(lock_fd);
- lock_fd = -1;
- lock_job_id = -1;
- }
-}
-
-
-static void
-lock_job(int job_id)
-{
- int try = 5;
- char name[12];
-
- syslog(LOG_DEBUG, "lock_job(%d): fd = %d, id = %d\n", job_id, lock_fd,
- lock_job_id);
- if ((lock_job_id != -1) && (lock_job_id != job_id))
- unlock_job();
-
- snprintf(name, sizeof (name), "%d", job_id);
- while ((try > 0) && (lock_fd < 0)) {
- if ((lock_fd = open(name, O_CREAT|O_EXCL|O_WRONLY, 0600)) < 0) {
- if (errno == EEXIST) {
- sleep(3);
- lock_fd = open(name, O_WRONLY);
- }
- }
- try--;
- }
-
- if (lockf(lock_fd, F_LOCK, 0) < 0) {
- syslog(LOG_DEBUG|LOG_INFO,
- "failed to lock job: %d, file(%s), fd(%d): %m",
- job_id, name, lock_fd);
- close(lock_fd);
- unlink(name);
- job_id = lock_fd = -1;
- }
-
- lock_job_id = job_id;
-}
-
-
-/*
- * transfer_job() retrieves jobs being sent from a remote system and
- * submits them as they are completely received.
- */
-static int
-transfer_job(const char *printer, const char *host, FILE *ifp,
- FILE *ofp)
-{
- char buf[BUFSIZ],
- *tmp;
- char *cf = NULL;
- char *df_list[64]; /* don't allow more that 64 files */
- int file_no = 0;
- int current_request = -1;
- int tmp_id;
- int psize;
-
-
- (void) memset(&df_list, NULL, sizeof (df_list));
-
- if (adaptor_spooler_accepting_jobs(printer) < 0) {
- syslog(LOG_DEBUG,
- "attempt to transfer job(s) to disabled printer"
- " or unknown printer %s", printer);
- return (-1);
- }
-
- ACK(ofp);
- /* start to receive job(s) */
- while (fgets(buf, sizeof (buf), ifp) != NULL) {
- int size = 0;
- char *name = NULL;
- char *ptr;
- int fd;
- int count;
-
- /*
- * When receiving jobs, buf[0] can only be 1,2 or 3
- * Anything else, abort transfer - rfc1179
- */
- if ((buf[0] < 1 || buf[0] > 3)) {
- syslog(LOG_ERR,
- "protocol error - bad message from client");
- syslog(LOG_DEBUG, "control file contained: (%s)",
- (cf ? cf : "NULL"));
- abort_transfer(df_list);
- unlock_job();
- return (-1);
- }
-
- if (strlen(&buf[1]) == 0) /* just a null */
- continue;
-
- count = size = atoi(strtok(&buf[1], "\n\t "));
- if ((tmp = strtok(NULL, "\n\t ")) != NULL) {
- if ((name = strrchr(tmp, '/')) != NULL) {
- /* for security */
- syslog(LOG_INFO|LOG_NOTICE,
- "Attempt to tranfer Absolute path: %s",
- tmp);
- name++;
- } else
- name = tmp;
-
- tmp_id = request_id_no(name);
- if ((cf != NULL) && (df_list[0] != NULL) &&
- (tmp_id != current_request)) {
- if (adaptor_submit_job(printer, host, cf,
- df_list) != 0) {
- abort_transfer(df_list);
- unlock_job();
- return (-1);
- }
- while (file_no-- > 0)
- free(df_list[file_no]);
- (void) memset(df_list, NULL, sizeof (df_list));
- file_no = 0;
- free(cf);
- cf = NULL;
- }
- if (tmp_id != current_request)
- lock_job(tmp_id);
-
- } else if (buf[0] != 1) {
- syslog(LOG_ERR, "Bad xfer message(%d), no file name",
- buf[0]);
- abort_transfer(df_list);
- unlock_job();
- return (-1);
- }
- current_request = tmp_id;
- tmp = NULL;
-
- switch (buf[0]) {
- case '\1': /* Abort Transfer */
- /* remove files on file_list */
- abort_transfer(df_list);
- unlock_job();
- return (-1);
- case '\2': /* Transfer Control File */
- syslog(LOG_DEBUG, "control(%s, %d)", name, size);
- if ((cf = malloc(size + 1)) == NULL) {
- NACK(ofp);
- break;
- }
- (void) memset(cf, NULL, size + 1);
- ACK(ofp);
- ptr = cf;
- while (count > 0)
- if (((fd = fread(ptr, 1, count, ifp)) == 0) &&
- (feof(ifp) != 0)) {
- syslog(LOG_DEBUG,
- "connection closed(%s): %m",
- name);
- abort_transfer(df_list);
- unlock_job();
- return (-1);
- } else {
- ptr += fd;
- count -= fd;
- }
- if (fgetc(ifp) != 0) { /* get ACK/NACK */
- abort_transfer(df_list);
- unlock_job();
- return (-1);
- }
- ACK(ofp);
- break;
- case '\3': /* Transfer Data File */
- syslog(LOG_DEBUG, "data(%s, %d)", name, size);
- if ((fd = open(name, O_RDWR|O_TRUNC|O_CREAT|O_EXCL,
- 0640)) < 0) {
- syslog(LOG_ERR, "open(%s): %m", name);
- abort_transfer(df_list);
- unlock_job();
- NACK(ofp);
- return (-1);
- }
- if (ftruncate(fd, size) < 0) {
- syslog(LOG_ERR, "ftruncate(%s): %m", name);
- (void) close(fd);
- (void) unlink(name);
- abort_transfer(df_list);
- unlock_job();
- NACK(ofp);
- return (-1);
- }
- if ((size > 0) &&
- ((tmp = mmap((caddr_t)0, (size_t)size,
- PROT_READ|PROT_WRITE,
- (MAP_SHARED | MAP_NORESERVE),
- fd, (off_t)0)) == (char *)MAP_FAILED)) {
- syslog(LOG_ERR, "mmap(%d, %d): %m", size, fd);
- (void) close(fd);
- (void) unlink(name);
- abort_transfer(df_list);
- unlock_job();
- NACK(ofp);
- return (-1);
- }
-
- /* Make sure that there is adequate space */
- if ((psize = pwrite(fd, tmp, size, 0)) < size) {
- syslog(LOG_ERR,
- "pwrite(,, %d ,) returns:(%d) %m",
- size, psize);
- (void) close(fd);
- (void) unlink(name);
- (void) munmap(tmp, size);
- abort_transfer(df_list);
- unlock_job();
- NACK(ofp);
- return (-1);
- }
- (void) close(fd);
- ACK(ofp);
- ptr = tmp;
- while (count > 0)
- if (((fd = fread(ptr, 1, count, ifp)) == 0) &&
- (feof(ifp) != 0)) {
- syslog(LOG_DEBUG,
- "connection closed(%s): %m",
- name);
- unlink(name);
- abort_transfer(df_list);
- unlock_job();
- return (-1);
- } else {
- ptr += fd;
- count -= fd;
- }
- (void) munmap(tmp, size);
- if (fgetc(ifp) != 0) { /* get ACK/NACK */
- unlink(name);
- abort_transfer(df_list);
- unlock_job();
- return (-1);
- }
- /*
- * make sure we don't overflow df_list.
- */
- if (file_no >= sizeof (df_list)/sizeof (df_list[0])) {
- syslog(LOG_ALERT|LOG_AUTH,
- "prevented in.lpd exploit from host %s",
- host);
- unlink(name);
- abort_transfer(df_list);
- return (-1);
- }
-
- df_list[file_no++] = strdup(name);
- ACK(ofp);
- break;
- default:
- abort_transfer(df_list);
- unlock_job();
- syslog(LOG_ERR, "protocol screwup");
- return (-1);
- }
- }
- if ((cf != NULL) && (file_no != 0)) {
- if (adaptor_submit_job(printer, host, cf, df_list) != 0) {
- abort_transfer(df_list);
- unlock_job();
- return (-1);
- }
- while (file_no-- > 0)
- free(df_list[file_no]);
- free(cf);
- } else
- abort_transfer(df_list);
- unlock_job();
-
- return (0);
-}
-
-
-/*
- * This is the entry point for this program. The program takes the
- * following options:
- * (none)
- */
-int
-main(int ac, char *av[])
-{
- FILE *ifp = stdin,
- *ofp = stdout;
- int c,
- rc;
- char buf[BUFSIZ],
- **args,
- *host,
- *dir,
- *printer,
- *requestor;
-
-
- openlog("bsd-gw", LOG_PID, LOG_LPR);
-
- while ((c = getopt(ac, av, "d")) != EOF)
- switch (c) {
- case 'd':
- default:
- ;
- }
-
- if (fgets(buf, sizeof (buf), ifp) == NULL) {
- if (feof(ifp) == 0)
- syslog(LOG_ERR, "Error reading from connection: %s",
- strerror(errno));
- exit(1);
- }
-
-#ifdef DEBUG
- if ((buf[0] > '0') && (buf[0] < '6'))
- buf[0] -= '0';
-#endif
-
- if ((buf[0] < 1) || (buf[0] > 5)) {
- syslog(LOG_ERR, "Invalid protocol request (%d): %c%s",
- buf[0], buf[0], buf);
- (void) fprintf(ofp,
- gettext("Invalid protocol request (%d): %c%s\n"),
- buf[0], buf[0], buf);
- exit(1);
- }
-
- args = strsplit(&buf[1], "\t\n ");
- printer = *args++;
-
- if (printer == NULL) {
- syslog(LOG_ERR, "Can't determine requested printer");
- (void) fprintf(ofp,
- gettext("Can't determine requested printer"));
- exit(1);
- }
-
- if ((host = remote_host_name(ifp)) == NULL) {
- syslog(LOG_ERR, "Can't determine requesting host");
- (void) fprintf(ofp,
- gettext("Can't determine requesting host\n"));
- exit(1);
- }
-
- if (adaptor_available(printer) < 0) {
- if (errno == ENOENT) {
- syslog(LOG_ERR,
- "request to %s (unknown printer) from %s",
- printer, host);
- (void) fprintf(ofp,
- gettext("%s: unknown printer\n"), printer);
- } else {
- syslog(LOG_ERR,
- "Can't locate protocol adaptor for %s from %s",
- printer, host);
- (void) fprintf(ofp, gettext(
- "Can't locate protocol adaptor for %s\n"),
- printer);
- }
- exit(1);
- }
-
- if (adaptor_spooler_available(printer) < 0) {
- syslog(LOG_ERR, "Can't communicate with spooler for %s",
- printer);
- (void) fprintf(ofp,
- gettext("Can't communicate with spooler for %s\n"),
- printer);
- exit(1);
- }
-
- if (adaptor_client_access(printer, host, fileno(ifp)) < 0) {
- syslog(LOG_ERR, "%s doesn't have permission to talk to %s",
- host, printer);
- (void) fprintf(ofp,
- gettext("%s doesn't have permission to talk to %s\n"),
- host, printer);
- exit(1);
- }
-
- if ((dir = adaptor_temp_dir(printer, host)) == NULL) {
- syslog(LOG_DEBUG, "failure to locate tmp dir");
- return (1);
- }
-
- if (chdir(dir) < 0) {
- syslog(LOG_DEBUG, "chdir(%s): %m", dir);
- return (1);
- }
-
- switch (buf[0]) {
- case '\1': /* restart printer */
- if ((rc = adaptor_restart_printer(printer)) == 0) {
- ACK(ofp);
- } else {
- NACK(ofp);
- }
- break;
- case '\2': /* transfer job(s) */
- rc = transfer_job(printer, host, ifp, ofp);
- break;
- case '\3': /* show queue (short) */
- case '\4': /* show queue (long) */
- rc = adaptor_show_queue(printer, ofp, buf[0], args);
- break;
- case '\5': /* cancel job(s) */
- requestor = *args++;
- rc = adaptor_cancel_job(printer, ofp, requestor, host, args);
- break;
- default:
- /* NOTREACHED */
- /* your system would have to be completely hosed */
- syslog(LOG_ERR, "reboot or reinstall your system");
- rc = -1;
- }
- (void) fflush(ofp);
-
- syslog(LOG_DEBUG,
- "protocol request(%d) for %s completed with status %d",
- buf[0], printer, rc);
- exit(0);
-}
diff --git a/usr/src/cmd/print/gateway/print-cleanup b/usr/src/cmd/print/gateway/print-cleanup
deleted file mode 100644
index 7780bcd68b..0000000000
--- a/usr/src/cmd/print/gateway/print-cleanup
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/sbin/sh
-#
-# 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.
-#
-# 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 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-. /lib/svc/share/smf_include.sh
-
-case "$1" in
-'start')
- if [ -f /usr/lib/print/printd ]; then
- rm -f /var/spool/print/tf* >/dev/null 2>&1
- /usr/lib/print/printd &
- else
- echo "Error: /usr/lib/print/printd missing."
- exit $SMF_EXIT_ERR_CONFIG
- fi
- ;;
-
-*)
- echo "Usage: $0 { start }"
- exit 1
- ;;
-esac
-exit $SMF_EXIT_OK
diff --git a/usr/src/cmd/print/gateway/printd.c b/usr/src/cmd/print/gateway/printd.c
deleted file mode 100644
index d94ea5cbcb..0000000000
--- a/usr/src/cmd/print/gateway/printd.c
+++ /dev/null
@@ -1,336 +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"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/systeminfo.h>
-#include <sys/param.h>
-#include <stdarg.h>
-#include <signal.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <syslog.h>
-#include <termios.h>
-#include <libintl.h>
-#include <locale.h>
-#include <pwd.h>
-#include <grp.h>
-
-#include <ns.h>
-#include <network.h>
-#include <misc.h>
-#include <list.h>
-#include <job.h>
-
-static int connection_failed = 0;
-
-/*
- * lpr/lp
- * This program will submit print jobs to a spooler using the BSD
- * printing protcol as defined in RFC1179, plus some extension for
- * support of additional lp functionality.
- */
-
-#define SEND_RETRY -1
-#define SEND_ABORT -2
-
-/*ARGSUSED*/
-static void sigpipe_handler(int i)
-{
- syslog(LOG_ERR, "Warning: Received SIGPIPE; continuing");
- (void) signal(SIGPIPE, sigpipe_handler);
-}
-
-static int
-sendfile(jobfile_t *file, int nd, int type)
-{
- int rc = -1;
-
- syslog(LOG_DEBUG, "sendfile(%s, %d, %d)",
- ((file != NULL) ? file->jf_spl_path : "NULL"), nd, type);
- if (file && file->jf_spl_path) {
- rc = net_send_file(nd, file->jf_spl_path, file->jf_data,
- file->jf_size, type);
- }
- return (rc);
-}
-
-
-/*
- * send_job() sends a job to a remote print server.
- */
-static int
-send_job(job_t *job)
-{
- int lockfd,
- lock_size,
- nd,
- tmp,
- rc = 0;
- struct passwd *p = NULL;
- char buf[BUFSIZ];
-
- syslog(LOG_DEBUG, "send_job(%s, %s, %d): called", job->job_printer,
- job->job_server, job->job_id);
- if ((lockfd = get_lock(job->job_cf->jf_src_path, 0)) < 0) {
- (void) close(lockfd);
- return (SEND_RETRY);
- }
-
- /* is job complete ? */
-
- lock_size = file_size(job->job_cf->jf_src_path);
- (void) sprintf(buf, "%ld\n", getpid()); /* add pid to lock file */
- (void) lseek(lockfd, 0, SEEK_END);
- (void) write(lockfd, buf, strlen(buf));
-
- syslog(LOG_DEBUG, "send_job(%s, %s, %d): have lock", job->job_printer,
- job->job_server, job->job_id);
- connection_failed = 0;
- if ((nd = net_open(job->job_server, 5)) < 0) {
- connection_failed = 1;
- if ((nd != NETWORK_ERROR_UNKNOWN) && (nd != NETWORK_ERROR_PORT))
- job_destroy(job);
- else
- (void) ftruncate(lockfd, lock_size);
- (void) close(lockfd);
- return ((nd == NETWORK_ERROR_UNKNOWN) ||
- (nd == NETWORK_ERROR_PORT) ? SEND_RETRY : SEND_ABORT);
- }
-
- if (net_send_message(nd, "%c%s\n", XFER_REQUEST, job->job_printer)
- != 0) {
- (void) net_close(nd);
- syslog(LOG_WARNING,
- "send_job failed job %d (%s@%s) check status\n",
- job->job_id, job->job_printer, job->job_server);
- (void) ftruncate(lockfd, lock_size);
- (void) close(lockfd);
- return (SEND_RETRY);
- }
-
- syslog(LOG_DEBUG, "send_job(%s, %s, %d): send data", job->job_printer,
- job->job_server, job->job_id);
-
- if ((p = getpwnam(job->job_user)) != NULL) {
- /*
- * attempt to become the job owner: uid, euid, gid, and
- * supplementary groups while we try to send the job data.
- * The real uid is changed with setreuid() separately from
- * changing the effective uid so that we retain the saved
- * uid to elevate privilege later. Combining these changes
- * would result in a change to the saved uid also and a loss
- * of the ability to elevate privilege later.
- */
- (void) setuid(0);
- (void) initgroups(job->job_user, p->pw_gid);
- (void) setgid(p->pw_gid);
- (void) setreuid(p->pw_uid, -1);
- (void) seteuid(p->pw_uid);
- }
-
- for (tmp = 0; job->job_df_list[tmp] != NULL; tmp++)
- if ((rc = sendfile(job->job_df_list[tmp], nd, XFER_DATA)) < 0)
- break; /* there was an error, quit now */
- tmp = errno;
- if (p != NULL) {
- /*
- * lose the supplemental groups and elevate our effective
- * uid to root so that we can destroy jobs and/or become
- * other job owners later on.
- */
- (void) seteuid(0);
- (void) initgroups("root", 1);
- }
- errno = tmp;
-
- if (rc < 0) {
- if (errno == ENOENT) {
- (void) net_close(nd);
- job_destroy(job);
- (void) close(lockfd);
- return (SEND_ABORT);
- } else if (errno == EACCES) {
- /* probably trying to circumvent file security */
- (void) net_close(nd);
- job_destroy(job);
- (void) close(lockfd);
- return (SEND_ABORT);
- } else {
- (void) net_close(nd);
- (void) ftruncate(lockfd, lock_size);
- (void) close(lockfd);
- return (SEND_RETRY);
- }
- }
-
- if (sendfile(job->job_cf, nd, XFER_CONTROL) < 0) {
- (void) net_send_message(nd, "%c\n", XFER_CLEANUP);
- (void) net_close(nd);
- (void) ftruncate(lockfd, lock_size);
- (void) close(lockfd);
- return (SEND_RETRY);
- }
-
- syslog(LOG_DEBUG, "send_job(%s, %s, %d): complete", job->job_printer,
- job->job_server, job->job_id);
- (void) net_close(nd);
- job_destroy(job);
- (void) close(lockfd);
- return (0);
-}
-
-
-/*
- * xfer_daemon() attempts to start up a daemon for transfering jobs to a remote
- * print server. The daemon runs if it can get the master lock, and it
- * runs until there are no jobs waiting for transfer.
- */
-static void
-xfer_daemon()
-{
- job_t **list = NULL;
- int i,
- rc;
-
-
-
- closelog();
- closefrom(0);
-
- (void) open("/dev/null", O_RDONLY);
- (void) open("/dev/null", O_WRONLY);
- (void) dup(1);
-
- (void) setuid(0);
- (void) setsid();
- openlog("printd", LOG_PID, LOG_LPR);
- if (fork() != 0)
- exit(0);
-
- if ((i = get_lock(MASTER_LOCK, 1)) < 0)
- exit(0);
-
- (void) chdir(SPOOL_DIR);
- while ((list = job_list_append(NULL, NULL, NULL, SPOOL_DIR)) != NULL) {
- job_t **tmp;
-
- syslog(LOG_DEBUG, "got the queue...");
- for (tmp = list; *tmp != NULL; tmp++) {
- /*
- * Bugid: 4133175 printd dies when data is removed or
- * permissions are changed. Memory is freed twice.
- * Fix: Do not process anything else in the list
- * if the return code is SEND_ABORT as the memory
- * has already been freed by job_destroy().
- */
- rc = send_job(*tmp);
- if ((rc != 0) && (rc != SEND_ABORT)) {
- char *s = strdup((*tmp)->job_server);
- char *p = strdup((*tmp)->job_printer);
-
- if (rc != SEND_ABORT) /* already free */
- job_free(*tmp);
-
- for (tmp++; ((*tmp != NULL) &&
- (strcmp(s, (*tmp)->job_server) == 0));
- tmp++)
- if ((connection_failed == 0) &&
- (strcmp(p,
- (*tmp)->job_printer) == 0))
- job_free(*tmp);
- else
- break;
- tmp--;
- free(s);
- free(p);
- }
- }
- free(list);
-
- /* look for more work to do before we sleep */
- if ((list = job_list_append(NULL, NULL, NULL,
- SPOOL_DIR)) != NULL) {
- (void) list_iterate((void **)list, (VFUNC_T)job_free);
- free(list);
- (void) sleep(60);
- }
- }
- syslog(LOG_DEBUG, "daemon exiting...");
-}
-
-int
-main(int ac, char *av[])
-{
- ns_bsd_addr_t *binding = NULL;
- int numFiles = 0,
- queueStdin = 0,
- exit_code = 0;
- char *program,
- *user,
- hostname[128],
- buf[BUFSIZ];
- job_t *job;
-
- (void) setlocale(LC_ALL, "");
-
-#if !defined(TEXT_DOMAIN)
-#define TEXT_DOMAIN "SYS_TEST"
-#endif
- (void) textdomain(TEXT_DOMAIN);
-
- if ((program = strrchr(av[0], '/')) == NULL)
- program = av[0];
- else
- program++;
-
- openlog(program, LOG_PID, LOG_LPR);
-
- /*
- * Bugid: 4013980 Application changed fd 1 to a pipe that has
- * no reader; we write to stdout and catch a sigpipe and exit.
- * Fix: catch signal, complain to syslog, and continue.
- */
- (void) signal(SIGPIPE, sigpipe_handler);
-
- if (check_client_spool(NULL) < 0) {
- (void) fprintf(stderr,
- gettext("couldn't validate local spool area (%s)\n"),
- SPOOL_DIR);
- return (-1);
- }
-
- xfer_daemon();
-
- exit(0);
-}
diff --git a/usr/src/cmd/print/gateway/translators/Makefile b/usr/src/cmd/print/gateway/translators/Makefile
deleted file mode 100644
index f761f2c949..0000000000
--- a/usr/src/cmd/print/gateway/translators/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# 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.
-#
-# 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 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#ident "%Z%%M% %I% %E% SMI"
-#
-# cmd/print/gateway/translators/Makefile
-#
-
-SUBDIRS = test cascade
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-strip := TARGET= strip
-_msg := TARGET= catalog
-
-.KEEP_STATE:
-
-all install: $(SUBDIRS)
-
-clean clobber strip cstyle lint: $(SUBDIRS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/cmd/print/gateway/translators/cascade/Makefile b/usr/src/cmd/print/gateway/translators/cascade/Makefile
deleted file mode 100644
index efff220e82..0000000000
--- a/usr/src/cmd/print/gateway/translators/cascade/Makefile
+++ /dev/null
@@ -1,70 +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.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-LIBRARY = bsd_cascade.a
-VERS=.1
-
-OBJECTS = cascade.o
-
-include ../../../../../lib/Makefile.lib
-include ../../../Makefile.sp
-
-# There should be a mapfile here
-MAPFILES =
-
-ROOTLIBDIR= $(ROOT)/usr/lib/print/bsd-adaptor
-
-#CPPFLAGS += -I$(LPINC)
-CPPFLAGS += -I$(NPRTINC)
-LDLIBS += -lprint -lc # with XFN API
-#LDLIBS += $(LIBCLS) $(LIBPRT) $(LIBMSG)
-
-LIBS = $(DYNLIB) # could be += for static and dynamic
-SRCS= $(OBJECTS:%.o=%.c)
-
-CLOBBERFILES= llib-lbsd_cascade.a.ln lint.out
-
-.KEEP_STATE:
-
-all : $(LIBS)
-
-install: $(ROOTLIBDIR) $(ROOTLIBS) $(ROOTLINKS)
-
-cstyle:
- cstyle $(SRCS)
-
-lint:
- $(LINT.c) $(SRCS)
-strip:
-
-_msg:
- @echo "Messages are made in usr/src/cmd/print"
-
-$(ROOTLIBDIR):
- $(INS.dir)
-
-include ../../../../../lib/Makefile.targ
diff --git a/usr/src/cmd/print/gateway/translators/cascade/cascade.c b/usr/src/cmd/print/gateway/translators/cascade/cascade.c
deleted file mode 100644
index 8e50a9b0d7..0000000000
--- a/usr/src/cmd/print/gateway/translators/cascade/cascade.c
+++ /dev/null
@@ -1,373 +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 <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <libintl.h>
-
-#include <ns.h>
-#include <job.h>
-#include <list.h>
-#include <misc.h>
-#include <network.h>
-
-
-static ns_printer_t *printer_object = NULL;
-static ns_bsd_addr_t *printer_addr = NULL;
-
-
-static char *_rank_suffixes[] = {
- "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"
-};
-
-static char *
-rank_string(const int rank)
-{
- static char buf[12];
-
- if (rank < 0)
- snprintf(buf, sizeof (buf), gettext("invalid"));
- else if (rank == 0)
- snprintf(buf, sizeof (buf), gettext("active"));
- else if ((rank > 10) && (rank < 14))
- sprintf(buf, "%dth", rank);
- else
- sprintf(buf, "%d%s", rank, _rank_suffixes[rank % 10]);
-
- return (buf);
-}
-
-
-
-/*
- * cascade_spooler_available() always returns 0, because it is really
- * used as a waiting space for contacting another spooler.
- */
-int
-cascade_spooler_available(const char *printer)
-{
- syslog(LOG_DEBUG, "cascade_spooler_available(%s)",
- (printer ? printer : "NULL"));
-
- if ((printer_object = ns_printer_get_name(printer, NULL)) == NULL)
- return (-1);
-
- if ((printer_addr = ns_bsd_addr_get_name((char *)printer)) == NULL)
- return (-1);
-
- return (0);
-}
-
-
-/*
- * cascade_client_access() always returns 0, because all requestors should
- * be allowed to cascade.
- */
-int
-cascade_client_access(const char *printer, const char *host)
-{
- syslog(LOG_DEBUG, "cascade_client_access(%s, %s)",
- (printer ? printer : "NULL"), (host ? host : "NULL"));
-
- return (0);
-}
-
-
-/*
- * cascade_spooler_accepting_jobs() always returns 0, because all requestors
- * should be allowed to cascade.
- */
-int
-cascade_spooler_accepting_jobs(const char *printer)
-{
- syslog(LOG_DEBUG, "cascade_spooler_accepting_jobs(%s)",
- (printer ? printer : "NULL"));
-
- return (0);
-}
-
-
-/*
- * cascade_temp_dir() returns the directory to be used as the working
- * directory for the cascaded spooler. All data files will be expected to
- * be stored and retreived from this directory
- */
-char *
-cascade_temp_dir(const char *printer, const char *host)
-{
- char *tmp = NULL;
-
- if ((tmp = ns_get_value_string("spool-dir", printer_object)) == NULL)
- tmp = strdup("/var/spool/print");
-
- syslog(LOG_DEBUG, "cascade_temp_dir(%s, %s) = %s",
- (printer ? printer : "NULL"), (host ? host : "NULL"), tmp);
-
- if ((access((const char *)tmp, F_OK) < 0) && (mkdir(tmp, 0755) < 0))
- return (NULL);
-
- return (tmp);
-}
-
-
-/*
- * cascade_restart_printer() always returns 0, because it should always be
- * processing if a job is waiting to cascade.
- */
-int
-cascade_restart_printer(const char *printer)
-{
- syslog(LOG_DEBUG, "cascade_restart_printer(%s)",
- (printer ? printer : "NULL"));
-
- start_daemon(1);
-
- return (0);
-}
-
-
-/*
- * cascade_submit_job() will save the control file data, write a binding
- * file and attempt to start a transfer agent.
- */
-int
-cascade_submit_job(const char *printer, const char *host, char *cf,
- char **df_list)
-{
- FILE *fp;
- char *s, *newcf, *user = NULL;
- int i;
- uid_t userid = -1;
- struct passwd *p = NULL;
-
- syslog(LOG_DEBUG, "cascade_submit_job(%s, %s, 0x%x, 0x%x)",
- (printer ? printer : "NULL"), (host ? host : "NULL"), cf,
- df_list);
-
- /*
- * Validate/Cleanup the control/metadata file.
- */
- if ((newcf = calloc(1, strlen(cf) + 1)) == NULL)
- return (-1);
- for (s = strtok(cf, "\n"); s != NULL; s = strtok(NULL, "\n")) {
- /*
- * If the first character is 'U' then make sure that the
- * filename does not contain '/'
- */
- if ((s[0] == CF_UNLINK) && (strchr(s, '/') != NULL)) {
- syslog(LOG_ALERT, "suspicious directive: %s", s);
- } else {
- strcat(newcf, s);
- strcat(newcf, "\n");
- }
- if (s[0] == CF_USER) /* RFC-1179 User */
- user = ++s;
- }
-
- /*
- * When printd comes to print the request, it will have the submitting
- * user's privileges so, having extracted the username from the BSD
- * control file, check the user is known to locally active passwd
- * databases and change ownership of the datafiles to the job owner.
- */
- if ((user != NULL) && (p = getpwnam(user)) != NULL) {
- syslog(LOG_DEBUG, "cascade_submit_job: user = %s\n", user);
- userid = p->pw_uid;
- syslog(LOG_DEBUG, "cascade_submit_job: userid = %d\n", userid);
- }
-
- if (userid > 0)
- for (i = 0; df_list[i] != NULL; i++) {
- syslog(LOG_DEBUG, "cascade_submit_job: dffile = %s\n",
- df_list[i]);
- if ((chown(df_list[i], userid, -1)) < 0)
- syslog(LOG_DEBUG,
- "cascade_submit_job: chown failed");
- else
- syslog(LOG_DEBUG,
- "cascade_submit_job: chown succeeded");
- }
-
- /* write the control file */
- df_list[0][0] = 'c';
-
- /*
- * Applying lock when bsd-gw is writing control file
- * in /var/spool/print directory
- */
- if (((fp = fopen(df_list[0], "w")) != NULL) &&
- ((lockf(fileno(fp), F_LOCK, 0)) == 0)) {
- fprintf(fp, "%s", newcf);
- free(newcf);
- fclose(fp);
- } else {
- free(newcf);
- return (-1);
- }
-
- /* write a binding file */
- df_list[0][0] = 'x';
-
- /*
- * Applying lock when bsd-gw is writing xfile
- * in /var/spool/print directory
- */
- if (((fp = fopen(df_list[0], "w")) != NULL) &&
- ((lockf(fileno(fp), F_LOCK, 0)) == 0)) {
- fprintf(fp, "%s:%s\n", printer_addr->server,
- printer_addr->printer);
- fclose(fp);
- } else {
- df_list[0][0] = 'c';
- unlink(df_list[0]);
- return (-1);
- }
-
- start_daemon(1);
-
- return (0);
-}
-
-
-/*
- * cascade_show_queue() will relay job information from a remote spooler
- * and then add any local jobs waiting to cascade to the same destination.
- */
-int
-cascade_show_queue(const char *printer, FILE *ofp, const int type,
- const char **list)
-{
- int fd;
- job_t **jobs = NULL;
-
- syslog(LOG_DEBUG, "cascade_show_queue(%s, 0x%x, %d, 0x%x)",
- (printer ? printer : "NULL"), ofp, type, list);
-
- /* get the remote list first */
- if ((fd = net_open(printer_addr->server, 5)) >= 0) {
- char buf[BUFSIZ];
- char **jlist = (char **)list;
-
- snprintf(buf, sizeof (buf), "%c%s", type,
- (printer_addr->printer ? printer_addr->printer :
- printer));
- while ((jlist != NULL) && (*jlist != NULL)) {
- strlcat(buf, " ", sizeof (buf));
- strlcat(buf, *jlist++, sizeof (buf));
- }
-
- net_printf(fd, "%s\n", buf);
- while (net_gets(buf, sizeof (buf), fd) != NULL)
- fputs(buf, ofp);
-
- close(fd);
- } else
- fprintf(ofp, gettext("can't connect to %s\n"),
- printer_addr->server);
-
- /* list any "local" jobs */
- if ((jobs = job_list_append(NULL, (char *)printer,
- NULL, ".")) != NULL) {
- int rank = 1;
-
- while (*jobs != NULL) {
- if (type == 3) {
- fprintf(ofp,
- gettext("%-7.7s %8.8s %5d "
- "%-32.32s %8d bytes\n"),
- rank_string(rank++), (*jobs)->job_user,
- (*jobs)->job_id, "files", -1);
- } else {
- fprintf(ofp,
- gettext("%-8s:%-7s\t\t\t[ job %d%s ]\n"),
- (*jobs)->job_user, rank_string(rank++),
- (*jobs)->job_id, (*jobs)->job_host);
-
- }
- jobs++;
- }
- }
-
- return (0);
-}
-
-
-/*
- * cascade_cancel_job() will remove any matching jobs waiting to cascade to
- * the remote system, and then request the remote system to remove any
- * matching jobs.
- */
-int
-cascade_cancel_job(const char *printer, FILE *ofp, const char *user,
- const char *host, const char **list)
-{
- int fd;
- job_t **jobs = NULL;
-
- syslog(LOG_DEBUG, "cascade_cancel_job(%s, 0x%x, %s, %s, 0x%x)",
- (printer ? printer : "NULL"), ofp, (user ? user : "NULL"),
- (host ? host : "NULL"), list);
-
- /* cancel "local" jobs */
- if ((jobs = job_list_append(NULL, (char *)printer,
- (char *)host, ".")) != NULL)
- list_iterate((void **)jobs, (VFUNC_T)vjob_cancel, user,
- printer, host, list);
-
- /* ask the remote system next */
- if ((fd = net_open(printer_addr->server, 5)) >= 0) {
- char buf[BUFSIZ];
- char **jlist = (char **)list;
-
- snprintf(buf, sizeof (buf), "%c%s %s", 5,
- (printer_addr->printer ? printer_addr->printer :
- printer), user);
- while ((jlist != NULL) && (*jlist != NULL)) {
- strlcat(buf, " ", sizeof (buf));
- strlcat(buf, *jlist++, sizeof (buf));
- }
-
- net_printf(fd, "%s\n", buf);
- while (net_gets(buf, sizeof (buf), fd) != NULL)
- fputs(buf, ofp);
-
- close(fd);
- } else
- fprintf(ofp, gettext("can't connect to %s\n"),
- printer_addr->server);
-
- return (0);
-}
diff --git a/usr/src/cmd/print/gateway/translators/test/Makefile b/usr/src/cmd/print/gateway/translators/test/Makefile
deleted file mode 100644
index 301e3b8649..0000000000
--- a/usr/src/cmd/print/gateway/translators/test/Makefile
+++ /dev/null
@@ -1,70 +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.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-LIBRARY = bsd_test.a
-VERS=.1
-
-OBJECTS = test.o
-
-include ../../../../../lib/Makefile.lib
-include ../../../Makefile.sp
-
-# There should be a mapfile here
-MAPFILES =
-
-ROOTLIBDIR= $(ROOT)/usr/lib/print/bsd-adaptor
-
-#CPPFLAGS += -I$(LPINC)
-CPPFLAGS += -I$(NPRTINC)
-LDLIBS += -lprint -lc # with XFN API
-#LDLIBS += $(LIBCLS) $(LIBPRT) $(LIBMSG)
-
-LIBS = $(DYNLIB) # could be += for static and dynamic
-SRCS= $(OBJECTS:%.o=%.c)
-
-CLOBBERFILES= llib-lbsd_test.a.ln lint.out
-
-.KEEP_STATE:
-
-all : $(LIBS)
-
-install: $(ROOTLIBDIR) $(ROOTLIBS) $(ROOTLINKS)
-
-cstyle:
- cstyle $(SRCS)
-
-lint:
- $(LINT.c) $(SRCS)
-strip:
-
-_msg:
- @echo "Messages are made in usr/src/cmd/print"
-
-$(ROOTLIBDIR):
- $(INS.dir)
-
-include ../../../../../lib/Makefile.targ
diff --git a/usr/src/cmd/print/gateway/translators/test/README b/usr/src/cmd/print/gateway/translators/test/README
deleted file mode 100644
index 229a57b38e..0000000000
--- a/usr/src/cmd/print/gateway/translators/test/README
+++ /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, Version 1.0 only
-# (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 2000 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
- ident "%Z%%M% %I% %E% SMI"
-
-This file describes how to use the "test" translator...
-
-The "test" translator is design to provide a simple method of testing the
-printing protocol adaptor front-end, and BSD protocol client side functionality.The translator is a loadable module implementing the adaptor API. It relies
-heavily on the naming interface (printers.conf) to determine the action it
-should take.
-
-The following Keys have been defined:
-
-Key description
-test-log log file name (string)
-test-dir working dir (string)
-test-spooler-available spooler running (boolean)
-test-access access allowed (boolean)
-test-restart restart allowed (boolean)
-test-submit submission allowed (boolean)
-test-show-queue-state status line (string)
-test-show-queue-file status data file (string)
-test-cancel-job-file cancel data file (string)
-
-a sample entry might look like:
-
-test:\
- :bsdaddr=test,localhost,Solaris:\
- :spooling-paradigm=test:\
- :test-log=/tmp/test_printer/log:\
- :test-dir=/tmp/test_printer:\
- :test-access=true:\
- :test-restart=true:\
- :test-submit=true:\
- :test-show-queue-state=out of paper:\
- :test-show-queue-file=/tmp/test_printer/show-queue:\
- :test-cancel-job-file=/tmp/test_printer/cancel-job:
-
diff --git a/usr/src/cmd/print/gateway/translators/test/test.c b/usr/src/cmd/print/gateway/translators/test/test.c
deleted file mode 100644
index 1749e5c2e8..0000000000
--- a/usr/src/cmd/print/gateway/translators/test/test.c
+++ /dev/null
@@ -1,238 +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 <string.h>
-#include <stdarg.h>
-#include <syslog.h>
-
-#include <ns.h>
-
-
-static ns_printer_t *printer_object = NULL;
-static FILE *lfp = NULL;
-
-
-static void
-log_printf(char *fmt, ...)
-{
- if (lfp != NULL) {
- va_list ap;
-
- va_start(ap, fmt);
- (void) vfprintf(lfp, fmt, ap);
- va_end(ap);
- (void) fflush(lfp);
- }
-}
-
-
-int
-test_spooler_available(const char *printer)
-{
- int rc = 0;
- char *tmp;
-
- if ((printer_object = ns_printer_get_name(printer, NULL)) == NULL)
- return (-1);
-
- if ((tmp = ns_get_value_string("test-log", printer_object)) != NULL)
- lfp = fopen(tmp, "a+");
-
- if (((tmp = ns_get_value_string("test-spooler-available",
- printer_object)) != NULL) &&
- (strcasecmp(tmp, "false") == 0))
- rc = -1;
-
- log_printf("test_spooler_available(%s): "
- "test-spooler-available = %s (%d)\n",
- (printer ? printer : "NULL"), (tmp ? tmp : "NULL"), rc);
-
- return (rc);
-}
-
-
-int
-test_spooler_accepting_jobs(const char *printer)
-{
- int rc = 0;
- char *tmp;
-
- if (((tmp = ns_get_value_string("test-accepting", printer_object))
- != NULL) && (strcasecmp(tmp, "false") == 0))
- rc = -1;
-
- log_printf(
- "test_spooler_accepting_jobs(%s): test-accepting = %s (%d)\n",
- (printer ? printer : "NULL"), (tmp ? tmp : "NULL"), rc);
-
- return (rc);
-}
-
-
-int
-test_client_access(const char *printer, const char *host)
-{
- int rc = 0;
- char *tmp;
-
- if (((tmp = ns_get_value_string("test-access", printer_object))
- != NULL) && (strcasecmp(tmp, "false") == 0))
- rc = -1;
-
- log_printf("test_client_access(%s, %s): test-access = %s (%d)\n",
- (printer ? printer : "NULL"), (host ? host : "NULL"),
- (tmp ? tmp : "NULL"), rc);
-
- return (rc);
-}
-
-
-char *
-test_temp_dir(const char *printer, const char *host)
-{
- char *tmp;
-
- if ((tmp = ns_get_value_string("test-dir", printer_object)) == NULL)
- tmp = strdup("/tmp");
-
- log_printf("test_temp_dir(%s, %s): test-dir = %s\n",
- (printer ? printer : "NULL"), (host ? host : "NULL"),
- (tmp ? tmp : "NULL"));
-
- return (tmp);
-}
-
-
-int
-test_restart_printer(const char *printer)
-{
- int rc = 0;
- char *tmp;
-
- if (((tmp = ns_get_value_string("test-restart", printer_object))
- != NULL) && (strcasecmp(tmp, "false") == 0))
- rc = -1;
-
- log_printf("test_restart_printer(%s): test-restart = %s (%d)\n",
- (printer ? printer : "NULL"), (tmp ? tmp : "NULL"), rc);
-
- return (rc);
-}
-
-
-int
-test_submit_job(const char *printer, const char *host, char *cf,
- char **df_list)
-{
- FILE *fp;
- char *tmp;
-
- if (((tmp = ns_get_value_string("test-submit", printer_object))
- != NULL) && (strcasecmp(tmp, "false") == 0))
- return (-1);
-
- df_list[0][0] = 'c';
- if ((fp = fopen(df_list[0], "w")) != 0) {
- (void) fprintf(fp, "%s", cf);
- (void) fclose(fp);
- }
- df_list[0][0] = 'c';
-
- log_printf("test_submit_job(%s, %s): test-submit = %s\n",
- (printer ? printer : "NULL"), (host ? host : "NULL"),
- (tmp ? tmp : "NULL"));
- log_printf("\tcontrol = %s\n", df_list[0]);
- df_list[0][0] = 'd';
- while (*df_list != NULL)
- log_printf("\tdata = %s\n", *df_list++);
-
- return (0);
-}
-
-
-int
-test_show_queue(const char *printer, FILE *ofp, const int type,
- const char **list)
-{
- char *file = NULL;
- FILE *fp;
-
- if (((file = ns_get_value_string("test-show-queue-file",
- printer_object)) != NULL) &&
- ((fp = fopen(file, "r+")) != NULL)) {
- char buf[1024];
-
- while (fgets(buf, sizeof (buf), fp) != NULL)
- (void) fputs(buf, ofp);
- (void) fclose(fp);
- } else
- (void) fprintf(ofp, "no entries\n");
-
- log_printf("test_show_queue(%s, 0x%x, %s):\n",
- (printer ? printer : "NULL"), ofp,
- (type == 3 ? "short" : "long"));
- log_printf("\tfile = %s\n", (file ? file : "NULL"));
- while (*list != NULL)
- log_printf("\tjob or user = %s\n", *list++);
-
- return (0);
-}
-
-
-int
-test_cancel_job(const char *printer, FILE *ofp, const char *user,
- const char *host, const char **list)
-{
- char *file = NULL;
-
- if ((file = ns_get_value_string("test-cancel-job-file", printer_object))
- != NULL)
-
- if (file != NULL) {
- FILE *fp;
- char buf[1024];
-
- if ((fp = fopen(file, "r+")) != NULL) {
- while (fgets(buf, sizeof (buf), fp) != NULL)
- (void) fputs(buf, ofp);
- (void) fclose(fp);
- }
- }
-
- log_printf("test_cancel_job(%s, 0x%x, %s, %s):\n",
- (printer ? printer : "NULL"), ofp, (user ? user : "NULL"),
- (host ? host : "NULL"));
- while (*list != NULL)
- log_printf("\tjob or user = %s\n", *list++);
-
- return (0);
-}
diff --git a/usr/src/cmd/print/scripts/lpadmin b/usr/src/cmd/print/scripts/lpadmin
index ae9f6cd9e6..f605306b1e 100644
--- a/usr/src/cmd/print/scripts/lpadmin
+++ b/usr/src/cmd/print/scripts/lpadmin
@@ -32,6 +32,7 @@ export TEXTDOMAIN
LPSET=/usr/bin/lpset
LPGET=/usr/bin/lpget
+LPSTAT=/usr/bin/lpstat
LPADMIN=/usr/lib/lp/local/lpadmin
HOST=$(/bin/uname -n)
@@ -181,6 +182,7 @@ do
if [[ ! -n "${server}" ]] ; then
server=${HOST}
fi
+ local="true"
;;
x)
if [[ -n "${printer}" || -n "${server}" || \
@@ -269,17 +271,27 @@ case "${server}" in
;;
esac
-# default URI form is "lpd" form
if [[ -n "${server}" ]] ; then
- uri=${uri:-"lpd://${server}/printers/${rem_printer}#Solaris"}
+ # if we need a uri, find the "best" one.
+ if [[ -z "${uri}" ]] ; then
+ uri="ipp://${server}/printers/${rem_printer}"
+ ${LPSTAT} -p ${uri} >/dev/null 2>&1
+ if [[ $? -ne 0 ]] ; then
+ uri="lpd://${server}/printers/${rem_printer}#Solaris"
+ fi
+ fi
+ # set the bsdaddr
bsdaddr="${server},${rem_printer},Solaris"
fi
+# if there is a "device" or LP configuration, it's local
+if [[ -n "${device}" || -f /etc/lp/printers/${printer}/configuration || \
+ -f /etc/lp/classes/${printer} ]] ; then
+ local="true"
+fi
# Do the LP configuration for a local printer served by lpsched
-if [[ -x ${LPADMIN} && ( -n "${local}" || -n "${device}" || \
- -f /etc/lp/printers/${printer}/configuration || \
- -f /etc/lp/classes/${printer} ) ]] ; then
+if [[ -x ${LPADMIN} && -n "${local}" ]] ; then
# enumerate LP configured printers before modification
PRE=$(/bin/ls /etc/lp/printers 2>/dev/null ; /bin/ls /etc/lp/classes \
2>/dev/null)
@@ -321,11 +333,11 @@ fi
if [[ -n "${delete}" ]] ; then
if [[ "${delete}" = "all" ]] ; then
[[ $exit_code -eq 0 ]] && delete_all
- elif [[ -n "${local}" ]] ; then
+ elif [[ -z "${local}" ]] ; then
${LPSET} -n system -x ${delete}
exit_code=$?
fi
-elif [[ -n "${local}" ]] ; then
+elif [[ -z "${local}" ]] ; then
if [[ -n "${printer}" ]] ; then
${LPSET} -n system \
-a "printer-uri-supported=${uri}" \
diff --git a/usr/src/lib/print/libhttp-core/common/http.c b/usr/src/lib/print/libhttp-core/common/http.c
index 83a0790022..b32b1eb3bc 100644
--- a/usr/src/lib/print/libhttp-core/common/http.c
+++ b/usr/src/lib/print/libhttp-core/common/http.c
@@ -191,7 +191,7 @@ static const char * const months[12] =
};
void
-httpDumpData(FILE *fp, char *tag, char *buffer, int bytes)
+httpDumpData(FILE *fp, const char *tag, const char *buffer, int bytes)
{
int i, j, ch;
diff --git a/usr/src/lib/print/libhttp-core/common/http.h b/usr/src/lib/print/libhttp-core/common/http.h
index da36b461a3..593b7b68f6 100644
--- a/usr/src/lib/print/libhttp-core/common/http.h
+++ b/usr/src/lib/print/libhttp-core/common/http.h
@@ -420,6 +420,9 @@ extern char *httpAddrLookup(const http_addr_t *addr,
extern char *httpAddrString(const http_addr_t *addr,
char *s, int slen);
+#include <stdio.h>
+extern void httpDumpData(FILE *, const char *, const char *, int);
+
/*
* C++ magic...
diff --git a/usr/src/lib/print/libipp-listener/common/ipp-listener.c b/usr/src/lib/print/libipp-listener/common/ipp-listener.c
index 9163ddffa3..fc46366ea0 100644
--- a/usr/src/lib/print/libipp-listener/common/ipp-listener.c
+++ b/usr/src/lib/print/libipp-listener/common/ipp-listener.c
@@ -39,9 +39,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <unistd.h>
+#include <sys/systeminfo.h>
#include <papi.h>
#include <ipp-listener.h>
+#include <uri.h>
typedef papi_status_t (ipp_handler_t)(papi_service_t svc,
papi_attribute_t **request,
@@ -360,6 +363,61 @@ ipp_initialize_response(papi_attribute_t **request,
return (PAPI_OK);
}
+/* simplistic check for cyclical service references */
+static int
+cyclical_service_check(char *svc_name, int port)
+{
+ papi_attribute_t **list;
+ char buf[BUFSIZ];
+ uri_t *uri = NULL;
+ char *s = NULL;
+
+ /* was there a service_uri? */
+ if (svc_name == NULL)
+ return (0);
+
+ if ((list = getprinterbyname(svc_name, NULL)) == NULL)
+ return (0); /* if it doesnt' resolve, we will fail later */
+
+ papiAttributeListGetString(list, NULL, "printer-uri-supported", &s);
+ if ((s == NULL) || (strcasecmp(svc_name, s) != 0))
+ return (0); /* they don't match */
+
+ /* is it in uri form? */
+ if (uri_from_string(s, &uri) < 0)
+ return (0);
+
+ if ((uri == NULL) || (uri->scheme == NULL) || (uri->host == NULL)) {
+ uri_free(uri);
+ return (0);
+ }
+
+ /* is it ipp form */
+ if (strcasecmp(uri->scheme, "ipp") != 0) {
+ uri_free(uri);
+ return (0);
+ }
+
+ /* does the host match up */
+ sysinfo(SI_HOSTNAME, buf, sizeof (buf));
+ if ((strcasecmp(uri->host, "localhost") != 0) &&
+ (strcasecmp(uri->host, buf) != 0)) {
+ uri_free(uri);
+ return (0);
+ }
+
+ /* does the port match our own */
+ if (((uri->port == NULL) && (port != 631)) ||
+ ((uri->port != NULL) && (atoi(uri->port) != port))) {
+ uri_free(uri);
+ return (0);
+ }
+
+ uri_free(uri);
+
+ return (1);
+}
+
static papi_status_t
print_service_connect(papi_service_t *svc, papi_attribute_t **request,
papi_attribute_t ***response)
@@ -369,6 +427,7 @@ print_service_connect(papi_service_t *svc, papi_attribute_t **request,
char *printer_uri = NULL;
char *svc_name = NULL;
char *user = NULL;
+ int port = 631;
/* Get the operational attributes group from the request */
(void) papiAttributeListGetCollection(request, NULL,
@@ -384,6 +443,15 @@ print_service_connect(papi_service_t *svc, papi_attribute_t **request,
"default-service", &svc_name);
get_printer_id(operational, &svc_name, NULL);
+ /* get the port that we are listening on */
+ (void) papiAttributeListGetInteger(request, NULL, "uri-port", &port);
+
+ if (cyclical_service_check(svc_name, port) != 0) {
+ status = PAPI_NOT_POSSIBLE;
+ ipp_set_status(response, status, "printer-uri is cyclical");
+ return (status);
+ }
+
status = papiServiceCreate(svc, svc_name, user, NULL, NULL,
PAPI_ENCRYPT_NEVER, NULL);
if (status != PAPI_OK) {
diff --git a/usr/src/lib/print/libpapi-common/common/attribute.c b/usr/src/lib/print/libpapi-common/common/attribute.c
index 2b2e035cfe..4fd9f01a19 100644
--- a/usr/src/lib/print/libpapi-common/common/attribute.c
+++ b/usr/src/lib/print/libpapi-common/common/attribute.c
@@ -387,7 +387,7 @@ papiAttributeListDelete(papi_attribute_t ***list, char *name)
if ((attribute = papiAttributeListFind(*list, name)) == NULL)
return (PAPI_NOT_FOUND);
- list_remove(*list, attribute);
+ list_remove(list, attribute);
papiAttributeFree(attribute);
return (PAPI_OK);
diff --git a/usr/src/lib/print/libpapi-common/common/common.c b/usr/src/lib/print/libpapi-common/common/common.c
index 318b1d2c83..c14515417b 100644
--- a/usr/src/lib/print/libpapi-common/common/common.c
+++ b/usr/src/lib/print/libpapi-common/common/common.c
@@ -130,3 +130,6 @@ papiJobGetId(papi_job_t job)
#pragma weak papiJobGetJobTicket = _unsupported_null_return
#pragma weak papiJobFree = _unsupported_no_return
#pragma weak papiJobListFree = _unsupported_no_return
+
+/* private functions */
+#pragma weak getprinterbyname = _unsupported_null_return
diff --git a/usr/src/lib/print/libpapi-common/common/list.c b/usr/src/lib/print/libpapi-common/common/list.c
index 9ed0d2ded2..ddd29a76df 100644
--- a/usr/src/lib/print/libpapi-common/common/list.c
+++ b/usr/src/lib/print/libpapi-common/common/list.c
@@ -60,6 +60,8 @@ list_append(void ***list, void *item)
__list_increment;
new_list = (void **)calloc(new_size, sizeof (void *));
+ if (new_list == NULL)
+ return (-1);
for (count = 0; (*list)[count] != NULL; count++)
new_list[count] = (*list)[count];
@@ -136,26 +138,36 @@ list_locate(void **list, int (*compare)(void *, void *), void *element)
}
void
-list_remove(void **list, void *item)
+list_remove(void ***list, void *item)
{
- int i, last;
-
- if ((list == NULL) || (*list == NULL) || (item == NULL))
- return;
-
- for (last = 0; list[last] != NULL; last++)
- ;
- --last;
-
- /*
- * This doesn't preserve order, and doesn't shrink the allocation if we
- * go below % __list_increment == 0. <shrug>
- */
- for (i = 0; list[i] != NULL; i++) {
- if (list[i] == item) {
- list[i] = list[last];
- list[last] = NULL;
- break;
- }
+ int i, count;
+ void **tmp = NULL;
+
+ if ((list == NULL) || (*list == NULL) || (item == NULL))
+ return;
+
+ for (count = 0; (*list)[count] != NULL; count++)
+ ;
+
+ if (count > 0) {
+ int new_size = (((count + 1) / __list_increment) + 1) *
+ __list_increment;
+
+ if ((tmp = (void **)calloc(new_size, sizeof (void *))) != NULL)
+ tmp = *list;
+
+ /* copy up to item */
+ for (i = 0; (((*list)[i] != NULL) && ((*list)[i] != item)); i++)
+ tmp[i] = (*list)[i];
+ /* copy after item */
+ if ((*list)[i] == item)
+ for (++i; ((*list)[i] != NULL); i++)
+ tmp[i-1] = (*list)[i];
+ }
+
+ /* replace the list */
+ if (tmp != *list) {
+ free(*list);
+ *list = tmp;
}
}
diff --git a/usr/src/lib/print/libpapi-common/common/mapfile b/usr/src/lib/print/libpapi-common/common/mapfile
index a187eb4da8..729e6f3abb 100644
--- a/usr/src/lib/print/libpapi-common/common/mapfile
+++ b/usr/src/lib/print/libpapi-common/common/mapfile
@@ -134,11 +134,15 @@ SUNWprivate_1.0 { # Misc. semi-private supporting calls
uri_from_string;
uri_to_string;
uri_free;
+
# list
list_remove;
list_append;
list_concatenate;
+ # NS
+ getprinterbyname;
+
# extra Attribute Calls
copy_attributes;
split_and_copy_attributes;
diff --git a/usr/src/lib/print/libpapi-common/common/papi.h b/usr/src/lib/print/libpapi-common/common/papi.h
index 7c1d891eb2..b84e7904ac 100644
--- a/usr/src/lib/print/libpapi-common/common/papi.h
+++ b/usr/src/lib/print/libpapi-common/common/papi.h
@@ -441,6 +441,8 @@ extern void split_and_copy_attributes(char **list,
papi_attribute_t ***in,
papi_attribute_t ***out);
+extern papi_attribute_t **getprinterbyname(char *name, char *ns);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/lib/print/libpapi-dynamic/common/mapfile b/usr/src/lib/print/libpapi-dynamic/common/mapfile
index 2cd1ca7fe4..41734836cb 100644
--- a/usr/src/lib/print/libpapi-dynamic/common/mapfile
+++ b/usr/src/lib/print/libpapi-dynamic/common/mapfile
@@ -139,6 +139,8 @@ SUNWprivate_1.0 {
list_remove = FUNCTION FILTER libpapi-common.so ;
list_append = FUNCTION FILTER libpapi-common.so ;
list_concatenate = FUNCTION FILTER libpapi-common.so ;
+ # NS
+ getprinterbyname ;
# extra Attribute Calls
copy_attributes = FUNCTION FILTER libpapi-common.so ;
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 f0f6ced38d..9e648de23c 100644
--- a/usr/src/lib/print/libpapi-ipp/common/ipp-support.c
+++ b/usr/src/lib/print/libpapi-ipp/common/ipp-support.c
@@ -40,6 +40,8 @@
#include <config-site.h>
+#include <ipp.h>
+
papi_status_t
http_to_papi_status(http_status_t status)
{
diff --git a/usr/src/lib/print/libpapi-ipp/common/mapfile b/usr/src/lib/print/libpapi-ipp/common/mapfile
index ca9a53f0a4..918398aa74 100644
--- a/usr/src/lib/print/libpapi-ipp/common/mapfile
+++ b/usr/src/lib/print/libpapi-ipp/common/mapfile
@@ -139,6 +139,8 @@ SUNWprivate_1.0 {
list_remove = FUNCTION FILTER libpapi-common.so ;
list_append = FUNCTION FILTER libpapi-common.so ;
list_concatenate = FUNCTION FILTER libpapi-common.so ;
+ # NS
+ getprinterbyname = FUNCTION FILTER libpapi-common.so ;
# extra Attribute Calls
copy_attributes = FUNCTION FILTER libpapi-common.so ;
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 3d36fef99d..6d9976825f 100644
--- a/usr/src/lib/print/libpapi-lpd/common/lpd-job.c
+++ b/usr/src/lib/print/libpapi-lpd/common/lpd-job.c
@@ -49,7 +49,7 @@ static char
mime_type_to_rfc1179_type(char *mime)
{
static struct { char *mime; char rfc; } cvt[] = {
- { "plain/text", 'f' },
+ { "text/plain", 'f' },
{ "application/octet-stream", 'l' },
{ "application/postscript", 'f' }, /* rfc incorrectly has 'o' */
{ "application/x-pr", 'p' },
@@ -422,7 +422,7 @@ papi_status_t
lpd_job_add_files(service_t *svc, papi_attribute_t **attributes,
char **files, char **metadata, papi_attribute_t ***used)
{
- char *format = "plain/text";
+ char *format = "text/plain";
char rfc_fmt = 'l';
int copies = 1;
char host[BUFSIZ];
diff --git a/usr/src/lib/print/libpapi-lpd/common/mapfile b/usr/src/lib/print/libpapi-lpd/common/mapfile
index d21b349ff7..257a97becf 100644
--- a/usr/src/lib/print/libpapi-lpd/common/mapfile
+++ b/usr/src/lib/print/libpapi-lpd/common/mapfile
@@ -139,6 +139,8 @@ SUNWprivate_1.0 {
list_remove = FUNCTION FILTER libpapi-common.so ;
list_append = FUNCTION FILTER libpapi-common.so ;
list_concatenate = FUNCTION FILTER libpapi-common.so ;
+ # NS
+ getprinterbyname = FUNCTION FILTER libpapi-common.so ;
# extra Attribute Calls
copy_attributes = FUNCTION FILTER libpapi-common.so ;
diff --git a/usr/src/pkgdefs/SUNWpcr/prototype_com b/usr/src/pkgdefs/SUNWpcr/prototype_com
index 9655e7547d..f39954b77a 100644
--- a/usr/src/pkgdefs/SUNWpcr/prototype_com
+++ b/usr/src/pkgdefs/SUNWpcr/prototype_com
@@ -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 2004 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
@@ -53,11 +52,6 @@ d none var/svc 755 root sys
d none var/svc/manifest 755 root sys
d none var/svc/manifest/application 755 root sys
d none var/svc/manifest/application/print 755 root sys
-f manifest var/svc/manifest/application/print/cleanup.xml 0444 root sys
f manifest var/svc/manifest/application/print/rfc1179.xml 0444 root sys
-d none lib 755 root bin
-d none lib/svc 0755 root bin
-d none lib/svc/method 0755 root bin
-f none lib/svc/method/print-cleanup 0555 root bin
d none var/spool 755 root bin
d none var/spool/print 0755 root lp
diff --git a/usr/src/pkgdefs/SUNWpcu/Makefile b/usr/src/pkgdefs/SUNWpcu/Makefile
index e19a81f92d..13b1c681aa 100644
--- a/usr/src/pkgdefs/SUNWpcu/Makefile
+++ b/usr/src/pkgdefs/SUNWpcu/Makefile
@@ -33,6 +33,7 @@ DATAFILES += depend
ACTION=grep SUNWpcr depend > /dev/null || \
( chmod 666 depend; \
echo "P SUNWpcr Solaris Print - Client, (root)" >> depend; \
+ echo "P SUNWpapi Free Standards Group Open Printing API" >> depend; \
echo "I SUNWlpu LP Print Service, (usr)" >> depend; \
chmod 444 depend );
diff --git a/usr/src/pkgdefs/SUNWpcu/prototype_com b/usr/src/pkgdefs/SUNWpcu/prototype_com
index 7819733540..dbbac2b647 100644
--- a/usr/src/pkgdefs/SUNWpcu/prototype_com
+++ b/usr/src/pkgdefs/SUNWpcu/prototype_com
@@ -53,17 +53,11 @@ s none usr/lib/libprint.so=./libprint.so.2
s none usr/lib/lpadmin=../sbin/lpadmin
s none usr/lib/lpsystem=../sbin/lpsystem
d none usr/lib/print 0755 root lp
-d none usr/lib/print/bsd-adaptor 0755 root lp
-f none usr/lib/print/bsd-adaptor/bsd_cascade.so.1 0755 root lp
-s none usr/lib/print/bsd-adaptor/bsd_cascade.so=./bsd_cascade.so.1
-f none usr/lib/print/bsd-adaptor/bsd_test.so.1 0755 root lp
-s none usr/lib/print/bsd-adaptor/bsd_test.so=./bsd_test.so.1
f none usr/lib/print/Makefile.yp 0444 root lp
f none usr/lib/print/in.lpd 0555 root bin
f none usr/lib/print/conv_fix 0555 root lp
f none usr/lib/print/conv_lp 0555 root lp
f none usr/lib/print/conv_lpd 0555 root lp
-f none usr/lib/print/printd 0555 root bin
d none usr/sbin 0755 root bin
f none usr/sbin/lpadmin 0555 root lp
f none usr/sbin/lpsystem 0555 root lp
diff --git a/usr/src/pkgdefs/SUNWpsu/prototype_com b/usr/src/pkgdefs/SUNWpsu/prototype_com
index 4449bf7ebe..9f4b8baf2c 100644
--- a/usr/src/pkgdefs/SUNWpsu/prototype_com
+++ b/usr/src/pkgdefs/SUNWpsu/prototype_com
@@ -75,12 +75,8 @@ f none usr/sbin/lpfilter 555 root lp
f none usr/sbin/lpforms 555 root lp
f none usr/sbin/lpusers 555 root lp
f none usr/sbin/lpshut 555 root lp
-# protocol adaptor
-d none usr/lib/print 0755 root lp
-d none usr/lib/print/bsd-adaptor 0755 root lp
-f none usr/lib/print/bsd-adaptor/bsd_lpsched.so.1 0755 root lp
-s none usr/lib/print/bsd-adaptor/bsd_lpsched.so=./bsd_lpsched.so.1
# PAPI lpsched service module
+d none usr/lib/print 0755 root lp
f none usr/lib/print/psm-lpsched.so.1 0755 root lp
s none usr/lib/print/psm-lpsched.so=./psm-lpsched.so.1
# terminfo entries for printers