From e67e2f9e9fc479417e4afc0011c74b49f3796d7e Mon Sep 17 00:00:00 2001 From: msweet Date: Mon, 19 Oct 2015 18:49:28 +0000 Subject: [PATCH] Interface scripts are no longer supported for security reasons () git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12904 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES.txt | 4 +- doc/help/man-cups-lpd.html | 2 +- doc/help/man-cups-snmp.html | 2 +- doc/help/man-cupsaddsmb.html | 2 +- doc/help/man-cupsd.html | 4 +- doc/help/man-filter.html | 5 +- doc/help/man-lpadmin.html | 13 +-- doc/help/man-lpoptions.html | 2 +- doc/help/spec-design.html | 2 +- doc/help/spec-ipp.html | 5 +- man/filter.man | 7 +- man/lpadmin.man | 17 ++-- packaging/cups.list.in | 3 +- packaging/cups.spec.in | 1 - scheduler/Makefile | 2 - scheduler/cups-driverd.cxx | 6 ++ scheduler/ipp.c | 178 ++++++++++++----------------------- scheduler/printers.c | 71 ++++---------- systemv/lpadmin.c | 27 +----- systemv/lpstat.c | 12 +-- 20 files changed, 118 insertions(+), 247 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index fda644dc5..05722be21 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,7 +1,9 @@ -CHANGES.txt - 2.2b1 - 2015-10-08 +CHANGES.txt - 2.2b1 - 2015-10-19 -------------------------------- CHANGES IN CUPS V2.2b1 - The cupsd domain socket is no longer world-accessible on OS X () + - Interface scripts are no longer supported for security reasons + () \ No newline at end of file diff --git a/doc/help/man-cups-lpd.html b/doc/help/man-cups-lpd.html index b4f1184e0..697518ac0 100644 --- a/doc/help/man-cups-lpd.html +++ b/doc/help/man-cups-lpd.html @@ -108,7 +108,7 @@ service using the corresponding control program. CUPS Online Help (http://localhost:631/help), RFC 2569

Copyright

-Copyright © 2007-2014 by Apple Inc. +Copyright © 2007-2015 by Apple Inc. diff --git a/doc/help/man-cups-snmp.html b/doc/help/man-cups-snmp.html index 06a48133f..faa57639d 100644 --- a/doc/help/man-cups-snmp.html +++ b/doc/help/man-cups-snmp.html @@ -48,7 +48,7 @@ The CUPS SNMP backend uses the information from the Host, Printer, and Port Moni lpinfo(8), CUPS Online Help (http://localhost:631/help)

Copyright

-Copyright © 2007-2014 by Apple Inc. +Copyright © 2007-2015 by Apple Inc. diff --git a/doc/help/man-cupsaddsmb.html b/doc/help/man-cupsaddsmb.html index 622d30a7d..cb2901e27 100644 --- a/doc/help/man-cupsaddsmb.html +++ b/doc/help/man-cupsaddsmb.html @@ -115,7 +115,7 @@ This is useful for debugging SAMBA configuration problems. smb.conf(5), CUPS Online Help (http://localhost:631/help)

Copyright

-Copyright © 2007-2014 by Apple Inc. +Copyright © 2007-2015 by Apple Inc. diff --git a/doc/help/man-cupsd.html b/doc/help/man-cupsd.html index 8f90f447c..de1294217 100644 --- a/doc/help/man-cupsd.html +++ b/doc/help/man-cupsd.html @@ -14,7 +14,7 @@ cupsd - cups scheduler [ -c config-file -] [ +] [ -f ] [ -F @@ -111,7 +111,7 @@ in the foreground with a test configuration file called systemd(8), CUPS Online Help (http://localhost:631/help)

Copyright

-Copyright © 2007-2014 by Apple Inc. +Copyright © 2007-2015 by Apple Inc. diff --git a/doc/help/man-filter.html b/doc/help/man-filter.html index bb4f620bc..33a35563e 100644 --- a/doc/help/man-filter.html +++ b/doc/help/man-filter.html @@ -163,10 +163,7 @@ for a regular print file.
The user executing the filter, typically "lp" or "root"; consult the cups-files.conf file for the current setting.

Conforming To

-While the filter interface is compatible with System V interface -scripts, it will only work with the System V interface script as the -only filter. Typically the interface script will be provided via the -lpadmin(8) command using the -i option. +While the filter interface is compatible with System V interface scripts, CUPS does not support System V interface scripts.

Notes

CUPS filters are not meant to be run directly by the user. Aside from the legacy System V interface issues (argv[0] is the printer name), CUPS filters also expect specific environment variables and file descriptors, and typically run in a user session that (on OS X) has additional restrictions that affect how it runs. diff --git a/doc/help/man-lpadmin.html b/doc/help/man-lpadmin.html index 2a74cf06c..775e7e9bc 100644 --- a/doc/help/man-lpadmin.html +++ b/doc/help/man-lpadmin.html @@ -71,15 +71,15 @@ The following options are recognized when configuring a printer queue:
-c class
Adds the named printer to class. If class does not exist it is created automatically. -
-i interface -
Sets a System V style interface script for the printer. -This option cannot be specified with the -P option (PPD file) and is intended for providing support for legacy printer drivers. +
-i ppd-file +
-P ppd-file +
Specifies a PostScript Printer Description (PPD) file to use with the printer.
-m model -
Sets a standard System V interface script or PPD file for the printer from the model directory or using one of the driver interfaces. +
Sets a standard PPD file for the printer from the model directory or using one of the driver interfaces. Use the -m option with the lpinfo(8) command to get a list of supported models. -The model "raw" clears any existing interface script or PPD file and the model "everywhere" queries the printer referred to by the specified IPP device-uri. +The model "raw" clears any existing PPD file and the model "everywhere" queries the printer referred to by the specified IPP device-uri.
-o cupsIPPSupplies=true
-o cupsIPPSupplies=false
Specifies whether IPP supply level values should be reported. @@ -151,9 +151,6 @@ and programs on the destination.
-L "location"
Provides a textual location of the destination. -
-P ppd-file -
Specifies a PostScript Printer Description file to use with the printer. -If specified, this option overrides the -i option (interface script).

Conforming To

Unlike the System V printing system, CUPS allows printer names to contain any printable character except SPACE, TAB, "/", or "#". diff --git a/doc/help/man-lpoptions.html b/doc/help/man-lpoptions.html index 2e171296b..0aeed451d 100644 --- a/doc/help/man-lpoptions.html +++ b/doc/help/man-lpoptions.html @@ -119,7 +119,7 @@ The lpoptions command is unique to CUPS. lprm(1), CUPS Online Help (http://localhost:631/help)

Copyright

-Copyright © 2007-2014 by Apple Inc. +Copyright © 2007-2015 by Apple Inc. diff --git a/doc/help/spec-design.html b/doc/help/spec-design.html index 76cbd9cab..73d07b8f4 100644 --- a/doc/help/spec-design.html +++ b/doc/help/spec-design.html @@ -31,7 +31,7 @@ WIDTH="768" HEIGHT="768" ALT="CUPS Block Diagram">

Config Files

-

The scheduler uses several configuration files to store the server settings (cupsd.conf), available classes (classes.conf), available printers (printers.conf), current notification subscriptions (subscriptions.conf), and supported file types and filters (mime.types, mime.convs). In addition, PostScript Printer Description ("PPD") files or interface scripts are associated with each printer, and the scheduler has cache files for remote printers, PPD files, and current jobs to optimize the scheduler's startup speed and availability.

+

The scheduler uses several configuration files to store the server settings (cupsd.conf), available classes (classes.conf), available printers (printers.conf), current notification subscriptions (subscriptions.conf), and supported file types and filters (mime.types, mime.convs). In addition, PostScript Printer Description ("PPD") files are associated with each printer, and the scheduler has cache files for remote printers, PPD files, and current jobs to optimize the scheduler's startup speed and availability.

Job Files

diff --git a/doc/help/spec-ipp.html b/doc/help/spec-ipp.html index 3a9fd6cfa..4766002f0 100644 --- a/doc/help/spec-ipp.html +++ b/doc/help/spec-ipp.html @@ -1098,10 +1098,7 @@ CUPS-Add-Modify-Printer request: -

The CUPS-Add-Modify-Printer request can optionally be followed by a PPD -file or System V interface script to be used for the printer. The -"ppd-name" attribute overrides any file that is attached to the end of -the request with a local CUPS PPD file. +

The CUPS-Add-Modify-Printer request can optionally be followed by a PPD file to be used for the printer. The "ppd-name" attribute overrides any file that is attached to the end of the request with a local CUPS PPD file.

CUPS-Add-Modify-Printer Response

diff --git a/man/filter.man b/man/filter.man index 356b3537d..a12058526 100644 --- a/man/filter.man +++ b/man/filter.man @@ -12,7 +12,7 @@ .\" which should have been included with this file. If this file is .\" file is missing or damaged, see the license at "http://www.cups.org/". .\" -.TH filter 7 "CUPS" "26 August 2015" "Apple Inc." +.TH filter 7 "CUPS" "19 October 2015" "Apple Inc." .SH NAME filter \- cups file conversion filter interface .SH SYNOPSIS @@ -202,10 +202,7 @@ The timezone of the server. .B USER The user executing the filter, typically "lp" or "root"; consult the \fIcups-files.conf\fR file for the current setting. .SH CONFORMING TO -While the filter interface is compatible with System V interface -scripts, it will only work with the System V interface script as the -only filter. Typically the interface script will be provided via the -\fIlpadmin(8)\fR command using the \fI-i\fR option. +While the filter interface is compatible with System V interface scripts, CUPS does not support System V interface scripts. .SH NOTES CUPS filters are not meant to be run directly by the user. Aside from the legacy System V interface issues (\fIargv[0]\fR is the printer name), CUPS filters also expect specific environment variables and file descriptors, and typically run in a user session that (on OS X) has additional restrictions that affect how it runs. diff --git a/man/lpadmin.man b/man/lpadmin.man index f242b8970..c0283f2da 100644 --- a/man/lpadmin.man +++ b/man/lpadmin.man @@ -12,7 +12,7 @@ .\" which should have been included with this file. If this file is .\" file is missing or damaged, see the license at "http://www.cups.org/". .\" -.TH lpadmin 8 "CUPS" "11 February 2015" "Apple Inc." +.TH lpadmin 8 "CUPS" "19 October 2015" "Apple Inc." .SH NAME lpadmin \- configure cups printers and classes .SH SYNOPSIS @@ -82,16 +82,17 @@ The following options are recognized when configuring a printer queue: Adds the named \fIprinter\fR to \fIclass\fR. If \fIclass\fR does not exist it is created automatically. .TP 5 -\fB\-i \fIinterface\fR -Sets a System V style interface script for the printer. -This option cannot be specified with the \fI-P\fR option (PPD file) and is intended for providing support for legacy printer drivers. +\fB\-i \fIppd-file\fR +.TP 5 +\fB\-P \fIppd-file\fR +Specifies a PostScript Printer Description (PPD) file to use with the printer. .TP 5 \fB\-m \fImodel\fR -Sets a standard System V interface script or PPD file for the printer from the \fImodel\fR directory or using one of the driver interfaces. +Sets a standard PPD file for the printer from the \fImodel\fR directory or using one of the driver interfaces. Use the \fI-m\fR option with the .BR lpinfo (8) command to get a list of supported models. -The model "raw" clears any existing interface script or PPD file and the model "everywhere" queries the printer referred to by the specified IPP \fIdevice-uri\fR. +The model "raw" clears any existing PPD file and the model "everywhere" queries the printer referred to by the specified IPP \fIdevice-uri\fR. .TP 5 \fB\-o cupsIPPSupplies=true\fR .TP 5 @@ -189,10 +190,6 @@ programs on the destination. .TP 5 \fB\-L "\fIlocation\fB"\fR Provides a textual location of the destination. -.TP 5 -\fB\-P \fIppd-file\fR -Specifies a PostScript Printer Description file to use with the printer. -If specified, this option overrides the \fI-i\fR option (interface script). .SH CONFORMING TO Unlike the System V printing system, CUPS allows printer names to contain any printable character except SPACE, TAB, "/", or "#". Also, printer and class names are \fInot\fR case-sensitive. diff --git a/packaging/cups.list.in b/packaging/cups.list.in index efc4abc0e..b1172230c 100644 --- a/packaging/cups.list.in +++ b/packaging/cups.list.in @@ -3,7 +3,7 @@ # # ESP Package Manager (EPM) file list for CUPS. # -# Copyright 2007-2014 by Apple Inc. +# Copyright 2007-2015 by Apple Inc. # Copyright 1997-2007 by Easy Software Products, all rights reserved. # # These coded instructions, statements, and computer programs are the @@ -524,7 +524,6 @@ f 0444 root sys $DATADIR/templates templates/*.tmpl # Config files d 0755 root $CUPS_GROUP $SERVERROOT - -d 0755 root $CUPS_GROUP $SERVERROOT/interfaces - d 0755 root $CUPS_GROUP $SERVERROOT/ppd - d 0700 root $CUPS_GROUP $SERVERROOT/ssl - c $CUPS_PERM root $CUPS_GROUP $SERVERROOT/cups-files.conf conf/cups-files.conf diff --git a/packaging/cups.spec.in b/packaging/cups.spec.in index 481e20cfc..46faef2cc 100644 --- a/packaging/cups.spec.in +++ b/packaging/cups.spec.in @@ -168,7 +168,6 @@ rm -rf $RPM_BUILD_ROOT /etc/cups/cups-files.conf.default /etc/cups/cupsd.conf.default /etc/cups/snmp.conf.default -%dir /etc/cups/interfaces %dir /etc/cups/ppd %attr(0700,root,root) %dir /etc/cups/ssl diff --git a/scheduler/Makefile b/scheduler/Makefile index d6e9dc218..14c8f1ab9 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -149,8 +149,6 @@ install-data: $(INSTALL_DIR) -m 755 $(SERVERBIN)/driver echo Creating $(SERVERROOT)... $(INSTALL_DIR) -m 755 -g $(CUPS_GROUP) $(SERVERROOT) - echo Creating $(SERVERROOT)/interfaces... - $(INSTALL_DIR) -m 755 -g $(CUPS_GROUP) $(SERVERROOT)/interfaces echo Creating $(SERVERROOT)/ppd... $(INSTALL_DIR) -m 755 -g $(CUPS_GROUP) $(SERVERROOT)/ppd if test "x`uname`" != xDarwin; then \ diff --git a/scheduler/cups-driverd.cxx b/scheduler/cups-driverd.cxx index 73f3228d5..46ed9cffd 100644 --- a/scheduler/cups-driverd.cxx +++ b/scheduler/cups-driverd.cxx @@ -448,6 +448,12 @@ cat_ppd(const char *name, /* I - PPD name */ * Figure out if this is a static or dynamic PPD file... */ + if (strstr(name, "../")) + { + fputs("ERROR: Invalid PPD name.\n", stderr); + return (1); + } + strlcpy(scheme, name, sizeof(scheme)); if ((sptr = strchr(scheme, ':')) != NULL) { diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 624f219ad..c0834c0a2 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -2187,7 +2187,7 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ char srcfile[1024], /* Source Script/PPD file */ dstfile[1024]; /* Destination Script/PPD file */ int modify; /* Non-zero if we are modifying */ - int changed_driver, /* Changed the PPD/interface script? */ + int changed_driver, /* Changed the PPD? */ need_restart_job, /* Need to restart job? */ set_device_uri, /* Did we set the device URI? */ set_port_monitor; /* Did we set the port monitor? */ @@ -2572,7 +2572,7 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ cupsdSetString(&printer->device_uri, "file:///dev/null"); /* - * See if we have an interface script or PPD file attached to the request... + * See if we have a PPD file attached to the request... */ if (con->filename) @@ -2596,118 +2596,74 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ * Then see what kind of file it is... */ - snprintf(dstfile, sizeof(dstfile), "%s/interfaces/%s", ServerRoot, - printer->name); - - if (!strncmp(line, "*PPD-Adobe", 10)) + if (strncmp(line, "*PPD-Adobe", 10)) { - /* - * The new file is a PPD file, so remove any old interface script - * that might be lying around... - */ - - unlink(dstfile); - } - else - { - /* - * This must be an interface script, so move the file over to the - * interfaces directory and make it executable... - */ - - if (copy_file(srcfile, dstfile, ConfigFilePerm | 0110)) - { - send_ipp_status(con, IPP_INTERNAL_ERROR, - _("Unable to copy interface script - %s"), - strerror(errno)); - return; - } - - cupsdLogMessage(CUPSD_LOG_DEBUG, - "Copied interface script successfully"); + send_ipp_status(con, IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED, _("Bad PPD file.")); + return; } snprintf(dstfile, sizeof(dstfile), "%s/ppd/%s.ppd", ServerRoot, printer->name); - if (!strncmp(line, "*PPD-Adobe", 10)) - { - /* - * The new file is a PPD file, so move the file over to the - * ppd directory and make it readable by all... - */ - - if (copy_file(srcfile, dstfile, ConfigFilePerm)) - { - send_ipp_status(con, IPP_INTERNAL_ERROR, - _("Unable to copy PPD file - %s"), - strerror(errno)); - return; - } + /* + * The new file is a PPD file, so move the file over to the ppd + * directory... + */ - cupsdLogMessage(CUPSD_LOG_DEBUG, - "Copied PPD file successfully"); - } - else + if (copy_file(srcfile, dstfile, ConfigFilePerm)) { - /* - * This must be an interface script, so remove any old PPD file that - * may be lying around... - */ - - unlink(dstfile); + send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to copy PPD file - %s"), strerror(errno)); + return; } + + cupsdLogMessage(CUPSD_LOG_DEBUG, "Copied PPD file successfully"); } } - else if ((attr = ippFindAttribute(con->request, "ppd-name", - IPP_TAG_NAME)) != NULL) + else if ((attr = ippFindAttribute(con->request, "ppd-name", IPP_TAG_NAME)) != NULL) { + const char *ppd_name = ippGetString(attr, 0, NULL); + /* ppd-name value */ + need_restart_job = 1; changed_driver = 1; - if (!strcmp(attr->values[0].string.text, "raw")) + if (!strcmp(ppd_name, "raw")) { /* - * Raw driver, remove any existing PPD or interface script files. + * Raw driver, remove any existing PPD file. */ - snprintf(dstfile, sizeof(dstfile), "%s/interfaces/%s", ServerRoot, - printer->name); - unlink(dstfile); - - snprintf(dstfile, sizeof(dstfile), "%s/ppd/%s.ppd", ServerRoot, - printer->name); + snprintf(dstfile, sizeof(dstfile), "%s/ppd/%s.ppd", ServerRoot, printer->name); unlink(dstfile); } + else if (strstr(ppd_name, "../")) + { + send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Invalid ppd-name value.")); + return; + } else { /* * PPD model file... */ - snprintf(dstfile, sizeof(dstfile), "%s/interfaces/%s", ServerRoot, - printer->name); - unlink(dstfile); - - snprintf(dstfile, sizeof(dstfile), "%s/ppd/%s.ppd", ServerRoot, - printer->name); + snprintf(dstfile, sizeof(dstfile), "%s/ppd/%s.ppd", ServerRoot, printer->name); - if (copy_model(con, attr->values[0].string.text, dstfile)) + if (copy_model(con, ppd_name, dstfile)) { send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to copy PPD file.")); return; } - cupsdLogMessage(CUPSD_LOG_DEBUG, - "Copied PPD file successfully"); + cupsdLogMessage(CUPSD_LOG_DEBUG, "Copied PPD file successfully"); } } if (changed_driver) { /* - * If we changed the PPD/interface script, then remove the printer's cache - * file and clear the printer-state-reasons... + * If we changed the PPD, then remove the printer's cache file and clear the + * printer-state-reasons... */ char cache_name[1024]; /* Cache filename for printer attrs */ @@ -4329,7 +4285,7 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */ /* - * 'copy_file()' - Copy a PPD file or interface script... + * 'copy_file()' - Copy a PPD file... */ static int /* O - 0 = success, -1 = error */ @@ -4415,9 +4371,7 @@ copy_model(cupsd_client_t *con, /* I - Client connection */ /* cupsProtocol attribute */ - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "copy_model(con=%p, from=\"%s\", to=\"%s\")", - con, from, to); + cupsdLogMessage(CUPSD_LOG_DEBUG2, "copy_model(con=%p, from=\"%s\", to=\"%s\")", con, from, to); /* * Run cups-driverd to get the PPD file... @@ -5685,13 +5639,6 @@ delete_printer(cupsd_client_t *con, /* I - Client connection */ * Remove any old PPD or script files... */ - snprintf(filename, sizeof(filename), "%s/interfaces/%s", ServerRoot, - printer->name); - unlink(filename); - snprintf(filename, sizeof(filename), "%s/interfaces/%s.O", ServerRoot, - printer->name); - unlink(filename); - snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, printer->name); unlink(filename); @@ -6699,16 +6646,17 @@ get_ppd(cupsd_client_t *con, /* I - Client connection */ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppd(%p[%d], %p[%s=%s])", con, con->number, uri, uri->name, uri->values[0].string.text); - if (!strcmp(uri->name, "ppd-name")) + if (!strcmp(ippGetName(uri), "ppd-name")) { /* * Return a PPD file from cups-driverd... */ - char command[1024], /* cups-driverd command */ - options[1024], /* Options to pass to command */ - ppd_name[1024]; /* ppd-name */ - + const char *ppd_name = ippGetString(uri, 0, NULL); + /* ppd-name value */ + char command[1024], /* cups-driverd command */ + options[1024], /* Options to pass to command */ + oppd_name[1024]; /* Escaped ppd-name */ /* * Check policy... @@ -6720,14 +6668,23 @@ get_ppd(cupsd_client_t *con, /* I - Client connection */ return; } + /* + * Check ppd-name value... + */ + + if (strstr(ppd_name, "../")) + { + send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Invalid ppd-name value.")); + return; + } + /* * Run cups-driverd command with the given options... */ snprintf(command, sizeof(command), "%s/daemon/cups-driverd", ServerBin); - url_encode_string(uri->values[0].string.text, ppd_name, sizeof(ppd_name)); - snprintf(options, sizeof(options), "get+%d+%s", - con->request->request.op.request_id, ppd_name); + url_encode_string(ppd_name, oppd_name, sizeof(oppd_name)); + snprintf(options, sizeof(options), "get+%d+%s", ippGetRequestId(con->request), oppd_name); if (cupsdSendCommand(con, command, options, 0)) { @@ -6745,17 +6702,14 @@ get_ppd(cupsd_client_t *con, /* I - Client connection */ * went wrong... */ - send_ipp_status(con, IPP_INTERNAL_ERROR, - _("cups-driverd failed to execute.")); + send_ipp_status(con, IPP_INTERNAL_ERROR, _("cups-driverd failed to execute.")); } } - else if (!strcmp(uri->name, "printer-uri") && - cupsdValidateDest(uri->values[0].string.text, &dtype, &dest)) + else if (!strcmp(ippGetName(uri), "printer-uri") && cupsdValidateDest(ippGetString(uri, 0, NULL), &dtype, &dest)) { int i; /* Looping var */ char filename[1024]; /* PPD filename */ - /* * Check policy... */ @@ -6770,14 +6724,12 @@ get_ppd(cupsd_client_t *con, /* I - Client connection */ * See if we need the PPD for a class or remote printer... */ - snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, - dest->name); + snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, dest->name); if ((dtype & CUPS_PRINTER_REMOTE) && access(filename, 0)) { - con->response->request.status.status_code = CUPS_SEE_OTHER; - ippAddString(con->response, IPP_TAG_OPERATION, IPP_TAG_URI, - "printer-uri", NULL, dest->uri); + send_ipp_status(con, IPP_STATUS_CUPS_SEE_OTHER, _("See remote printer.")); + ippAddString(con->response, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, dest->uri); return; } else if (dtype & CUPS_PRINTER_CLASS) @@ -6785,8 +6737,7 @@ get_ppd(cupsd_client_t *con, /* I - Client connection */ for (i = 0; i < dest->num_printers; i ++) if (!(dest->printers[i]->type & CUPS_PRINTER_CLASS)) { - snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, - dest->printers[i]->name); + snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, dest->printers[i]->name); if (!access(filename, 0)) break; @@ -6796,9 +6747,8 @@ get_ppd(cupsd_client_t *con, /* I - Client connection */ dest = dest->printers[i]; else { - con->response->request.status.status_code = CUPS_SEE_OTHER; - ippAddString(con->response, IPP_TAG_OPERATION, IPP_TAG_URI, - "printer-uri", NULL, dest->printers[0]->uri); + send_ipp_status(con, IPP_STATUS_CUPS_SEE_OTHER, _("See remote printer.")); + ippAddString(con->response, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, dest->printers[0]->uri); return; } } @@ -6809,9 +6759,7 @@ get_ppd(cupsd_client_t *con, /* I - Client connection */ if ((con->file = open(filename, O_RDONLY)) < 0) { - send_ipp_status(con, IPP_NOT_FOUND, - _("The PPD file \"%s\" could not be opened: %s"), - uri->values[0].string.text, strerror(errno)); + send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("The PPD file \"%s\" could not be opened: %s"), ippGetString(uri, 0, NULL), strerror(errno)); return; } @@ -6819,12 +6767,10 @@ get_ppd(cupsd_client_t *con, /* I - Client connection */ con->pipe_pid = 0; - con->response->request.status.status_code = IPP_OK; + ippSetStatusCode(con->response, IPP_STATUS_OK); } else - send_ipp_status(con, IPP_NOT_FOUND, - _("The PPD file \"%s\" could not be found."), - uri->values[0].string.text); + send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("The PPD file \"%s\" could not be found."), ippGetString(uri, 0, NULL)); } diff --git a/scheduler/printers.c b/scheduler/printers.c index c80a0c6c1..ed733bc4d 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -2344,37 +2344,19 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ } else if (!(p->type & CUPS_PRINTER_REMOTE)) { - char interface[1024]; /* Interface script */ - - - snprintf(interface, sizeof(interface), "%s/interfaces/%s", ServerRoot, - p->name); - if (!access(interface, X_OK)) - { - /* - * Yes, we have a System V style interface script; use it! - */ - - snprintf(interface, sizeof(interface), "*/* 0 %s/interfaces/%s", - ServerRoot, p->name); - add_printer_filter(p, p->filetype, interface); - } - else - { - /* - * Add a filter from application/vnd.cups-raw to printer/name to - * handle "raw" printing by users. - */ + /* + * Add a filter from application/vnd.cups-raw to printer/name to + * handle "raw" printing by users. + */ - add_printer_filter(p, p->filetype, "application/vnd.cups-raw 0 -"); + add_printer_filter(p, p->filetype, "application/vnd.cups-raw 0 -"); - /* - * Add a PostScript filter, since this is still possibly PS printer. - */ + /* + * Add a PostScript filter, since this is still possibly PS printer. + */ - add_printer_filter(p, p->filetype, - "application/vnd.cups-postscript 0 -"); - } + add_printer_filter(p, p->filetype, + "application/vnd.cups-postscript 0 -"); } if (p->pc && p->pc->prefilters) @@ -4881,32 +4863,13 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ } else { - /* - * If we have an interface script, add a filter entry for it... - */ - - char interface[1024]; /* Interface script */ - - - snprintf(interface, sizeof(interface), "%s/interfaces/%s", ServerRoot, - p->name); - if (!access(interface, X_OK)) - { - /* - * Yes, we have a System V style interface script; use it! - */ - - ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, - "printer-make-and-model", NULL, - "Local System V Printer"); - } - else if (((!strncmp(p->device_uri, "ipp://", 6) || - !strncmp(p->device_uri, "ipps://", 7)) && - (strstr(p->device_uri, "/printers/") != NULL || - strstr(p->device_uri, "/classes/") != NULL)) || - ((strstr(p->device_uri, "._ipp.") != NULL || - strstr(p->device_uri, "._ipps.") != NULL) && - !strcmp(p->device_uri + strlen(p->device_uri) - 5, "/cups"))) + if (((!strncmp(p->device_uri, "ipp://", 6) || + !strncmp(p->device_uri, "ipps://", 7)) && + (strstr(p->device_uri, "/printers/") != NULL || + strstr(p->device_uri, "/classes/") != NULL)) || + ((strstr(p->device_uri, "._ipp.") != NULL || + strstr(p->device_uri, "._ipps.") != NULL) && + !strcmp(p->device_uri + strlen(p->device_uri) - 5, "/cups"))) { /* * Tell the client this is really a hard-wired remote printer. diff --git a/systemv/lpadmin.c b/systemv/lpadmin.c index fa077b2b9..eb7ce0fb2 100644 --- a/systemv/lpadmin.c +++ b/systemv/lpadmin.c @@ -58,7 +58,7 @@ main(int argc, /* I - Number of command-line arguments */ *val; /* Pointer to allow/deny value */ int num_options; /* Number of options */ cups_option_t *options; /* Options */ - char *file, /* New PPD file/interface script */ + char *file, /* New PPD file */ evefile[1024] = ""; /* IPP Everywhere PPD */ const char *ppd_name, /* ppd-name value */ @@ -199,7 +199,8 @@ main(int argc, /* I - Number of command-line arguments */ } break; - case 'i' : /* Use the specified interface script */ + case 'P' : /* Use the specified PPD file */ + case 'i' : /* Use the specified PPD file */ if (argv[i][2]) file = argv[i] + 2; else @@ -208,9 +209,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { - _cupsLangPuts(stderr, - _("lpadmin: Expected interface after \"-i\" " - "option.")); + _cupsLangPrintf(stderr, _("lpadmin: Expected PPD after \"-%c\" option."), argv[i - 1][1]); return (1); } @@ -588,24 +587,6 @@ main(int argc, /* I - Number of command-line arguments */ } break; - case 'P' : /* Use the specified PPD file */ - if (argv[i][2]) - file = argv[i] + 2; - else - { - i ++; - - if (i >= argc) - { - _cupsLangPuts(stderr, - _("lpadmin: Expected PPD after \"-P\" option.")); - return (1); - } - - file = argv[i]; - } - break; - default : _cupsLangPrintf(stderr, _("lpadmin: Unknown option \"%c\"."), argv[i][1]); diff --git a/systemv/lpstat.c b/systemv/lpstat.c index 43e4c7a33..7bfadeb12 100644 --- a/systemv/lpstat.c +++ b/systemv/lpstat.c @@ -1835,11 +1835,7 @@ show_printers(const char *printers, /* I - Destinations */ { _cupsLangPuts(stdout, _("\tConnection: direct")); - if (make_model && strstr(make_model, "System V Printer")) - _cupsLangPrintf(stdout, - _("\tInterface: %s/interfaces/%s"), - cg->cups_serverroot, printer); - else if (make_model && !strstr(make_model, "Raw Printer")) + if (make_model && !strstr(make_model, "Raw Printer")) _cupsLangPrintf(stdout, _("\tInterface: %s/ppd/%s.ppd"), cg->cups_serverroot, printer); @@ -1958,11 +1954,7 @@ show_printers(const char *printers, /* I - Destinations */ { _cupsLangPuts(stdout, _("\tConnection: direct")); - if (make_model && strstr(make_model, "System V Printer")) - _cupsLangPrintf(stdout, - _("\tInterface: %s/interfaces/%s"), - cg->cups_serverroot, printer); - else if (make_model && !strstr(make_model, "Raw Printer")) + if (make_model && !strstr(make_model, "Raw Printer")) _cupsLangPrintf(stdout, _("\tInterface: %s/ppd/%s.ppd"), cg->cups_serverroot, printer); -- 2.39.2