*BSD News Article 36142


Return to BSD News archive

Xref: sserve comp.unix.programmer:20327 comp.unix.questions:55556 comp.unix.bsd:14946
Newsgroups: comp.unix.programmer,newbridge.comp,comp.unix.questions,comp.unix.bsd
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!howland.reston.ans.net!wupost!news.utdallas.edu!corpgate!bcarh8ac.bnr.ca!bnrgate!nott!nbkanata!newshost.newbridge.com!shayman
From: shayman@Newbridge.COM (Scott Hayman)
Subject: Q: set user ID bit and shared libraries
Message-ID: <Cw6Dq0.G76@Newbridge.COM>
Summary: Executabls with UID bit set can't find shared libraries
Keywords: UID, shared libraries
Sender: usenet@Newbridge.COM
Organization: Newbridge Networks Corporation
X-Newsreader: TIN [version 1.2 PL2]
Date: Thu, 15 Sep 1994 14:32:23 GMT
Lines: 48

I am having a problem getting an executable with its UID bit set to
find a shared library.  I am running on sunOS 4.1.3.

According to ld(1), "when running a set-user- or set-group-ID program,
ld.so will only search for shared libraries in directories it
"trusts", which are /usr/lib, /usr/5lib/, /usr/local/lib, and any
directories specified within the executable as a result of -L options
given when the executable was constructed." The shared library that I
want the executable to find is in the current directory (and it won't
be the same on all machines).

The first thing I tried to do was to specify -L./ at link time, along
with the other -L options needed to link successfully.  Let's say that
the executable was linked in directory A and the shared library was
built in directory B.  When the linker linked the exec in dir A, it
resolved the library reference of db to B/libdb.sa.1.0.  I then
changed the owner of the exec, set its UID bit, copied the shared
library to directory A, and umounted the file system containing
directory B.  In other words, I removed access to the shared library
that was available at link time and put a copy of the shared library
in the current directory.  But when I ran ldd on the exec, it said it
couldn't find the shared lib.  I tried putting the -L./ as the last -L
link option, as well as the first, all to no avail.  I even tried
putting a copy of the shared lib in /usr/lib, but ldd still said that
it couldn't find the shared lib.

I then tried copying the shared lib to directory A and then linked the
exec.  I then copied the exec and shared lib to directory C and
unmounted the filesystem containing directory A.  After changing the
owner of the exec and setting its UID bit, ldd still told me it
couldn't find the shared lib.  It couldn't find it even after I
remounted A, only after remounting B coult it find it there - even
though ld resolved the db reference to directory A.

My question is this: does an executable with its UID bit set search
for shared libaries, or does it only try to find it where it was
built?  Is there a way to build an executable with its UID bit set so
that it can find a shared library in the current directory, even if
the current directory won't be the same on all machines?

Any help would be much appreciated.

Scott
--
Scott Hayman
CrossKeys Systems Corporation
(613) 591-1600 x4928
shayman@newbridge.com