Bug#776315: foomatic-filters: foomatic-rip can't properly execute text filters

2022-01-26 Thread Alexander Zangerl
On Mon, 26 Jan 2015 18:34:44 +, Martín Ferrari writes:
>Following with strace, I see that foomatic-rip is incorrectly executing
>commands in the shell:
>
>[pid 13859] execve("/bin/bash", ["/bin/bash", "-c", "mpage -o -1 -b Letter -H
>-h Documentation for the Lexmark X792 Foomatic/Postscript -m36l36b36t36r -f -P-
>-"], [/* 38 vars */]) = 0

this can be fixed by changing just one line in fileconverters.c;
if the @@JOBTITLE@@ placeholder is prefixed by '\"' (and only prefixed),
then the argument prep logic wraps it suitably. (it's still a
pretty ugly mess, what with unnecessary detours via a shell but
that's a separate story.)

the attached patch makes that change, and a quick check with strace confirms
that a2ps is now called correctly:

25389 execve("/bin/bash", ["/bin/bash", "-c", "a2ps -1 --medium=A4dj 
--center-title=\"Documentation for the Ricoh SP C250DN PS\" -o -"], 
0x7fffc24477b8 /* 38 vars */ 
...
25389 execve("/usr/bin/a2ps", ["a2ps", "-1", "--medium=A4dj", 
"--center-title=Documentation for the Ricoh SP C250DN PS", "-o", "-"], 
0x55f407b0f1b0 /* 37 vars */) = 0

>At the same time, I don't see any code generating the docs I am looking for, it
>seems commented out. So maybe that is also broken?

yes, it's nonexistent: they never migrated the documentation extraction code
from version 3.x's perl (where it was very simple to do) to version 4.x's c
codebase (where it's a bit more work) - but the did leave the
broken/incomplete '-o docs' in the code and the documentation :-(

i recreated something not entirely unlike that doc extractor earlier today
and will submit it in a separate bug regarding the misleading docs and
code leftovers.

--- a/fileconverter.c
+++ b/fileconverter.c
@@ -37,9 +37,9 @@
  * is not set. (Except if the spooler is CUPS, then 'texttops' is used
  */
 const char *fileconverters[][2] = {
-{ "a2ps", "a2ps -1 @@--medium=@@PAGESIZE@@ @@--center-title=@@JOBTITLE@@ -o -" },
+{ "a2ps", "a2ps -1 @@--medium=@@PAGESIZE@@ @@--center-title=\"@@JOBTITLE@@ -o -" },
 { "enscript", "enscript -G @@-M @@PAGESIZE@@ @@-b \"Page $%|@@JOBTITLE@@ --margins=36:36:36:36 --mark-wrapped-lines=arrow --word-wrap -p-" },
-{ "mpage", "mpage -o -1 @@-b @@PAGESIZE@@ @@-H -h @@JOBTITLE@@ -m36l36b36t36r -f -P- -" },
+{ "mpage", "mpage -o -1 @@-b @@PAGESIZE@@ @@-H -h \"@@JOBTITLE@@ -m36l36b36t36r -f -P- -" },
 { "paps", "paps @@--paper @@PAGESIZE@@ --header --font=11.5" },
 { NULL, NULL }
 };
-- 
Alexander Zangerl + GPG Key 2FCCF66BB963BD5F + http://snafu.priv.at/
Fachbegriffe der Informatik, GNU: GNU is Not Useful, ohne Windows 
oder Linux darunter. -- Uwe Ohse


signature.asc
Description: Digital Signature


Bug#776315: foomatic-filters: foomatic-rip can't properly execute text filters

2015-01-26 Thread Martín Ferrari
Package: foomatic-filters
Version: 4.0.17-5
Severity: normal

While trying to setup a printer directly with foomatic and rlpr, I executed the
documented command to get a printout of config values:

$ foomatic-rip -P printer -o docs /proc/cpuinfo

I noticed errors, and the command waiting on stdin, and nothing getting
printed.

Following with strace, I see that foomatic-rip is incorrectly executing
commands in the shell:

[pid 13859] execve(/bin/bash, [/bin/bash, -c, mpage -o -1 -b Letter -H
-h Documentation for the Lexmark X792 Foomatic/Postscript -m36l36b36t36r -f -P-
-], [/* 38 vars */]) = 0

[pid 13859] execve(/usr/bin/mpage, [mpage, -o, -1, -b, Letter,
-H, -h, Documentation, for, the, Lexmark, X792,
Foomatic/Postscript, -m36l36b36t36r, -f, -P-, -], [/* 37 vars */]) =
0

As you can see, it is calling system() with an improperly quoted command.
Looking at the source code, I don't see any simple way to solve this. It is
pretty ugly...

At the same time, I don't see any code generating the docs I am looking for, it
seems commented out. So maybe that is also broken?

-- System Information:
Debian Release: 8.0
  APT prefers testing
  APT policy: (500, 'testing'), (100, 'unstable'), (50, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages foomatic-filters depends on:
ii  bash   4.3-11+b1
ii  debconf [debconf-2.0]  1.5.55
ii  libc6  2.19-13
ii  libdbus-1-31.8.12-3
ii  ucf3.0030

Versions of packages foomatic-filters recommends:
ii  a2ps   1:4.14-1.3
ii  colord 1.2.1-1+b2
ii  cups-client1.7.5-10
ii  ghostscript9.06~dfsg-1.1+b1
ii  mpage  2.5.6-1
ii  poppler-utils  0.26.5-2
ii  rlpr   2.05-4

foomatic-filters suggests no packages.

-- debconf information:
  foomatic-filters/title:
  foomatic-filters/custom_textfilter:
  foomatic-filters/filter_debug: false
  foomatic-filters/spooler: cups
  foomatic-filters/textfilter: Automagic
  foomatic-filters/config_parsed: true
  foomatic-filters/ps_accounting: true


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org