redirection and smbwrapper

Alexandre Oliva oliva at dcc.unicamp.br
Sat Oct 3 15:01:34 GMT 1998


Andrew Tridgell <tridge at samba.anu.edu.au> writes:

>> How about an environment variable?  The library start-up code could
>> check whether the variable is defined and use its contents to map file 
>> descriptors to SMB files.

> that might work. hmmm, something like this:

> 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.

> 3) in the first wrapper call check for a SMBW_FD environment variable
>    and if set then open the files specified in the env and dup2() them
>    to the right fd

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.

-- 
Alexandre Oliva
mailto:oliva at dcc.unicamp.br mailto:aoliva at acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



More information about the samba-technical mailing list