Bug 3516

Summary: lpd barfs on remote files
Product: [Retired] Red Hat Linux Reporter: eric
Component: lprAssignee: David Lawrence <dkl>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-06-17 14:50:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description eric 1999-06-17 00:01:32 UTC
When trying to print files from a remote Red Hat 6.0 system
to a Red Hat 6.0 lpd spool, the print daemon dies. The error
log is filled with a message

Jun 16 15:55:18 nfs lpd[11408]: Can't create temp cfp file
Jun 16 15:55:18 nfs last message repeated 1016 times
Jun 16 15:55:18 nfs lpd[11408]: lp: can't scan
/var/spool/lpd/lp

The problem is in file 'printjob.c' (under the 'lpd'
directory) in the 'sendit' routine. The lpr spool command
has been modified to put control files into the spool
directory that are appended with the name of the system
sending the job, rather than the fixed-size control file
names that were previously the norm. The problem is that the
file name is assumed to be that fixed size, and the last six
characters of that fixed size are overwritten with XXXXXX
and handed off to mktemp(). So you get stuff like
"cf134a1XXXXXXebes" (the XXX's are overwritting part of the
host name, which would not have been there for a local print
job) rather than a useful string for 'mktemp'.  The problem
is that if the last character of the string is not an "X",
mktemp() returns a null string, and you get the message in
question!

My solution: just write a 0 after the last 'X' to terminate
the string. The filenames for the temp files will still be
unique because the print job names are incremented and are
in that first 7 characters. Here is my patch:
-------------------------start patch--------------------
--- printjob.c.orig	Tue Feb 16 13:01:45 1999
+++ printjob.c	Wed Jun 16 16:05:30 1999
@@ -770,6 +770,7 @@
 	  {
 	    dup_cfpname = strdup(file);
 	    memcpy((dup_cfpname+7), "XXXXXX", 6);
+            dup_cfpname[13]=0;  /* fix by eric! */
 	    mktemp(dup_cfpname);
 	    tmpmask = umask(007);
 	    dup_cfp=fopen(dup_cfpname, "w");
---------------------end of patch--------------------

That should fix *THIS* bug, at least...

Eric Lee Green  eric
SysAdmin/Software Engineer
Enhanced Software Technologies, Inc. ("The BRU Guys")

Comment 1 Bill Nottingham 1999-06-17 14:50:59 UTC
ths has been fixed in the latest lpr release (0.36-4), available
from rawhide.redhat.com.