[3733] in linux-net channel archive

home help back first fref pref prev next nref lref last post

Re: LPD kills logins

daemon@ATHENA.MIT.EDU (Carlos Carvalho)
Wed Jul 17 02:13:43 1996

Date: 	Tue, 16 Jul 96 11:22 EST
From: Carlos Carvalho <carlos@riglos.fisica.ufpr.br>
To: David Sowder <davids@cosmic.swac.edu>
Cc: linux-net@vger.rutgers.edu
In-Reply-To: <Pine.LNX.3.91.960715153318.21247A-100000@cosmic.swac.edu>

David Sowder (davids@cosmic.swac.edu) wrote on 15 July 1996 15:51:
 >I have a linux system that was working fine until the other day.  I had 
 >an lpr queue that was giving me fits.

Yes, I know what you mean :-(

 >Anyway, taking a long shot, I decided to restart the parent lpd daemon.  
 >I kill -SIGHUPed the lpd daemon and rm'd the lock and lpd.lock files from 
 >the /var/spool/lpd directory and then ran /usr/sbin/lpd.  The system 
 >froze for most practical purposes.  I got the shell prompt back and typed 
 >another command, ls -l I think, and the system never responsded.  I tried 
 >opening another session with telnet.  It got to the escape character 
 >line, but never showed the login banner or the login prompt.  I then 
 >tried to log in from the console, but none of my typing echoed.  I 
 >rebooted the computer with the power switch and everything looked fine 
 >until it was starting the various daemons.  It started the lpd daemon 
 >last and advanced the cursor to the next line but then froze up in the 
 >same way as before without giving a login banner or prompt.
 >
 >I rebooted with the Slackware install disks and renamed lpd so that it 
 >would not run lpd on startup and everything ran fine, until I started lpd 
 >when it would freeze in the same manner.
 >
 >I'm stumped.  The logs on the remote syslog machine don't say anything 
 >about lpd or anything related that I can see.

The system freezes because it goes into a fork bomb. When lpd starts,
it spawns a child for each printer queue you have, the child looks
if there's something to print and after printing any spooled jobs it
exits.

The key point is that the parent lpd scans /etc/printcap for the
queues. For some reason, the scanning goes bonkers and it finds
hundreds of "queues", and therefore forks madly, bringing down the
machine. I tried to find why this happens, and put a syslog() call
after every queue found. The /var/log/messages files shows A LOT of
repetition of print queues, and sometimes only partial lines from
/etc/printcap, which cause "unkown printer" messages from the
children.

So why doesn't it scan the printcap lines correctly? I stared at the
code and found no problem. I then changed the syslog() call to a
fprintf() to a file obtained from tmpnam(), and the problem persisted.
I added more fprintf's to check that each complete line of
/etc/printcap is correctly built. The lines are correct, but the
problem persists. I finally put a fflush() after every fprintf() and
the problem vanished! I don't know if the problem is with libc or the
kernel, or somewhere else.

This is an important issue for me. Any clues?

Carlos


home help back first fref pref prev next nref lref last post