Bug 2676 - Printer job was not unlinked
Printer job was not unlinked
Product: Red Hat Linux
Classification: Retired
Component: lpr (Show other bugs)
All Linux
high Severity medium
: ---
: ---
Assigned To: David Lawrence
Depends On:
  Show dependency treegraph
Reported: 1999-05-08 21:39 EDT by genec
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 1999-06-17 17:18:37 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description genec 1999-05-08 21:39:24 EDT
I am reporting this for RedHat 6.0 but it also occurs under

I recently changed my printer connection from a parallel
port connection one via an HP JETDIRECT EX PLUS box -- the
printer (HP 4000) remained the same.

Linux is configured with the printer as an LPD remote at an
IP address (e.g., and queue pscript [this name
does not seem to matter).  Everthing works fine in that
output is properly printed BUT every print job results in an
email msg sent to the user whose job was printed:

From: bin <bin@xxx.home>
Subject: lp printer job "<unknown>"

Your printer job
was not unlinked: primission denied

Comment 1 Bill Nottingham 1999-05-10 12:32:59 EDT
Is the message coming from the local machine or the JetDirect box?

------- Email Received From  "Gene C." <genec@mindspring.com> 05/10/99 18:49 -------
Comment 2 Bill Nottingham 1999-05-11 10:19:59 EDT
What are the permissions on the files still remaining in the spool
directory? (and the permissions on the spool directory)
Comment 3 genec 1999-05-21 23:17:59 EDT
After a bit of looking at the my sitution I have located the bugs in
the lpr code -- specifically in lpd/printjob.c.

1. The code supporting network printers (or spooling to another lpd
system) is really kludgy!!  This stuff needs a rewrite bigtime.  I am
not sure if the patches will work in "all" cases but they "seem to fix
the basic problems.

2. Ths first bug is the use of fputs rather than fprintf which causes
two cpf lines to be merged.

diff -uNr lpr-0.36.orig/lpd/printjob.c lpr-0.36/lpd/printjob.c
--- lpr-0.36.orig/lpd/printjob.c	Mon May 10 11:06:22 1999
+++ lpr-0.36/lpd/printjob.c	Fri May 21 20:58:03 1999
@@ -896,7 +896,7 @@
 			  if (dup_cfp)
-			    fputs(line, dup_cfp);
+			    fprintf(dup_cfp, "%s\n", line);

                         sendresult = sendfile('\3', last+1);

3. The second bug is that the code really trys to delete a file twice.
This patch ignore an error indicating that the unlink is for a file
which does not exist.

diff -uNr lpr-0.36.orig/lpd/printjob.c lpr-0.36/lpd/printjob.c
--- lpr-0.36.orig/lpd/printjob.c	Fri May 21 21:16:26 1999
+++ lpr-0.36/lpd/printjob.c	Fri May 21 21:55:34 1999
@@ -1191,6 +1191,21 @@
 	char *host;
 	char *user;
+	/* this hack duplicates some code but things should work
better */
+	/* if the file does not exist, do not worry about doing unlink
+	int ret;
+	extern int errno;
+	if ((strchr(file,'/') == NULL) &&
+	    (strstr(file,"..") == NULL)) {
+		ret = unlink(file);
+		if (ret == 0)
+			return;
+		if (errno == 2)
+			return;
+		syslog(LOG_ERR,"unlink file=%s, ret=%i, errno=%i",
+			file, ret, errno);
+	}
 	if (dounlink(file, host, user))
 		sendmail(user, UNLINK);

These patches were created against source obtained from 1.3.7 of

------- Email Received From  "Gene C." <genec@mindspring.com> 05/21/99 23:22 -------
Comment 4 Bill Nottingham 1999-06-17 17:17:59 EDT
fixed in lpr-0.37...

Note You need to log in before you can comment on or make changes to this bug.