Anyone tried building smbsh on Linux lately?
davecb at canada.sun.com
Sat Mar 23 07:49:01 GMT 2002
Steve Langasek wrote:
> On Fri, Mar 22, 2002 at 12:25:40PM -0500, David Collier-Brown wrote:
> > A colleague (Fred Weigel) just prototyped an interposer
> > library on Linux 2.2 using LD_PRELOAD, which worked
> > happily, substantially the same as on Solaris.
> > In addition, dlsym(RTLD_NEXT,...) seems to be
> > supported.
> > Any other things necessary for smbsh on Linux?
> On Linux, that sounds to me like it's everything that's needed. As a
> general-purpose rewrite of smbsh that works on multiple platforms, I
> would guess that there needs to be something in the configure script to
> figure out the path to the appropriate C library.
As long as you're not doing your dlsyms in a vendor-
specific _init function, you can use the RTLD_NEXT
option to dlsym.
Failing that, use syscall and don't call the libraries at all.
From the (Solaris) man page,
void *dlsym(void *handle, const char *name);
The dlsym() function allows a process to obtain the address
of a symbol defined within a shared object or executable.
The handle argument is either the value returned from a call
to dlopen() or one of the special handles RTLD_DEFAULT,
RTLD_NEXT, or RTLD_SELF. The name argument is the symbol's
name as a character string.
In the case of a handle returned from dlopen(), the
corresponding shared object must not have been closed using
dlclose(). The dlsym() function searches for the named sym-
bol in all shared objects loaded automatically as a result
of loading the object referenced by handle. See dlopen(3DL).
In the case of the special handle RTLD_DEFAULT, dlsym()
searches for the named symbol starting with the first object
loaded and proceeding through the list of initial loaded
objects, and any global objects obtained with dlopen(3DL),
until a match is found. This search follows the default
model employed to relocate all objects within the process.
[And finds the interceptor you just wrote (:-(]
In the case of the special handle RTLD_NEXT, dlsym()
searches for the named symbol in the objects that were
loaded following the object from which the dlsym() call is
being made. [Ie, the underlying symbol, in libc and so
forth. This does require the
[and RTLD_SELF searches in the current .so]
David Collier-Brown, | Always do right. This will gratify
Performance & Engineering | some people and astonish the rest.
Americas Customer Engineering, | -- Mark Twain
(905) 415-2849 | davecb at canada.sun.com
More information about the samba-technical