#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
#  
#  
# Licensed Materials - Property of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 2003,2007 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
#----------------------------------------------------------------------
# Module Name:  ctcasd_start
# Component:    ctsec
# Description:  Script invoked by the System Resource Controller (SRC)
#               to start the "ctcas" service.  The service itself is embodied in
#               the executable file /usr/sbin/rsct/bin/ctcasd.  This script
#               is used to detect any unique operating environment
#               characteristics for the current platform and invoke the
#               "ctcasd" binary in the appropriate manner for that platform.
#----------------------------------------------------------------------
# @(#)90    1.9 src/rsct/security/CAS/bin/ctcasd_start.sh, ctsec, rsct_relgh, relghs001a 10/30/06 14:10:54

typeset CTCASD_DAEMON
typeset CTCASD_OPTIONS

CTCASD_DAEMON="/usr/sbin/rsct/bin/ctcasd"
CTCASD_OPTIONS=""

# ==========================================================================
# Native POSIX Thread Library (NPTL) Special Processing - we have discovered
# a problem with certain versions of the NPTL library in some of the Linux
# distros that will cause the ctcasd daemon problems.  To "work around" the
# NPTL problem until such a time as a repair becomes available, we will
# force a reversion to the "old" POSIX Thread library in certain distros.
# We revert to the old pthread library by setting LD_ASSUME_KERNEL for the
# ctcasd daemon process to:
#	Red Hat:
#		Red Hat Enterprise Linux 3 ONLY 	2.4.19
#	SuSE:
#		No levels
# ==========================================================================

typeset REDHAT_RELFILE
typeset REDHAT_DISTRO
typeset DISTROSTR
typeset PRODUCTSTR
typeset RELEASESTR

REDHAT_RELFILE="/etc/redhat-release"
REDHAT_DISTRO="Red Hat "

if [[ -f $REDHAT_RELFILE ]]
then
	integer RELEASENUM
	# ---------------------------------------- #
	# Checks specific to RedHat Linux products #
	# ---------------------------------------- #
	DISTROSTR=""
	DISTROSTR=$(grep "^$REDHAT_DISTRO" $REDHAT_RELFILE 2> /dev/null)
	if [[ -n $DISTROSTR ]]
	then
		# -------------------------------------------------- #
		# Determine "Enterprise" or not, plus version number #
		# (ignore release & modification level, if any)      #
		# -------------------------------------------------- #
		PRODUCTSTR=${DISTROSTR#*$REDHAT_DISTRO}
		PRODUCTSTR=${PRODUCTSTR%% *}
		RELEASESTR=${DISTROSTR##*[Rr]elease }
		RELEASESTR=${RELEASESTR%% *}
		RELEASESTR=${RELEASESTR%.*}
		RELEASENUM=$RELEASESTR
		# -------------------------------------------- #
		# RedHat Enterprise Linux versions 3 ONLY sets #
		# LD_ASSUME_KERNEL to 2.4.19                   #
		# -------------------------------------------- #
		if [[ $PRODUCTSTR = Enterprise ]]
		then
			if ((RELEASENUM == 3))
			then
				export LD_ASSUME_KERNEL=2.4.19
			fi
		fi
		# --------------------------------------------- #
		# Other RedHat Linux products and levels do not #
		# require LD_ASSUME_KERNEL to be set.           #
		# --------------------------------------------- #
	fi
fi
# ==========================================================================
# End special processing for NPTL
# ==========================================================================

# ==========================================================================
# Start the service with the correct options
# ==========================================================================
exec $CTCASD_DAEMON $CTCASD_OPTIONS

# NOTREACHED
