`gs [options] -- <input_file>` fails with "permission denied"

Bug #1913656 reported by Dirk F
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ghostscript (Ubuntu)
Fix Released
Medium
Unassigned
Focal
Fix Released
Medium
William Wilson

Bug Description

[Impact]
 * The command line syntax `gs [options] -- <input_file>` fails
   to load in the input file with a "permission denied" error.
 * Per the ghostscript documentation, the `--` syntax is used as follows:
      "-- filename arg1 ...
       Takes the next argument as a file name as usual,
       but takes all remaining arguments (even if they
       have the syntactic form of switches) and defines
       the name ARGUMENTS in userdict (not systemdict)
       as an array of those strings, before running the
       file. When Ghostscript finishes executing the file,
       it exits back to the shell."

[Test Plan]
---------- to be performed in a desktop environment ----------
 * Obtain a valid input file for ghostscript. The Source package
   contains an `examples/` directory with plenty to choose from.
 * `gs -- <input-file>`
 * Observe that the test failed with a "permission denied" error.
 * Install the version of ghostscript from focal-proposed.
 * `gs -- <input-file>`
 * Observe that the command succeeds and a ghostscript window.
   appears with the output of the `gs` command.

------------------------ Test Plan 2 --------------------------
 * Run ocrfeeder from a terminal
 * Click File -> Import PDF
 * Select a PDF file
 * Note that no pages are displayed, and ocrfeeder throws a
   "Permission denied" error in the terminal from which it
   was launched
 * Install ghostscript from -proposed
 * Run ocrfeeder from a terminal and attempt to import the PDF
   file again
 * Note that the pages of the PDF are displayed in ocrfeeder
   and no error is reported in the terminal

------------------------- Test Plan 3 ---------------------------
 * Using the version of ghostscript in -proposed, run a variety
   of different commands to ensure there has been no regression.
      * gs <input file>
      * gs -r300x300 -sPAPERSIZE=letter \
           -sOUTPUTFILE=waterfal.jpg \
           -dNOPAUSE -dBATCH <input file>
      * gs -r300x300 -sPAPERSIZE=letter \
           -sOUTPUTFILE=waterfal.jpg \
           -dNOPAUSE -dBATCH -- <input file>

[Regression Potential]
 * Since this patch affects command line processing, it is possible
   that other arguments or command line syntaxes could be affected.

[Original Description]
Ghostscript 9.50 exhibits https://bugs.ghostscript.com/show_bug.cgi?id=701894 (fix the '--' and co options) which causes (eg) ocrfeeder to fail to load PDF files: an input file specified using the "... -- filename ..." command line syntax has no read permission in the GS interpreter.

This commit fixes it:

http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=24ec06a27df63297796a379c95ee5d4b39040410

GS 9.52 includes the commit.

Either apply the fix from the linked commit in the Focal-Updates version, or upgrade it to 9.52.

tags: added: focal
Revision history for this message
Sebastien Bacher (seb128) wrote :

20.10 has 9.52 so that's fixed in the current serie and a request for SRU to focal

Could you perhaps provide an user facing example of steps to trigger the issue which could be used to justify and test the stable update? (you mentioned ocrfeeder)

Revision history for this message
Dirk F (fieldhouse) wrote :

Example.

Start with GS 9.26 installed.

1 Install package ocrfeeder from the Graphics (universe) category (if not already installed).

2 Run ocrfeeder (desktop menu item OCRFeeder).

3 Select a PDF file to use with File>Import PDF.

4 A pop-up dialog "Loading" appears; after it closes the images of the pages from the PDF file are shown in the ocrfeeder application window. One can then use the application UI to run OCR on the images or selected areas from them.

Start again with GS 9.50 installed.

Repeat steps 1-3. At step 4, nothing happens.

Repeat but at 2 start ocrfeeder from a terminal window. At step 4 a Ghostscript error exit 1 is reported.

The referenced bug (which owing to a long-standing bug in Launchpad has been automatically linked to Launchpad, but is actually in GS's Bugzilla) means that some ways of passing a filename argument from the GS command line fail to give the said file read permission in the GS interpreter.

ocrfeeder sensibly calls GS using "gs ... -- <filename>", which protects against incorrect command-line parsing for a file called (eg) "--startswithhyphens.pdf", but is also one of the bugged cases.

Mathew Hodson (mhodson)
Changed in ghostscript (Ubuntu):
status: New → Fix Released
importance: Undecided → Medium
Changed in ghostscript (Ubuntu Focal):
importance: Undecided → Medium
Mathew Hodson (mhodson)
description: updated
Changed in ghostscript (Ubuntu Focal):
assignee: nobody → Till Kamppeter (till-kamppeter)
tags: added: verification-needed verification-needed-focal
description: updated
Revision history for this message
William Wilson (jawn-smith) wrote :
Changed in ghostscript (Ubuntu Focal):
assignee: Till Kamppeter (till-kamppeter) → William Wilson (jawn-smith)
status: New → In Progress
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

@jawn-smith, I have uploaded the package for your SRU patch now. Thanks for the debdiff.

Robie Basak (racb)
summary: - Fix for Ghostscript 9.50 upstream bug needs to be back-ported
+ `gs [options] -- <input_file>` fails with "permission denied"
Revision history for this message
Robie Basak (racb) wrote :

This looks good, but in addition to the test case in the description, please add a couple of things to your test plan for SRU verification:

1) Dirk F's steps to reproduce in comment 2, because that's the real user impact for which we're doing this SRU.

2) I agree with your assessment under "Regression Potential", so in mitigation please also exercise some other cases of ghostscript command line parsing - for example without '--' - that other tools might use, to ensure that we aren't regressing them.

description: updated
Changed in ghostscript (Ubuntu Focal):
status: In Progress → Fix Committed
Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello Dirk, or anyone else affected,

Accepted ghostscript into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ghostscript/9.50~dfsg-5ubuntu4.4 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Dirk F (fieldhouse) wrote :

My kind back-porter (https://launchpad.net/~savoury1/+archive/ubuntu/graphics) applied the GS commit http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=24ec06a27df63297796a379c95ee5d4b39040410 to his PPA GS 9.50 build (Focal -> Xenial) and that has worked fine. Thanks for pushing this.

Revision history for this message
William Wilson (jawn-smith) wrote :

racb: In order to add the steps from comment #2 as a useful test case, another bug in ocrfeeder needed to be fixed with an SRU. See https://bugs.launchpad.net/ubuntu/+source/ocrfeeder/+bug/1890013 for more details.

Revision history for this message
William Wilson (jawn-smith) wrote :
Download full text (3.7 KiB)

The verification passed for focal.

--------------------------- Test case 1 verification--------------------
ubuntu@focalvm:~$ apt-cache policy ghostscript
ghostscript:
  Installed: 9.50~dfsg-5ubuntu4.3
  Candidate: 9.50~dfsg-5ubuntu4.4
  Version table:
     9.50~dfsg-5ubuntu4.4 500
        500 http://us.archive.ubuntu.com/ubuntu focal-proposed/main amd64 Packages
 *** 9.50~dfsg-5ubuntu4.3 500
        500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        100 /var/lib/dpkg/status
     9.50~dfsg-5ubuntu4 500
        500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
ubuntu@focalvm:~$ gs -- waterfal.ps
GPL Ghostscript 9.50 (2019-10-15)
Copyright (C) 2019 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Error: /undefinedfilename in (waterfal.ps)
Operand stack:

Execution stack:
   %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
   --dict:724/1123(ro)(G)-- --dict:0/20(G)-- --dict:76/200(L)--
Current allocation mode is local
Last OS error: Permission denied
GPL Ghostscript 9.50: Unrecoverable error, exit code 1
ubuntu@focalvm:~$ sudo apt install ghostscript -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libgs9 libgs9-common
Suggested packages:
  ghostscript-x
The following packages will be upgraded:
  ghostscript libgs9 libgs9-common
3 upgraded, 0 newly installed, 0 to remove and 33 not upgraded.
Need to get 2,906 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu focal-proposed/main amd64 ghostscript amd64 9.50~dfsg-5ubuntu4.4 [51.8 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal-proposed/main amd64 libgs9 amd64 9.50~dfsg-5ubuntu4.4 [2,173 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu focal-proposed/main amd64 libgs9-common all 9.50~dfsg-5ubuntu4.4 [682 kB]
Fetched 2,906 kB in 1s (4,127 kB/s)
(Reading database ... 214058 files and directories currently installed.)
Preparing to unpack .../ghostscript_9.50~dfsg-5ubuntu4.4_amd64.deb ...
Unpacking ghostscript (9.50~dfsg-5ubuntu4.4) over (9.50~dfsg-5ubuntu4.3) ...
Preparing to unpack .../libgs9_9.50~dfsg-5ubuntu4.4_amd64.deb ...
Unpacking libgs9:amd64 (9.50~dfsg-5ubuntu4.4) over (9.50~dfsg-5ubuntu4.3) ...
Preparing to unpack .../libgs9-common_9.50~dfsg-5ubuntu4.4_all.deb ...
Unpacking libgs9-common (9.50~dfsg-5ubuntu4.4) over (9.50~dfsg-5ubuntu4.3) ...
Setting up libgs9-common (9.50~dfsg-5ubuntu4.4) ...
Setting up libgs9:amd64 (9.50~dfsg-5ubuntu4.4) ...
Setting up ghostscript (9.50~dfsg-5ubuntu4.4) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for man-db (2.9.1-1) ...
ubuntu@focalvm:~$ gs -- waterfal.ps
GPL Ghostscript 9.50 (2019-10-15)
Copyright (C) 2019 Artifex Software, Inc. All rights reserved.
This software is supp...

Read more...

description: updated
Revision history for this message
William Wilson (jawn-smith) wrote :

Test showing the failure with ocrfeeder before installing from -proposed

Revision history for this message
William Wilson (jawn-smith) wrote :

Test showing ocrfeeder succeeding with the version of ghostscript in -proposed

Revision history for this message
William Wilson (jawn-smith) wrote :

---------------------------- Test Case 3 verification --------------------
ubuntu@focalvm:~$ apt-cache policy ghostscript
ghostscript:
  Installed: 9.50~dfsg-5ubuntu4.4
  Candidate: 9.50~dfsg-5ubuntu4.4
  Version table:
 *** 9.50~dfsg-5ubuntu4.4 500
        500 http://us.archive.ubuntu.com/ubuntu focal-proposed/main amd64 Packages
        100 /var/lib/dpkg/status
     9.50~dfsg-5ubuntu4.3 500
        500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
     9.50~dfsg-5ubuntu4 500
        500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
ubuntu@focalvm:~$ gs waterfal.ps
GPL Ghostscript 9.50 (2019-10-15)
Copyright (C) 2019 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Creating waterfall printout at 4000 DPI.
Loading NimbusMonoPS-Regular font from /usr/share/ghostscript/9.50/Resource/Font/NimbusMonoPS-Regular... 4308816 2840291 2772400 1477426 2 done.
/Courier 6 7 8 9 10 11 12 14 16
/HelveticaLoading NimbusSans-Regular font from /usr/share/ghostscript/9.50/Resource/Font/NimbusSans-Regular... 4395128 3041706 2792600 1499350 3 done.
 6 7 8 9 10 11 12 14 16
%%BoundingBox: 28 18 282 764
%%HiResBoundingBox: 28.547999 18.251999 281.375991 763.055977
>>showpage, press <return> to continue<<

GS>quit
ubuntu@focalvm:~$ echo $?
0
ubuntu@focalvm:~$ gs -r300x300 -sPAPERSIZE=letter -sOUTPUTFILE=waterfal.jpg -dNOPAUSE -dBATCH waterfal.ps
GPL Ghostscript 9.50 (2019-10-15)
Copyright (C) 2019 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Creating waterfall printout at 300 DPI.
Loading NimbusMonoPS-Regular font from /usr/share/ghostscript/9.50/Resource/Font/NimbusMonoPS-Regular... 4329016 2846189 1581112 279688 2 done.
/Courier 6 7 8 9 10 11 12 14 16
/HelveticaLoading NimbusSans-Regular font from /usr/share/ghostscript/9.50/Resource/Font/NimbusSans-Regular... 4395128 3044172 1601312 301839 3 done.
 6 7 8 9 10 11 12 14 16
%%BoundingBox: 22 18 282 763
%%HiResBoundingBox: 22.080001 18.240001 281.520011 762.960029
ubuntu@focalvm:~$ echo $?
0
ubuntu@focalvm:~$ gs -r300x300 -sPAPERSIZE=letter -sOUTPUTFILE=waterfal.jpg -dNOPAUSE -dBATCH -- waterfal.ps
GPL Ghostscript 9.50 (2019-10-15)
Copyright (C) 2019 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Creating waterfall printout at 300 DPI.
Loading NimbusMonoPS-Regular font from /usr/share/ghostscript/9.50/Resource/Font/NimbusMonoPS-Regular... 4329016 2848173 1581112 279944 2 done.
/Courier 6 7 8 9 10 11 12 14 16
/HelveticaLoading NimbusSans-Regular font from /usr/share/ghostscript/9.50/Resource/Font/NimbusSans-Regular... 4395128 3046156 1601312 302095 3 done.
 6 7 8 9 10 11 12 14 16
%%BoundingBox: 22 18 282 763
%%HiResBoundingBox: 22.080001 18.240001 281.520011 762.960029
ubuntu@focalvm:~$ echo $?
0
ubuntu@focalvm:~$

tags: added: verification-done verification-done-focal
removed: verification-needed verification-needed-focal
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ghostscript - 9.50~dfsg-5ubuntu4.4

---------------
ghostscript (9.50~dfsg-5ubuntu4.4) focal; urgency=medium

  * debian/patches/2021_fix-double-hyphen-option.patch: Fix bug
    where using '--' command line syntax fails to read input files
    (LP: #1913656)

 -- William 'jawn-smith' Wilson <email address hidden> Thu, 14 Oct 2021 15:32:37 -0500

Changed in ghostscript (Ubuntu Focal):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for ghostscript has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.