#! /usr/pkg/bin/ksh93
# ##########################################################################
#
#   Xreset
#
#   Common Desktop Environment (CDE)
#
#   Configuration file for the Login Manager
#
#   (c) Copyright 1993, 1994 Hewlett-Packard Company
#   (c) Copyright 1993, 1994 International Business Machines Corp.
#   (c) Copyright 1993, 1994 Sun Microsystems, Inc.
#   (c) Copyright 1993, 1994 Novell, Inc.
#
#       ************** DO NOT EDIT THIS FILE **************
#
#   /usr/pkg/dt/config/Xreset is a factory-default file and will
#   be unconditionally overwritten upon subsequent installation.
#   Before making changes to the file, copy it to the configuration 
#   directory, /usr/pkg/usr/pkg/etc/dt/config. You must also update the reset
#   resource in /usr/pkg/usr/pkg/etc/dt/config/Xconfig.
#
#   $XConsortium: Xreset.src /main/6 1996/08/15 16:51:53 rswiston $
#
#
#   This file is symmetrical with Xstartup. This script is run after the user
#   session is terminated. Run as root, it should probably contain commands 
#   that undo the effects of commands in Xstartup, such as unmounting directories
#   from file servers. The collection of environment variables that were passed
#   to Xstartup are also passed to Xreset.
#
# ##########################################################################
#
# This script is run as root after the session terminates but
# before the display is closed...
#
#
#  Update action types for any printers created during the session  
#
if [ -x /usr/pkg/dt/bin/dtprintinfo ]
then
   /usr/pkg/dt/bin/dtprintinfo -populate
fi
#
#  Reset console ownership if local session
#
if [ "$DTXSERVERLOCATION" = "local" ]
then
  if [[ ! -z "$ITE" && "$ITE" != "??" && -a "/dev/$ITE" ]]
  then
        chown root /dev/$ITE
        chgrp $ROOT_GID  /dev/$ITE
  fi
fi
#
# If Xsession did not exit gracefully for this user, the dtdbcache
# file will still be left around.  Remove it if this user owns it.
#
# dtdbcache file's directory should match
# _DTDTSMMTEMPDIR in DtSvc/DtUtil1/DtsMM.h
DTDBFILE=/tmp/dtdbcache_$DISPLAY
if [ -f $DTDBFILE ]
then
  DTDBFILEOWNER=`/bin/ls -l $DTDBFILE | /bin/awk '{print $3}'`
  if [ $USER = $DTDBFILEOWNER ]
  then
    /bin/rm -f $DTDBFILE
  fi
fi
wtmp_flag=-w\ /var/log/wtmp
utmp_flag=-u\ /var/run/utmp
sessreg -d $wtmp_flag $utmp_flag -l $DISPLAY $USER
