From: dhami@cs.ubc.ca (Mandeep S Dhami)
Newsgroups: comp.windows.x,comp.sys.sun.admin,comp.unix.admin,comp.unix.questions,comp.unix.wizards
Subject: Re: MIT X11R5 problem with SUID & SGID
Date: 15 Oct 1992 00:03:22 -0700
Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
NNTP-Posting-Host: valhalla.cs.ubc.ca

veiss@cbmvax.commodore.com (Jeff Veiss - Staff) writes:
On:
> 
>Sun Sparc ELC
>SunOS Release 4.1.1
>MIT's X11R5 patch 19
 ...

Problem:
>It all started when I tried to execute xterm and it didn't
>want to find the required shared libraries, particularly
>libXaw.so.5.0 even though the libraries were in the
>$LD_LIBRARY_PATH environment variable 

From man ld (on suns):

                                  When building a program
  in which one or more objects are loaded when  -Bdynamic
  is in effect, those directories specified by -L options
  will be "remembered" for use at execution  time.   This
           ^^^^^^^^^^
  permits  the  construction of software that uses shared
  objects as libraries not residing in the standard loca-
             ^^^^^^^^^^^^^^^^^^^^^^
  tions  and  avoids  requiring  the specification of the
  LD_LIBRARY_PATH environment variable in order  to  exe-
  cute  such  software.   Note  that such directories are
  retained in exactly the form specified in  the  option,
              ^^^^^^^
  which  means  that  relative  directory  specifications
  (i.e., not beginning with "/") will be evaluated  rela-
  tive  to the current directory when the program is run,
  not just during the operation of ld.
  ...

                   NOTE:  when  running  a  set-user-  or
  set-group-ID   program,  ld.so  will  only  search  for
  libraries  in  directories  it  "trusts",   which   are
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  /usr/lib,  /usr/5lib,  /usr/local/lib,  and  any direc-
  tories specified within the executable as a  result  of
  -L options given when the executable was constructed.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

As I understand it, when compiling xterm you specified -L relative
to present dir. OR used LD_LIBRARY_PATH to find them. SO, when you
exec. xterm, it can not find libXaw.so.5 in the standard place (and
it won't check in $LD_LIBRARY_PATH as it is suid prog. (I think the
reason for suid'ing to root is to update /etc/utmp). Using correct
-L option should fix your problem.

>Apparently, the problem was the setuid bit in the permissions.  xterm
>was installed following the instructions in the RELNOTES.TXT file
>(make World ..., make install).  Does the suid bit need to be set
>for xterm?  It seems to run ok without it. 

Is /etc/utmp world writeable? Or you don't care for utmp update?
 (BTW, On our X installation, the Makefile for xterm has the full
 path for the shared libs in -L option. I did not install it so I
 am not sure if it is the default or was later fixed; you want to
 check this up too.)

>is occurring with xload except with the setgid bit.  Unfortunately,
>this one needs to be set to access the /dev/kmem device.  Any explanations
>for this phenomena and how to fix xload would be most appreciated.

Again use -L option with exact filenames.

Mandeep.
__________________________________________________________________
"I'm very brave generally," he went on in a low voice:
"only to-day I happen to have a headache."
                                      -- Lewis Carroll
__________________________________________________________________
Newsgroups: comp.windows.x