[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#656660: foomatic-rip: dying with "Cannot find a writable temp dir"



Package: foomatic-filters
Version: 4.0.5-6+squeeze1
Severity: important


When running lenny, I have been using foomatic-rip with lprng.
On upgrading to squeeze, foomatic-rip fails with the message:
 process dying with "Cannot find a writable temp dir".

The error seems to be in function "temp_dir()" in source file "util.c",
The search for a temporary-file directory, encounters a
premature NULL pointer (from getenv) which terminates the search.
The undeclared variable "P_tmpdir" also seems to be a NULL pointer.
Also, in  foomatic-filters_4.0.9 (from unstable), the declaration of
dirs lacks a terminating NULL.

I observe that this code is not used by the CUPS printing system,
but it is required by lprng. CUPS passes data to foomatic rip as
command-line arguments; lprng uses a pipe.

I don't know how to make patches properly (I apologise),
 so I'll just put my code for temp_dir() here.
It works when I test it.  
---------------------------------
const char * temp_dir()
{
    static const char *tmpdir = NULL;

    if (!tmpdir)
    {
 	/*
	 * getenv returns NULL if no match & prematurely terminates search;
	 * remove undeclared NULL pointer, P_tmpdir, from the list;
         * terminating NULL is required to stop search.
        */
        const char *dirs[] = { getenv("TMPDIR"), "/tmp", NULL };
        const char **dir;
	/* The fix ... */
	if ( dirs[0] == NULL ) dirs[0]=" ";
        for (dir = dirs; *dir; dir++)
            if (access(*dir, W_OK) == 0) {
                tmpdir = *dir;
                break;
            }
/*
 *  alternative to the above:
 *  WARNING : not tested
        const char env_tmp = getenv("TMPDIR"), sys_tmp="/tmp";
        if (  access(env_tmp, W_OK) == 0 )
             tmpdir = env_tmp;
        else if ( access(sys_tmp, W_OK) == 0 )
             tmpdir = sys_tmp;
*/
        if (tmpdir)
        {
            _log("Storing temporary files in %s\n", tmpdir);
            setenv("TMPDIR", tmpdir, 1); /* for child processes */
        }
        else
            rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS,
                    "Cannot find a writable temp dir.");
    }

    return tmpdir;
}
------------------------------















-- System Information:
Debian Release: 6.0.3
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages foomatic-filters depends on:
ii  bash                   4.1-3             The GNU Bourne Again SHell
ii  debconf [debconf-2.0]  1.5.36.1          Debian configuration management sy
ii  libc6                  2.11.2-10         Embedded GNU C Library: Shared lib
ii  perl                   5.10.1-17squeeze2 Larry Wall's Practical Extraction 
ii  ucf                    3.0025+nmu1       Update Configuration File: preserv

Versions of packages foomatic-filters recommends:
ii  a2ps                        1:4.14-1.1   GNU a2ps - 'Anything to PostScript
ii  enscript                    1.6.5.2-1    converts text to Postscript, HTML 
pn  foomatic-db-engine          <none>       (no description available)
ii  ghostscript                 8.71~dfsg2-9 The GPL Ghostscript PostScript/PDF
ii  lprng [lpr]                 3.8.A-3      lpr/lpd printer spooling system
ii  mpage                       2.5.6-1      print multiple pages per sheet on 
ii  poppler-utils               0.12.4-1.2   PDF utilitites (based on libpopple

foomatic-filters suggests no packages.

-- debconf-show failed



Reply to: