#!/bin/sh # # Xstartup: Do log on of the local or remote user by writing # utmp/wtmp/lastlog entries for the X session. # # Copyright (c) 1998-2000 SuSE GmbH Nuernberg, Germany. # please report bugfixes or comments at http://www.suse.de/feedback. # # Author: Werner Fink, # # Xstartup runs as root after the user logs in but before Xsession. LIBDIR=/usr/lib/X11 ETCDIR=/etc/X11 XDMDIR=${ETCDIR}/xdm # jimc/CouchNet and UCLA-Mathnet hack: can use same file on v10.3 and v10.1 for f in /usr/bin /usr/bin/X11 /usr/X11R*/bin ; do if [ -x $f/xmessage ] ; then BINDIR=$f break fi done xmessage=${BINDIR}/xmessage NOLOGIN=/etc/nologin halporp=/usr/bin/hal-find-by-property xvkbd=${BINDIR}/xvkbd no_exit_on_failed_exec=1 type shopt &> /dev/null && shopt -s execfail set +e &> /dev/null # # Check if the machine is a TabletPC and kill xvkbd # to avoid multiple start on user desktop # $halporp --key system.formfactor.subtype --string tabletpc if test $? -eq 0 -a -x $xvkbd ; then # Bug 238604 if grep -q DISPLAYMANAGER_AUTOLOGIN="" /etc/sysconfig/displaymanager; then /sbin/killproc -p /var/run/xvkbd.pid -TERM $xvkbd fi fi # # The real user id # RUID=`id -ur $USER` # # If login is disabled, give an appropriate message # and exit if normal user knock on. # if test -r $NOLOGIN ; then $xmessage -file $NOLOGIN -timeout 10 -default okay -center test "$RUID" != "0" && exit 1 fi # # Find out if this is a local or remote connection # LOCATION=${DISPLAY%:*} LINE=:${DISPLAY#*:} if test -z "$LOCATION" ; then # local connection case "$LINE" in :0|:0.0) LOCATION=console ;; *) LOCATION=localhost ;; esac else # TCP/IP connection (remote or local) NAME=${LOCATION%%.*} if test -z "${NAME%%*[0-9]}" ; then LINE=${LINE}/${LOCATION} else LINE=${LINE}/${NAME} fi fi # # Do not allow foreign root login if set in /etc/sysconfig/displaymanager # while test "$RUID" = "0" ; do test "$LOCATION" = "console" && break test "$LOCATION" = "localhost" && break test "$LOCATION" = "`hostname -f`" && break test -s /etc/sysconfig/displaymanager && . /etc/sysconfig/displaymanager test "$DISPLAYMANAGER_ROOT_LOGIN_REMOTE" = "yes" && break $xmessage -timeout 10 -default okay -center "No foreign root login allowed" exit 1 done # # Make devices ready for the user. # case "$DISPLAY" in :[0-5]|:[0-5].0) # Only for local displays we have to set up the owner ship # and permissions of the /dev/xconsole FIFO and the current # virtual console. # jimc-CouchNet hacks: # Create lock file which tells xhalt to wait before halting the machine kdmpid=/var/run/kdm.pid if [ ! -r $kdmpid ] ; then kdmpid=/dev/null ; fi echo "xdm has logged in user '$USER', pid = " `cat $kdmpid` \ > /tmp/.X11-unix/startx.lock ${XDMDIR}/GiveDevices ;; *) esac if test -x /sbin/preload && test -s /var/run/preload-session.pid; then /sbin/killproc -p /var/run/preload-session.pid /sbin/preload fi # UCLA-Mathnet hack: pre-create /tmp/.ICE-unix as root. ICE=/tmp/.ICE-unix if [ ! -d $ICE ] ; then mkdir $ICE chmod 1777 $ICE fi # CouchNet hack: kill boot box. for f in /var/run/Bootbox.pid /tmp/.X11-unix/xconsole-0.pid ; do if [ -s $f ] ; then kill `cat $f` rm -f $f fi done # # Write utmp, wtmp, and lastlog entries. Note that the `exec' is required # to hold an exisiting pid in utmp during xsession. # exec ${BINDIR}/sessreg -l $LINE -h $LOCATION -a $USER $xmessage -timeout 10 -default okay -center "$0: sessreg failed." exit 1