Xorg 6.8.1: can't switch VT or resolution (partially solved)

Corey Hickey bugfood-ml at fatooh.org
Sat Oct 16 20:33:31 PDT 2004


Glynn Clements wrote:

>>>I should ask, also, if there are any alternatives to using
>>>LD_LIBRARY_PATH for what I want to do. Basically, I just want xorg to
>>>not interfere with my current installation of xfree86, and vice versa. I
>>>want xorg, and any programs I run within xorg, to look for libraries in
>>>/usr/local/X11R6.8/lib first. Xfree86 and programs that run within
>>>xfree86 should only look for libs in the usual places.
>
> 
> Essentially, you have to re-set the LD_* variables after running any
> setuid program (unless you run it under the UID to which it's setuid;
> i.e. running a setuid-root program as root won't clear LD_*).
> 
> If you're using xdm, you can re-set LD_LIBRARY_PATH in the Xsession
> script. That will handle any non-setuid programs which are part of the
> session. If xterm is setuid, LD_* will be cleared for the shell which
> it spawns. You can either re-set it in your shell's startup script, or
> you may be able to make make xterm non-setuid.
> 
> There are two reasons for making xterm setuid root:
> 
> 1. To allow it to set the ownership of the pty.
> 2. To allow it to write utmp/wtmp entries.
> 
> On systems with Unix98 ptys and /dev/pts, #1 no longer applies, as the
> kernel sets the ownership when it creates the pty device. Also, some
> systems with BSD-style ptys provide a setuid-root helper program to
> set pty ownership (on GNU libc 2.x, it's /usr/libexec/pt_chown).
> 
> As for point #2, xterm can use the utempter library (which available
> on most Linux systems), which calls a setgid-utmp program (e.g. 
> /usr/sbin/utempter) to create the utmp/wtmp entries. Even if you don't
> have utempter, if you don't care about utmp/wtmp logging, you can just
> remove the setuid bit from xterm.
> 

Thanks for your help. I've been messing around, have managed to make
some progress, and learned a few things, but I'm still confused about
what's going on in some cases. My original goal was simply to get xkb
working properly, and I've managed to do that with the following hack:

First, my xorg startup script:
-----------begin----------
#!/bin/bash

# there doesn't seem to be any reason to export LD_LIBRARY_PATH,
# because ld.so strips it anyway
#export LD_LIBRARY_PATH=/usr/local/X11R6.8/lib
export PATH=/usr/local/X11R6.8/bin:$PATH

# create xinitrc
cat > /tmp/xinitrc.8 << EOF
# export here for programs in xinitrc
export LD_LIBRARY_PATH=/usr/local/X11R6.8/lib
setxkbmap -print | xkbcomp - :1.0
# ~/.bashrc checks for this to see if I'm running xorg
export XORG=1
rxvt # or a window manager, etc.
EOF

xinit /tmp/xinitrc.8 -- /usr/local/X11R6.8/bin/X :1 vt8 \
-layout default -dpi 100
------------end-----------


Now, ~/.bashrc:
-----------begin-----------
# set LD_LIBRARY_PATH in case the terminal strips it
if [ "$XORG" = 1 ] ; then
  export LD_LIBRARY_PATH=/usr/local/X11R6.8/lib
fi
#----------end--------------


So, it's a bit strange but I have xkb and vt switching working now. I
still have a couple questions, though

=========first question=========
I tried using
setxkbmap -layout us -model microsoft -rules xorg

...before I ended up using
setxkbmap -print | xkbcomp - :1.0

...but I can't make that work in xorg. If I run it straight from a
terminal emulator, it reports:
Error loading new keyboard description

...and the vt from which I started xorg says:
/usr/local/X11R6.8/lib/X11/xkb/xkbcomp: error while loading shared
libraries: libxkbfile.so.1: cannot open shared object file: No such file
or directory

I gather that setxkbmap uses xkbcomp, and that LD_LIBRARY_PATH is lost
before xkbcomp is called. If I run xkbcomp directly from xinitrc (with
LD_LIBRARY_PATH set) it doesn't have a problem. Nor is there a problem
when I run it directly from a terminal emulator.

Why does this happen? Neither setxkbmap nor xkbcomp are setuid/setgid.
Is this something particular to setxkbmap or will I run into problems
with other programs doing the same thing?

In case it helps, I've attached the output in xorg of:
strace setxkbmap -layout us -model microsoft -rules xorg

and the output in xfree86 (where it works) of:
strace setxkbmap -layout us -model microsoft -rules xfree86

==========second question==========
I had some trouble earlier because I was using:
setxkbmap -print | xkbcomp - $DISPLAY

...in my xinitrc. It actually seems that $DISPLAY is not set until
later; I suppose this is xinit's fault, but does anyone know exactly
when $DISPLAY is set? I'm just curious.



Thanks Kristian and Glynn, you've been a big help to me. I really
appreciate it. :)

-Corey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xfree86.trace.gz
Type: application/gzip
Size: 1998 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20041016/5dcd79e7/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xorg.trace.gz
Type: application/gzip
Size: 1885 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20041016/5dcd79e7/attachment-0001.bin>


More information about the xorg mailing list