Bad file descriptors with samba-2.2.x -- more details.

wolfgang.glas at wolfgang.glas at
Thu Jun 27 10:57:04 GMT 2002

Dear samba team,

  It's now been several weeks we had two short threads without results on 
the Badfile desciptor errors here on this list.

   In thge meanwhile I received more feedback from users experiencing the 
same problem (see cc-list above), most notable the contribution of Kid Mun 
Yap, which should really bring us into the position to make the problem 

   According to him I will snip the contents of his postings and add them 

   In short, he experiences the Bad filedescriptor error in sys_lseek, 
when the

lpq command=

parameter is set to an empty string (as in the line above). In his example 
this is due to some problems with the samba printer initialization code, 
other user (including me) had set an empty string inside their smb.conf, 
because they were configuriong special printer not addressable via lpr 

   Other symptoms are corrupted files (in my case files, which were opened 
by users, in other cases on my server and on Kid Yun's server, log.amb was 
corrupted), which are filled with the contents of print jobs (Postscript 
code, e.g.).

   I don't know, whether this is the only occasion for the Bad file 
descriptor to appear in the log, since other users are experienceing 
similar error, when their tdb-files are on reiserfs or XFS.

   In both situations, a wrong lpq command or a tdb corruption, it seem 
really weird to me experiencing bad file descriptor errors on user files 
rather than file error from tdb or errors from the printer queue code, so 
even the fact, that samba has a tendency to corrupt user files in a 
situation, when some seondary resource shows a failure, seem to be a samba 

   So I kindly request all users experiencing the problem to check their 
lpq command setting and hopefully we can enable Jeremy or any other samba 
team member to reproduce the problem.



----first message of Kid Mun Yap------------------- 

I recently encountered what could be the same problem and when I searched 
on google I found the article you posted. The thread in the archive seem 
have just ended with no solution (was it progressed any further?). 

I encountered exactly the same symptoms (file corruption lseek bad file 
descriptor errors in the log, junk in the log that seems to be part of 
files etc.). 
After looking on the net and finding your article but still no solution I 
did some 
very frustrating debugging and tracked my problem down to the printing 

My samba was compiled to default to CUPS printing but in my config I 
changed it to bsd and as a result the "lpq command" was empty, so 
everytime I printed something to my fax printer, the client tried to query 
the queue state from samba and samba, after a few times attempting to use 
an empty lpq command, goes crazy and causes all the above errors. I fixed 
by placing 'lpq command = /bin/echo'.

This may or may not be the same problem as yours but thought you might 
like to know.

Kid Mun

----second message by Kid Mun Yap------------------
> BTW, May I forward your message to the samba list ?

No problem. I would post it myself but I'm not currently subscribed.

> Do you have more detailed information on "my samba was going crazy..."

I was experiencing a lot of problems. Files that I would open would get 
corrupted after printing, with errors like the following
popping up...

[2002/06/27 22:10:43, 0] smbd/fileio.c:seek_file(43)
  seek_file: (Server Documents/Document.doc) sys_lseek failed. Error was 
Bad file descriptor

A lot of junk which looks like parts of printed files were getting into 
the log as well (since I had the printer set up as a
postscript printer, these were parts of postscript files).

The corrupted files were actually getting bigger, I suspect parts of the 
printed files were getting into them as well, but I
couldn't confirm for sure.

The reason why I detected the problem was because I was already looking at 
the samba print initialisation code, and
discovered that...
when you don't have bsd compiled as default doesn't really work
(I suspect because init_printer_values gets called from init_globals in 
param/loadparm.c before any parameters are read,
hence before printing=bsd has been processed, I also believe someone has 
reported this problem before a long while back).

Anyway, as a result all my printer related settings were empty instead of 
having the proper default value, but the lpq
command being empty seems to cause samba a lot of grieve, probably because 
it gets used everytime the client queries for
a queue status (which from what I can gather is quite often). I haven't 
gotten around to look at the exact cause of the problem
(why an empty lpq command should cause such a catastrophic chain of event) 

Hope this helps.

Kid Mun
PS: Feel free to post all or part of this email to samba-technical.
--------end of forwarded messages-------------------

More information about the samba-technical mailing list