Bug#165436: tetex-bin: Declaring a shell rule for including graphics causes latex to report that the command failed
Package: tetex-bin
Version: 1.0.7+20011202-8.1
Severity: normal
Tags: patch
If you declare a graphics rule in latex, such as:
\DeclareGraphicsRule{.jpg}{eps}{.jpg.bb}{`/home/anderse/public_html/convert-ps #1 }
latex the file, and then try to run dvips on the .dvi file, you will
get messages of the form:
Execution of </home/anderse/public_html/convert-ps tiny/img-3861.jpg > failed
Further inspection indicates that the problem is that dvips is using
popen(command,"rb"); and with the testing libc (2.2.5-14.3) popen will
always return NULL and claim EINVAL, as can be verified using the following
two-line c program:
#include <stdio.h>
int main() { FILE *f = popen("echo","rb");printf("%x\n",f); }
Changing the "rb" to "r" will make the popen work.
Inspection of the source code found two locations where popen was used
in "rb" mode. The following patch fixes both of those. It is unclear
to me from the popen man page whether popen() is supposed to accept
"rb", fopen() does. If you belive that popen should be working in
this case, then a bug should be filed against glibc, although I would
imagine it would have a similarly simple fix. The version -8.1 is for
the install of my patch on the -8 debian version of the package.
-Eric
*** texk/dvipsk/finclude.c-orig 2002-10-18 19:19:35.000000000 -0700
--- texk/dvipsk/finclude.c 2002-10-18 19:20:11.000000000 -0700
***************
*** 410,416 ****
/*
* Allow scanning of ` commands. Better return same results both times.
*/
! f = popen(filename+1, FOPEN_RBIN_MODE) ;
to_close = USE_PCLOSE ;
} else {
f = search(figpath, filename, READ) ;
--- 410,416 ----
/*
* Allow scanning of ` commands. Better return same results both times.
*/
! f = popen(filename+1, FOPEN_R_MODE) ;
to_close = USE_PCLOSE ;
} else {
f = search(figpath, filename, READ) ;
*** texk/dvipsk/output.c-orig 2002-10-18 19:19:41.000000000 -0700
--- texk/dvipsk/output.c 2002-10-18 19:20:40.000000000 -0700
***************
*** 174,180 ****
#endif
if (secure == 0) {
(void)sprintf(errbuf, "Execution of <%s> failed ", s) ;
! f = popen(s, FOPEN_RBIN_MODE) ;
}
else {
(void)sprintf(errbuf,"Secure mode is %d so execute <%s> will not run", secure,s) ;
--- 174,180 ----
#endif
if (secure == 0) {
(void)sprintf(errbuf, "Execution of <%s> failed ", s) ;
! f = popen(s, FOPEN_R_MODE) ;
}
else {
(void)sprintf(errbuf,"Secure mode is %d so execute <%s> will not run", secure,s) ;
-- System Information
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux eric-6100 2.4.18 #1 Sat May 18 21:33:38 PDT 2002 i686
Locale: LANG=en_US, LC_CTYPE=en_US
Versions of packages tetex-bin depends on:
ii debianutils 1.16.3 Miscellaneous utilities specific t
ii dpkg 1.10.4 Package maintenance system for Deb
ii ed 0.2-19 The classic unix line editor
ii libc6 2.2.5-14.3 GNU C Library: Shared libraries an
ii libkpathsea3 1.0.7+20011202-8 shared libkpathsea for teTeX
ii libpng3 1.2.1-4 PNG library - runtime
ii libstdc++2.10-glibc2.2 1:2.95.4-11 The GNU stdc++ library
ii libtiff3g 3.5.5-6 Tag Image File Format library
ii libxaw7 4.1.0-17 X Athena widget set library
ii tetex-base 1.0.2+20011202-3 basic teTeX library files
ii xlibs 4.1.0-17 X Window System client libraries
ii zlib1g 1:1.1.4-4 compression library - runtime
Reply to: