cvsdist 0bb98ee
#!/bin/bash
cvsdist af3b546
#
cvsdist af3b546
# krb5kdc      Start and stop the Kerberos 5 servers.
cvsdist af3b546
#
cvsdist af3b546
# chkconfig:   - 35 65
cvsdist af3b546
# description: Kerberos 5 is a trusted third-party authentication system.  \
724545e
#	       This script starts and stops the server that Kerberos 5 \
cvsdist af3b546
#	       clients need to connect to in order to obtain credentials.
cvsdist af3b546
# processname: krb5kdc
c22df5b
# config: /etc/sysconfig/krb5kdc
a0ca6e4
# pidfile: /var/run/krb5kdc.pid
cvsdist af3b546
#
cvsdist af3b546
724545e
### BEGIN INIT INFO
724545e
# Provides: krb5kdc
724545e
# Required-Start: $local_fs $network
724545e
# Required-Stop: $local_fs $network
2baf72c
# Should-Start: portreserve
41d635c
# Default-Start:
724545e
# Default-Stop: 0 1 2 3 4 5 6
724545e
# Short-Description: start and stop the Kerberos 5 KDC
724545e
# Description: The krb5kdc is the Kerberos 5 key distribution center, which \
724545e
#              issues credentials to Kerberos 5 clients.
724545e
### END INIT INFO
724545e
cvsdist af3b546
# Get config.
cvsdist af3b546
. /etc/sysconfig/network
cvsdist af3b546
708fedd
# Get config.
708fedd
[ -r /etc/sysconfig/krb5kdc ] && . /etc/sysconfig/krb5kdc
708fedd
cvsdist af3b546
# Source function library.
cvsdist af3b546
. /etc/rc.d/init.d/functions
cvsdist af3b546
cvsdist af3b546
RETVAL=0
cvsdist 21f3145
prog="Kerberos 5 KDC"
75b0804
krb5kdc=/usr/sbin/krb5kdc
a0ca6e4
pidfile=/var/run/krb5kdc.pid
08f510b
PATH=/usr/lib64/krb5:/usr/lib/krb5:"$PATH"
cvsdist af3b546
f072055
# Shell functions to cut down on useless shell instances.
cvsdist af3b546
start() {
f072055
	[ -x $krb5kdc ] || exit 5
08f510b
	# check that some of the basic principal names don't only have weak
08f510b
	# keys available. if they do, warn that they should be changed to
08f510b
	# get some keys for stronger ciphers added
08f510b
	if ! is_false "$KRB5CHECKWEAK" ; then
08f510b
		localhost=`hostname`
08f510b
		for principal in `kdb_check_weak -p "krbtgt/${KRB5REALM:+${KRB5REALM}@${KRB5REALM}}" "kadmin/admin${KRB5REALM:+@${KRB5REALM}}" "kadmin/changepw${KRB5REALM:+@${KRB5REALM}}" "kadmin/$localhost${KRB5REALM:+@${KRB5REALM}}"` ; do
08f510b
			echo -n "Keys for $principal should be changed to include keys for non-weak ciphers." ; warning ; echo ""
08f510b
		done
08f510b
	fi
cvsdist 21f3145
	echo -n $"Starting $prog: "
2baf72c
	# tell portreserve to release the kerberos-iv port
2baf72c
	[ -x /sbin/portrelease ] && /sbin/portrelease kerberos-iv &>/dev/null || :
a0ca6e4
	daemon ${krb5kdc} ${KRB5REALM:+-r ${KRB5REALM}} -P $pidfile $KRB5KDC_ARGS
cvsdist af3b546
	RETVAL=$?
cvsdist af3b546
	echo
060205d
	if test $RETVAL -ne 0 ; then
060205d
	    if status ${krb5kdc} > /dev/null ; then
060205d
		RETVAL=0
060205d
	    fi
060205d
	fi
cvsdist af3b546
	[ $RETVAL = 0 ] && touch /var/lock/subsys/krb5kdc
cvsdist af3b546
}
cvsdist af3b546
stop() {
cvsdist 21f3145
	echo -n $"Stopping $prog: "
cvsdist 21f3145
	killproc ${krb5kdc}
cvsdist af3b546
	RETVAL=$?
cvsdist af3b546
	echo
cvsdist af3b546
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/krb5kdc
cvsdist af3b546
}
cvsdist 21f3145
reload() {
cvsdist 21f3145
	echo -n $"Reopening $prog log file: "
cvsdist 21f3145
	killproc ${krb5kdc} -HUP
cvsdist 21f3145
        RETVAL=$?
cvsdist 21f3145
	echo
cvsdist 21f3145
}
cvsdist af3b546
cvsdist af3b546
# See how we were called.
cvsdist af3b546
case "$1" in
cvsdist af3b546
  start)
cvsdist af3b546
	start
cvsdist af3b546
	;;
cvsdist af3b546
  stop)
cvsdist af3b546
	stop
cvsdist af3b546
	;;
cvsdist af3b546
  restart)
cvsdist af3b546
	stop
cvsdist af3b546
	start
cvsdist af3b546
	;;
cvsdist 21f3145
  reload)
cvsdist 21f3145
        reload
cvsdist 21f3145
        ;;
cvsdist af3b546
  status)
cvsdist 21f3145
	status ${krb5kdc}
cvsdist 21f3145
        RETVAL=$?
cvsdist af3b546
	;;
cvsdist af3b546
  condrestart)
cvsdist af3b546
	if [ -f /var/lock/subsys/krb5kdc ] ; then
cvsdist af3b546
		stop
cvsdist af3b546
		start
cvsdist af3b546
	fi
cvsdist af3b546
	;;
cvsdist af3b546
  *)
cvsdist 21f3145
	echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
f072055
	RETVAL=2
cvsdist af3b546
	;;
cvsdist af3b546
esac
cvsdist af3b546
cvsdist af3b546
exit $RETVAL