#!/bin/sh
#
# /etc/kde2/kdm/Xstartup
#
# This script is run as root after the user logs in.
# If this script exits with a return code other than 0, the user's
# session will not be started.

PATH=$PATH:/usr/bin/X11

if grep -qs ^ignore-nologin /etc/kde2/kdm/kdm.options; then
  if [ -f /etc/nologin ]; then
    xmessage -file /etc/nologin -geometry 640x480
  fi
elif [ -f /etc/nologin ]; then
  # root can log in anyway
  if [ "$(id -u)" != "0" ]; then
    xmessage -file /etc/nologin -geometry 640x480
    exit 1
  fi
fi

# insert a utmp entry for the session
if grep -qs ^use-sessreg /etc/kde2/kdm/kdm.options && command -v sessreg > /dev/null 2>&1; then
  exec sessreg -a -l $DISPLAY -u /var/run/utmp -x /etc/kde2/kdm/Xservers $USER
  # NOTREACHED
fi

exit 0
