Since CUPS 2.2 System V interface scripts are no longer supported for security reasons

lpadmin -p weighbridge -E -i…

Login

Blog History

lpadmin -p weighbridge -E -i /home/jamesm/weighbridge -v socket://192.168.0.28:9100

lpadmin: System V interface scripts are no longer supported for security reasons.

So just upgrading a system from Ubuntu 14.04 which uses Cups 1.7.2 to 18.04 which uses Cups 2.2.7.

Previously I used a "System V" style interface script to make some changes to a plain text document printed via using a LPD queue from a Weighbridge. We haven't been able to upgrade the Weighbridge software and it has the old company name and A.C.N (Australian Company Number) so I use a bash script to change these details and to also output several copies of each document.

But while attempting to migrate my /etc/cups/interface scripts across to the new system I got the above error message.

So how to get the same functionality as the interface script with the newer version of Cups?

Apparently you need to convert the interface script to be a filter.

Basically you move the interface script to the filter directory and then create a custom PPD that includes the filter

This is my interface script, which suprisingly needed no modification to become an filter. I copy it to /usr/lib/cups/filter and make sure it has the same permissions and ownership of the other filters

#!/bin/sh
# filename for this script is weighbridge

# Command line arguments
job="$1"
user="$2"
title="$3"
numcopies="$4"
options="$5"
filename="$6"
log=/tmp/cups/weighbridge-interface-output

cat "$filename" > $log
echo "Job $job" >> $log
echo "user $user" >> $log
echo "title $title" >> $log
echo "numcopies $numcopies" >> $log
echo "options $options" >> $log
echo "filename $filename" >> $log

# each cat command fixes a legacy document header with incorrect
# details and creates a slightly different copy
# of a weighbridge docket e.g. Office Copy, Customer Copy, Driver Copy

# Pass through
cat "$filename" | sed -e '4 i \      Office Copy' -e 's+Old Company Name Pty Ltd+                       New Company Pty Ltd+' -e 's/OLD ABN/NEW ABN/'
# this command sends the print file to a perl script which creates a 
# PDF and puts it on a network share
cat "$filename" | sed -e '4 i \      Office Copy' -e 's+Old Company Name Pty Ltd+                       New Company Pty Ltd+' -e 's/OLD ABN/NEW ABN/' | /usr/local/bin/get_fields.pl

# cat "$filename" | sed -e '4 i \      Customer Copy' -e 's+Old Company Name Pty Ltd+                       New Company Pty Ltd+' -e 's/OLD ABN/NEW ABN/'

cat "$filename" | sed -e '4 i \      Driver Copy' -e 's+Old Company Name Pty Ltd+                       New Company Pty Ltd+' -e 's/OLD ABN/NEW ABN/'


In order to move the interface script to become a filter I need several pieces of information.

  1. An example copy of the print job for testing
  2. The mime-type of the print job

To get a copy of the print job I went into /var/spool/cups and find an archived copy of a print data file sent to the printer on the old system. To locate the correct file I grepped to find a data file with the correct text in it.

Once the data file is found I copy it to home so I can use it as test print job.

The print data file is being sent from a Windows system via a queue pointing towards the Ubuntu system via LPD (with cups you also need to add cups-lpd functionality too via installing xinetd. see below)

# on old server. Note: you need to have cups set "Preserve job history"
cd /var/spool/cups
grep "Old Company" *
# one of the files from the output of above
cp d155131-001 /home/james/
cd /home/jamesm
# test the mime-type of the file
file --mime-type d155131-001
d155131-001: text/plain

So we now have a sample print job and using file --mime-type <filename> we know the mime-type (text/plain) that Cups will see when the job is sent to the printer. In order for the filter to be triggered Cups has to see the correct mime-type for the incoming print file

Because the original printer using the interface script was a raw queue it didn't have a specific PPD file so next I had to create a PPD for the printer. This is so I can then edit the PPD to add the interface script as a filter and then load the custom PPD for that printer

driverless ipp://localhost/printers/weighbridge > weighbridge.ppd

This is an example of the output from driverless. The only modification it contains is the addition of the cupsFilter2: "text/plain text/plain 10 weighbridge" line

*PPD-Adobe: "4.3"
*FormatVersion: "4.3"
*FileVersion: "1.20.2"
*LanguageVersion: English
*LanguageEncoding: ISOLatin1
*PSVersion: "(3010.000) 0"
*LanguageLevel: "3"
*FileSystem: False
*PCFileName: "drvless.ppd"
*Manufacturer: "Local"
*ModelName: "Local Raw Printer"
*Product: "(Local Raw Printer)"
*NickName: "Local Raw Printer, driverless, cups-filters 1.20.2"
*ShortNickName: "Local Raw Printer"
*ColorDevice: False
*cupsVersion: 2.2
*cupsSNMPSupplies: False
*cupsLanguages: "en"
*APSupplies: "http://localhost:631/printers/weighbridge"
*cupsFilter2: "text/plain text/plain 10 weighbridge"
*cupsFilter2: "application/vnd.cups-pdf application/pdf 0 -"
*cupsFilter2: "application/vnd.cups-postscript application/postscript 500 -"
*cupsFilter2: "image/jpeg image/jpeg 0 -"
*cupsFilter2: "image/png image/png 0 -"
*% Printer did not supply page size info via IPP, using defaults
*OpenUI *PageSize/Media Size: PickOne
*OrderDependency: 10 AnySetup *PageSize
*DefaultPageSize: Letter
*PageSize Letter/US Letter: "<</PageSize[612 792]>>setpagedevice"
*PageSize Legal/US Legal: "<</PageSize[612 1008]>>setpagedevice"
*PageSize Executive/Executive: "<</PageSize[522 756]>>setpagedevice"
*PageSize Tabloid/Tabloid: "<</PageSize[792 1224]>>setpagedevice"
*PageSize A3/A3: "<</PageSize[842 1191]>>setpagedevice"
*PageSize A4/A4: "<</PageSize[595 842]>>setpagedevice"
*PageSize A5/A5: "<</PageSize[420 595]>>setpagedevice"
*PageSize B5/JIS B5: "<</PageSize[516 729]>>setpagedevice"
*PageSize EnvISOB5/Envelope B5: "<</PageSize[499 709]>>setpagedevice"
*PageSize Env10/Envelope #10 : "<</PageSize[297 684]>>setpagedevice"
*PageSize EnvC5/Envelope C5: "<</PageSize[459 649]>>setpagedevice"
*PageSize EnvDL/Envelope DL: "<</PageSize[312 624]>>setpagedevice"
*PageSize EnvMonarch/Envelope Monarch: "<</PageSize[279 540]>>setpagedevice"
*CloseUI: *PageSize
*OpenUI *PageRegion/Media Size: PickOne
*OrderDependency: 10 AnySetup *PageRegion
*DefaultPageRegion: Letter
*PageRegion Letter/US Letter: "<</PageSize[612 792]>>setpagedevice"
*PageRegion Legal/US Legal: "<</PageSize[612 1008]>>setpagedevice"
*PageRegion Executive/Executive: "<</PageSize[522 756]>>setpagedevice"
*PageRegion Tabloid/Tabloid: "<</PageSize[792 1224]>>setpagedevice"
*PageRegion A3/A3: "<</PageSize[842 1191]>>setpagedevice"
*PageRegion A4/A4: "<</PageSize[595 842]>>setpagedevice"
*PageRegion A5/A5: "<</PageSize[420 595]>>setpagedevice"
*PageRegion B5/JIS B5: "<</PageSize[516 729]>>setpagedevice"
*PageRegion EnvISOB5/Envelope B5: "<</PageSize[499 709]>>setpagedevice"
*PageRegion Env10/Envelope #10 : "<</PageSize[297 684]>>setpagedevice"
*PageRegion EnvC5/Envelope C5: "<</PageSize[459 649]>>setpagedevice"
*PageRegion EnvDL/Envelope DL: "<</PageSize[312 624]>>setpagedevice"
*PageRegion EnvMonarch/Envelope Monarch: "<</PageSize[279 540]>>setpagedevice"
*CloseUI: *PageSize
*DefaultImageableArea: Letter
*ImageableArea Letter/US Letter: "18 12 594 780"
*ImageableArea Legal/US Legal: "18 12 594 996"
*ImageableArea Executive/Executive: "18 12 504 744"
*ImageableArea Tabloid/Tabloid: "18 12 774 1212"
*ImageableArea A3/A3: "18 12 824 1179"
*ImageableArea A4/A4: "18 12 577 830"
*ImageableArea A5/A5: "18 12 402 583"
*ImageableArea B5/JIS B5: "18 12 498 717"
*ImageableArea EnvISOB5/Envelope B5: "18 12 481 697"
*ImageableArea Env10/Envelope #10 : "18 12 279 672"
*ImageableArea EnvC5/Envelope C5: "18 12 441 637"
*ImageableArea EnvDL/Envelope DL: "18 12 294 612"
*ImageableArea EnvMonarch/Envelope Monarch: "18 12 261 528"
*DefaultPaperDimension: Letter
*PaperDimension Letter/US Letter: "612 792"
*PaperDimension Legal/US Legal: "612 1008"
*PaperDimension Executive/Executive: "522 756"
*PaperDimension Tabloid/Tabloid: "792 1224"
*PaperDimension A3/A3: "842 1191"
*PaperDimension A4/A4: "595 842"
*PaperDimension A5/A5: "420 595"
*PaperDimension B5/JIS B5: "516 729"
*PaperDimension EnvISOB5/Envelope B5: "499 709"
*PaperDimension Env10/Envelope #10 : "297 684"
*PaperDimension EnvC5/Envelope C5: "459 649"
*PaperDimension EnvDL/Envelope DL: "312 624"
*PaperDimension EnvMonarch/Envelope Monarch: "279 540"
*OpenUI *ColorModel/Print Color Mode: PickOne
*OrderDependency: 10 AnySetup *ColorModel
*DefaultColorModel: Gray
*ColorModel FastGray/Fast Grayscale: "<</cupsColorSpace 3/cupsBitsPerColor 1/cupsColorOrder 0/cupsCompression 0/ProcessColorModel /DeviceGray>>setpagedevice"
*ColorModel Gray/Grayscale: "<</cupsColorSpace 18/cupsBitsPerColor 8/cupsColorOrder 0/cupsCompression 0/ProcessColorModel /DeviceGray>>setpagedevice"
*CloseUI: *ColorModel
*DefaultResolution: 300dpi

I used the Cups web interface to upload and add the customized PPD to the "weighbridge" print queue

Once the PPD is loaded then the filter will be triggered when the print job of type text/plain arrives

Enabling LPD on Ubuntu 18.04

Note: I didn't enable this on Ubuntu 22.04

On a Windows XP computer I just added a new computer with the url http://192.168.55.19:631/printers/admin making it an IPP printer not LPD

Install xinetd and then create a file named /etc/xinet.d/cups-lpd with the following contents and reload xinetd to get Cups listening on 515

service printer
           {
               socket_type = stream
               protocol = tcp
               wait = no
               user = lp
               group = sys
               passenv =
               server = /usr/lib/cups/daemon/cups-lpd
               server_args = -o document-format=application/octet-stream
           }

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.