kdcmgr.sh revision 67c900400ffabaec1fd8a7ee6cea5e9beb39c3cb
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
# This command provides an simple interface to configure, destroy, and to obtain
# the status of a master or slave Kerberos KDC server.
#
function usage {
cleanup 1
}
function ask {
# ask question, set global answer
typeset question=$1 default_answer=$2
if [[ -z $default_answer ]]; then
print "$question \c"
else
print "$question [$default_answer]: \c"
fi
read answer
}
function yesno {
typeset question="$1"
# answer is a global set by ask
while [[ -z $answer ]]; do
*) answer=;;
esac
done
}
function query {
yesno "$*"
fi
}
function cleanup {
integer ret=$1
kdestroy -q -c $TMP_CCACHE 1>$TMP_FILE 2>&1
exit $ret
}
function error_message {
printf "---------------------------------------------------\n"
cleanup 1
}
function check_bin {
bin=$1
if [[ ! -x $bin ]]; then
fi
}
function check_ret {
integer ret=$1
prog=$2
fi
}
function ok_to_proceed {
yesno "$@"
cleanup 0
fi
}
function check_value {
typeset arg="$1"
if [[ -z $arg ]]; then
else
fi
fi
}
function setup_kdc_conf {
if [[ -r $KRB5_KDC_CONF ]]; then
fi
exec 3>$KRB5_KDC_CONF
if [[ $? -ne 0 ]]; then
fi
fi
fi
}
function setup_krb_conf {
if [[ -r $KRB5_KRB_CONF ]]; then
fi
exec 3>$KRB5_KRB_CONF
if [[ $? -ne 0 ]]; then
fi
fi
else
fi
}
function cannot_create {
typeset filename="$1"
typeset stat="$2"
fi
}
function check_admin {
message=$1
if [[ -z $ADMIN_PRINC ]]; then
read ADMIN_PRINC
fi
# Already in "/admin" format, do nothing
:
else
else
fi
fi
}
function ping_check {
typeset machine="$1"
:
else
fi
}
function check_host {
# do nothing, host is in fqhn format
:
else
printf "$(gettext "Expecting the following format: 'somehost.example.com' or 'somehost', exiting").\n"
else
# Attach fqdn to host, to get the Fully Qualified Domain
# Name of the host requested
fi
fi
#
# Ping to see if the host is alive!
#
}
function kill_daemons {
# Kill daemons so they won't go into maintenance mode
if [[ $? -ne 0 ]]; then
fi
if [[ $? -ne 0 ]]; then
fi
if [[ $? -ne 0 ]]; then
fi
# Make sure that none of the daemons outside of SMF are running either
if [[ $? -gt 1 ]]; then
fi
if [[ $? -gt 1 ]]; then
fi
if [[ $? -gt 1 ]]; then
fi
}
function setup_mkeytab {
if [[ -z $PWFILE ]]; then
echo
$KADMINL -q "ank $ADMIN_PRINC"
else
fi
# To support Horowitz change password protocol
}
function setup_skeytab {
if [[ -z $PWFILE ]]; then
else
cat $PWFILE | kinit -c $TMP_CCACHE -S kadmin/$master_hn \
$ADMIN_PRINC > /dev/null 2>&1
fi
klist -c $TMP_CCACHE 1>$TMP_FILE 2>&1
:
else
fi
kdestroy -q -c $TMP_CCACHE 1>$TMP_FILE 2>&1
}
function setup_kadm5acl {
if [[ -r $KADM5ACL ]]; then
fi
exec 3>$KADM5ACL
if [[ $? -ne 0 ]]; then
fi
else
fi
}
function setup_kpropdacl {
if [[ -r $KPROPACL ]]; then
fi
exec 3>$KPROPACL
if [[ $? -ne 0 ]]; then
fi
}
function setup_master {
# create principal DB (KDB)
if [[ -z $PWFILE ]]; then
echo
else
fi
}
function setup_slave {
integer count=1
# Clear the kadm5acl, since the start methods look at this file
# to see if the server has been configured as a master server
# Wait for full propagation of the database, in some environments
# this could take a few seconds
fi
done
# The database is propagated now we need to create the stash file
if [[ -z $PWFILE ]]; then
else
fi
}
function destroy_kdc {
# Check first to see if this is an existing KDC or server
if [[ -f $KRB5KT || -f $KADM5KT || -f $PRINCDB || -f $OLDPRINCDB ]]
then
if [[ -z $PWFILE ]]; then
echo "\t$KRB5KT\n\t$KADM5KT\n\t$PRINCDB\n\t$OLDPRINCDB\n\t$STASH\n"
if [[ -z $d_option ]]; then
printf "$(gettext "You must first run 'kdcmgr destroy' to remove all of these files before creating a KDC server").\n\n"
cleanup 1
else
fi
fi
else
if [[ -n $d_option ]]; then
cleanup 0
fi
return
fi
cleanup 0
}
function kadm5_acl_configed {
if [[ -s $KADM5ACL ]]; then
if [[ $? -gt 0 ]]; then
return 0
fi
fi
return 1
}
function status_kdc {
integer is_master=0
echo "--------------------------------------------"
if kadm5_acl_configed; then
echo "--------------------------------------------"
else
echo "--------------------------------------------"
fi
echo "--------------------------------------------"
echo "--------------------------------------------"
if [[ ! -s $file ]]; then
fi
done
if [[ $is_master -eq 0 && ! -s $KPROPACL ]]; then
fi
if [[ $is_master -eq 1 && ! -s $KADM5KT ]]; then
fi
test ! -s $STASH &&
echo
cleanup 0
}
# Start of Main script
# Defaults
LOOPCNT=10
else
TMP_FILE="/etc/krb5/krb5tmpfile.$$"
TMP_CCACHE="/etc/krb5/krb5tmpccache.$$"
fi
if [[ ! -f /etc/resolv.conf ]]; then
cleanup 1
fi
if [[ -n "$fqhn" ]]; then
:
elif [[ -n $(hostname) && -n $(domainname) ]]; then
else
cleanup 1
fi
do
a) ADMIN_PRINC=$OPTARG;;
h) usage;;
if [[ ! -r $PWFILE ]]; then
cleanup 1
fi
;;
*) usage;;
esac
done
case "$*" in
if [[ $4 != slave ]]; then
fi;&
status) status_kdc;;
*) usage;;
esac
printf "---------------------------------------------------\n"
# Checks for existing kdb and destroys if desired
if [[ -z $REALM ]]; then
read REALM
fi
fi
fi
fi
read host
fi
else
fi
printf "\n---------------------------------------------------\n"
cleanup 0