redirection and smbwrapper

Andrew Tridgell tridge at samba.anu.edu.au
Sat Oct 3 15:19:58 GMT 1998


> > 1) wrap dup2() and dup() to catch the file descriptor creation
> 
> These could already create the environment variables.  In fact, all
> wrapper functions could do that, so you'd save the special case in
> fork().  Since you're going to have to keep that information in case
> of fork&exec anyway, you could always keep it in environment
> variables.

I'd rather not do that. The environment could easily overflow if you
open lots of files. I'd rather only use env variables for files when
necessary (ie. at fork())

Otherwise I'll have to start using shared memory, which opens a real
can of worms.

> Actually, you should do that as the library is loaded, not at the
> first call.  The later you do it, the greater the probability of some
> other call have stolen the fd.  In fact, a simple way to avoid that
> would be to ensure that any SMB-mapped file descriptor is really open, 
> either a TCP connection to the server or /dev/null.

I'm not sure how to hook the library start ... 

maybe I could open /dev/null for each file descriptor at execve()
time (just before the exec) then just rely on catching read/write.

I'm tempted to leave redirection as broken for the moment, and wait
till I think of a clean solution, or people start demanding it :-)


More information about the samba-technical mailing list