Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Apr 2024 05:55:02 GMT
From:      Cy Schubert <cy@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 9e248b7f645c - main - kdc: Add restart option
Message-ID:  <202404240555.43O5t2BC008641@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by cy:

URL: https://cgit.FreeBSD.org/src/commit/?id=9e248b7f645cdf05615a49cc15295df49b54d659

commit 9e248b7f645cdf05615a49cc15295df49b54d659
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2024-04-18 18:56:54 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2024-04-24 05:50:38 +0000

    kdc: Add restart option
    
    Add a new kdc_restart rc variable that manages kdc (or krb5kdc) under
    daemon(8). This automatically restarts the kdc should it fail, i.e.
    when it's configured to use LDAP as a backend and cannot connect to its
    LDAP directory.
    
    Set kdc_restart="YES" to auto restart kdc on abnormal termination.
    
    Set kdc_restart_delay="N" to the number of seconds to delay before
    restarting the kdc. The daemon(8) default seconds applies when not set.
    
    Reported by:            Lexi Winter <lexi.freebsd@le-fay.org>
    PR:                     278395
    Differential Revision:  https://reviews.freebsd.org/D44898
---
 libexec/rc/rc.conf  |  2 ++
 libexec/rc/rc.d/kdc | 29 +++++++++++++++++++++++++++--
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
index 6a8b6e257b17..c91f13bd9812 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -330,6 +330,8 @@ resolv_enable="YES"		# Enable resolv / resolvconf
 kdc_enable="NO"			# Run a kerberos 5 KDC (or NO).
 kdc_program="/usr/libexec/kdc"	# path to kerberos 5 KDC
 kdc_flags=""			# Additional flags to the kerberos 5 KDC
+kdc_restart="NO"		# Auto restart kdc on abnormal termination
+kdc_restart_delay=""		# Auto restart delay seconds
 kadmind_enable="NO"		# Run kadmind (or NO)
 kadmind_program="/usr/libexec/kadmind"	# path to kadmind
 kpasswdd_enable="NO"		# Run kpasswdd (or NO)
diff --git a/libexec/rc/rc.d/kdc b/libexec/rc/rc.d/kdc
index c3059f261e09..a2d9f87f8e20 100755
--- a/libexec/rc/rc.d/kdc
+++ b/libexec/rc/rc.d/kdc
@@ -12,15 +12,40 @@
 name=kdc
 desc="Kerberos 5 server"
 rcvar=${name}_enable
+: ${kdc_restart:="NO"}
+: ${kdc_restart_delay:=""}
 
 set_rcvar_obsolete kerberos5_server_enable kdc_enable
 set_rcvar_obsolete kerberos5_server kdc_program
 set_rcvar_obsolete kerberos5_server_flags kdc_flags
 
-
 load_rc_config $name
 if [ "${kdc_program}" = /usr/libexec/kdc -o \
      "${kdc_program}" = /usr/local/libexec/kdc ]; then
-	command_args="$command_args --detach"
+	detach="--detach"
+	flavor=heimdal
+else
+	flavor=mit
+	unset detach
 fi
+
+case ${kdc_restart} in
+[Yy][Ee][Ss])
+	if [ "$flavor" = mit ]; then
+		detach=-n
+	else
+		unset detach
+	fi
+	case ${kdc_restart_delay} in
+	"")	unset daemon_restart_delay;;
+	*)	daemon_restart_delay="-R ${kdc_restart_delay}";;
+	esac
+	command_args="-r ${daemon_restart_delay} ${kdc_program} ${detach} ${command_args}"
+	kdc_program=/usr/sbin/daemon
+	;;
+*)
+	command_args="${detach} ${command_args}"
+	;;
+esac
+
 run_rc_command "$1"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404240555.43O5t2BC008641>