cups-filters icon indicating copy to clipboard operation
cups-filters copied to clipboard

pdf-to-ps step fails with /bin/sh: 1: cannot create setpagedevice: Permission denied

Open xavigutierrez opened this issue 2 years ago • 4 comments

Hi! I am trying to make my HP DeskJet D1600 work with CUPS on a Raspberry Pi, so it can serve the printer (only USB capable) in the local network. Whenever I try to print anything from any client (including the server itself) I get an error that says that filters failed. So, I cranked up the logging level to debug and tried printing a one line text file from command line and found this in /var/log/cups/error_log:

D [18/Apr/2022:01:23:13 +0200] [Job 124] New page: %%Page: 1 1
D [18/Apr/2022:01:23:13 +0200] [Job 124] \"Setup\" section is missing, inserting it.
D [18/Apr/2022:01:23:13 +0200] [Job 124] Inserting option code into \"Setup\" section.
D [18/Apr/2022:01:23:13 +0200] [Job 124] Found: %%BeginPageSetup
D [18/Apr/2022:01:23:13 +0200] [Job 124] Inserting option code into \"PageSetup\" section.
D [18/Apr/2022:01:23:13 +0200] [Job 124] PID 1983 (gs) exited with no errors.
D [18/Apr/2022:01:23:13 +0200] [Job 124] Flushing FIFO.
D [18/Apr/2022:01:23:14 +0200] [Job 124] Starting renderer with command: \"gs -sstdout=%stderr  -dBATCH -dPARANOIDSAFER -dQUIET -dNOPAUSE -dNOINTERPOLATE -sDEVICE=ijs -sIjsServer=hpijs<</Duplex false/Tumble false>>setpagedevice -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -sDeviceManufacturer=\"HEWLETT-PACKARD\" -sDeviceModel=\"deskjet 5600\" -r300 -sIjsParams=Quality:Quality=0,Quality:ColorMode=2,Quality:MediaType=0,Quality:PenSet=2,PS:MediaPosition=7 -dIjsUseOutputFD -sOutputFile=%stdout -_\"
D [18/Apr/2022:01:23:14 +0200] [Job 124] Starting process \"kid3\" (generation 1)
D [18/Apr/2022:01:23:14 +0200] [Job 124] Starting process \"kid4\" (generation 2)
D [18/Apr/2022:01:23:14 +0200] [Job 124] Starting process \"renderer\" (generation 2)
D [18/Apr/2022:01:23:14 +0200] [Job 124] JCL: \033%-12345X@PJL
D [18/Apr/2022:01:23:14 +0200] [Job 124] <job data> 
D [18/Apr/2022:01:23:14 +0200] [Job 124] /bin/sh: 1: cannot create setpagedevice: Permission denied
D [18/Apr/2022:01:23:14 +0200] [Job 124] renderer exited with status 2
D [18/Apr/2022:01:23:14 +0200] [Job 124] Process is dying with \"Encountered error Broken pipe during fwrite\", exit stat 1
D [18/Apr/2022:01:23:14 +0200] [Job 124] Cleaning up...
D [18/Apr/2022:01:23:14 +0200] [Job 124] Killing pdf-to-ps
D [18/Apr/2022:01:23:22 +0200] [Job 124] Killing kid3
D [18/Apr/2022:01:23:30 +0200] [Job 124] prnt/backend/hp.c 913: ERROR: null print job total=0
D [18/Apr/2022:01:23:30 +0200] [Job 124] PID 1977 (/usr/lib/cups/filter/foomatic-rip) stopped with status 1.
D [18/Apr/2022:01:23:30 +0200] [Job 124] PID 1978 (/usr/lib/cups/backend/hp) exited with no errors.

I can see the following at first sight:

  • In the generated command line for ghostscript, the option -sDeviceModel points to the wrong printer model (-sDeviceModel="deskjet 5600"). I think it should be deskjet d1600 or something like that.
  • The main error before exiting is: /bin/sh: 1: cannot create setpagedevice: Permission denied
  • So, apparently, the command (gs?) cannot write to somewhere. However, I could not find where that is by browsing through the code.

Am I doing something wrong? Did I miss any step? Or is this a bug? Please, let me know if you need additional information. Thanks in advance! Xavier.

xavigutierrez avatar Apr 17 '22 23:04 xavigutierrez

Seeing the same issue. Seriously, do I really have to dig deep into how every package works, just to print a JPEG?

The printer was added to my Ubuntu with:

lpadmin -p HP_InkAdv_2515 -E -v 'ipp://192.168.111.6/ipp/print' -m 'drv:///hpijs.drv/hp-deskjet_2510_series-hpijs.ppd'

The issue is causes by gs command having inserted a XML tag into it, <</MediaPosition 7>>:

D [04/Sep/2022:18:28:58 +0200] [Job 2] Starting renderer with command: \"gs -sstdout=%stderr  -dBATCH -dPARANOIDSAFER -dQUIET -dNOPAUSE -dNOINTERPOLATE -sDEVICE=ijs -sIjsServer=hpijs -dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842 -sDeviceManufacturer=\"HEWLETT-PACKARD\" -sDeviceModel=\"deskjet 5600\" -r300 -sIjsParams=Quality:Quality=0,Quality:ColorMode=2,Quality:MediaType=0,Quality:PenSet=2<</MediaPosition 7>>setpagedevice -dIjsUseOutputFD -sOutputFile=%stdout -_\"

This causes the command to get input from a file, and send output to another file.

Shouldn't the variables to be used in command line be filtered, ie. for security reasons? Why we can make CUPS create files within filesystem by giving it parameters in unexpected format?

mefistotelis avatar Sep 04 '22 17:09 mefistotelis

Found a workaround.

He HP drivers are leaking between each other. Maybe the format is wrong, maybe the parser is bad - either way, CUPS parsers should be able to tell when such things happen.

The workaround is to just cut the specific driver you need. In my case, that is platform codename 'PyramidPlus'.

So I cut it to a separate file (first line - header, 2nd line - the part for specific printer):

grep -B9999 '^Filter ' /usr/share/cups/drv/hpijs.drv | sudo tee /usr/share/cups/drv/hpijs-pyramidplus.drv
grep -A9999 '^\/\/\/.* PyramidPlus' /usr/share/cups/drv/hpijs.drv | grep -B9999 '[}].* PyramidPlus' | sudo tee -a /usr/share/cups/drv/hpijs-pyramidplus.drv

And then I removed my printer and re-added it using the cutout driver:

lpadmin -x HP_InkAdv_2515
lpadmin -p HP_InkAdv_2515 -E -v 'ipp://192.168.111.6/ipp/print' -m 'drv:///hpijs-pyramidplus.drv/hp-deskjet_2510_series-hpijs.ppd'

That solved this issue, because MediaPosition in that driver is defined properly - the issue was that MediaPosition from a different driver was used instead, as the various file sections are leaking into each other.

mefistotelis avatar Sep 04 '22 20:09 mefistotelis

Could you remove your printer and re-add it with

lpadmin -p HP_InkAdv_2515 -E -v 'ipp://192.168.111.6/ipp/print' -m 'drv:///hpcups.drv/hp-deskjet_2510_series.ppd'

Does this work?

tillkamppeter avatar Dec 17 '22 19:12 tillkamppeter

The "hpijs" driver of HPLIP is deprecated, you should use "hpcups" instead.

tillkamppeter avatar Dec 17 '22 19:12 tillkamppeter