Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2024 12:50:51 GMT
From:      Cy Schubert <cy@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: abc4b3088941 - stable/14 - kdc: Add restart option
Message-ID:  <202404291250.43TCopWc001167@gitrepo.freebsd.org>

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

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

commit abc4b3088941d772728c28146d466010f816ea66
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2024-04-18 18:56:54 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2024-04-29 12:50:19 +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
    
    (cherry picked from commit 9e248b7f645cdf05615a49cc15295df49b54d659)
---
 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 f31efb4e2052..831ef202219c 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -329,6 +329,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?202404291250.43TCopWc001167>