Hi,

While playing with lpd, I saw this message in syslog:

Nov 21 08:30:55 clyde lpd: vfprintf %s NULL in "mail sent to user %s about job 
%s on printer %s (%s)"

The /var/log/lpd-errs contains:

Nov 21 08:30:55 clyde lpd[671]: lp: filter 'f' exited (retcode=143)
Nov 21 08:30:55 clyde lpd[671]: mail sent to user semarie about job test.pdf on 
printer lp ((null))
Nov 21 08:30:55 clyde lpd[671]: lp: job could not be printed (cfA013clyde.local)

The following diff ensures `cp' variable (last %s argument) is always
set in all cases.

Actually, on FILTERERR, if the tempfile is empty (or not exists), `cp'
isn't set and remains NULL.

In order to reproduce, my /etc/printcap is:

lp:\
        :lp=/dev/null:\
        :if=/etc/foomatic/scripts/test.sh:\
        :sd=/var/spool/output/lpd:\
        :lf=/var/log/lpd-errs:\
        :sh:

And /etc/foomatic/scripts/test.sh is:

#!/bin/sh
exit 143


With the patch applied (and lpd restarted), my lpd-errs has:

Nov 21 08:31:36 clyde lpd[9254]: lp: filter 'f' exited (retcode=143)
Nov 21 08:31:36 clyde lpd[9254]: mail sent to user semarie about job test.pdf 
on printer lp (FILTERERR)
Nov 21 08:31:36 clyde lpd[9254]: lp: job could not be printed 
(cfA014clyde.local)

-- 
Sebastien Marie


Index: lpd/printjob.c
===================================================================
RCS file: /cvs/src/usr.sbin/lpr/lpd/printjob.c,v
retrieving revision 1.57
diff -u -p -U5 -r1.57 printjob.c
--- lpd/printjob.c      29 Jan 2016 21:23:11 -0000      1.57
+++ lpd/printjob.c      21 Nov 2016 07:34:43 -0000
@@ -1159,20 +1159,20 @@ sendmail(char *user, int bombed)
                case NOACCT:
                        printf("\ncould not be printed without an account on 
%s\n", host);
                        cp = "NOACCT";
                        break;
                case FILTERERR:
+                       cp = "FILTERERR";
                        if (stat(tempfile, &stb) < 0 || stb.st_size == 0 ||
                            (fp = fopen(tempfile, "r")) == NULL) {
                                printf("\nhad some errors and may not have 
printed\n");
                                break;
                        }
                        printf("\nhad the following errors and may not have 
printed:\n");
                        while ((i = getc(fp)) != EOF)
                                putchar(i);
                        (void)fclose(fp);
-                       cp = "FILTERERR";
                        break;
                case ACCESS:
                        printf("\nwas not printed because it was not linked to 
the original file\n");
                        cp = "ACCESS";
                }

Reply via email to