From 403e010c5203a9ae418f4ed9636e4e56c6fafc02 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Wed, 4 Jun 2025 21:26:10 +0100 Subject: make program paths configurable --- acme.conf.5.in | 7 +++++++ dns.sh.in | 4 ++-- dnsutils.sh.in | 7 +++++-- init.sh.in | 43 ++++++++++++++++++++++++++++++++++++++++--- kerberos.sh.in | 13 ++++++++++--- lfacme-dns.7.in | 14 ++++++++++++++ lfacme-kerberos.7.in | 21 +++++++++++++++++++++ lfacme-ualpn.7.in | 14 ++++++++++++++ ualpn.sh.in | 6 ++++-- 9 files changed, 117 insertions(+), 12 deletions(-) diff --git a/acme.conf.5.in b/acme.conf.5.in index d968c74..a13f6ff 100644 --- a/acme.conf.5.in +++ b/acme.conf.5.in @@ -39,6 +39,13 @@ The path to a directory containing hooks to invoke when issuing certificates .Xr domains.conf 5 ) . The default path is .Pa __CONFDIR__/hooks . +.It Va ACME_UACME +Path to the +.Xr uacme 1 +program. +If not specified, +.Ev $PATH +will be searched. .El .Pp Additional configuration variables may be used by the ACME validation hooks; diff --git a/dns.sh.in b/dns.sh.in index 67fb280..e651cec 100644 --- a/dns.sh.in +++ b/dns.sh.in @@ -32,7 +32,7 @@ _add_record() { local domain="$1" local auth="$2" - nsupdate -k "$ACME_DNS_KEYFILE" <&2 '%s: FATAL: %s\n' "$_PROGNAME" "$_msg" - exit 1 + kill $$ } _error() { @@ -80,16 +82,51 @@ fi if [ ! -d "$ACME_DATADIR" ]; then _info "creating directory %s" "$ACME_DATADIR" mkdir -p "$ACME_DATADIR" + if [ "$?" -ne 0 ]; then + exit 1 + fi fi # The domains.conf file. _DOMAINS="${_CONFDIR}/domains.conf" +# Find a program based on $PATH, or return the second argument if specified. +# If the program isn't found, print an error and exit. +_findbin() { + local cmd="$1" + local force="$2" + + if ! [ -z "$force" ]; then + if ! [ -x "$force" ]; then + _fatal "not found or not executable: %s" "$force" + fi + + echo $force + return 0 + fi + + local oIFS="$IFS" + local IFS=: + for dir in $PATH; do + local _bin="${dir}/${cmd}" + + if ! [ -x "$_bin" ]; then + continue + fi + + echo $_bin + return 0 + done + IFS="$oIFS" + + _fatal "required command '%s' not found" "$cmd" +} + # uacme's base directory; this is where it puts certificates. _UACME_DIR="${ACME_DATADIR}/certs" # The uacme executable. -_UACME=uacme +_UACME="$(_findbin uacme $ACME_UACME)" _LFACME_UACME_FLAGS="" if ! [ -z "$LFACME_VERBOSE" ]; then diff --git a/kerberos.sh.in b/kerberos.sh.in index 41d99c2..e29f9c3 100644 --- a/kerberos.sh.in +++ b/kerberos.sh.in @@ -15,6 +15,8 @@ TOKEN=$4 # The token value we need to create. AUTH=$5 +_KINIT="$(_findbin kinit $ACME_KERBEROS_KINIT)" + if [ "$#" -ne 5 ]; then _fatal "missing arguments" fi @@ -31,7 +33,12 @@ if [ -z "$ACME_KERBEROS_KEYTAB" ]; then ACME_KERBEROS_KEYTAB="/etc/krb5.keytab" fi -if ! kinit -k -t "$ACME_KERBEROS_KEYTAB" "$ACME_KERBEROS_PRINCIPAL"; then +if ! [ -r "$ACME_KERBEROS_KEYTAB" ]; then + _fatal "keytab does not exist (or is not readable): %s" \ + "$ACME_KERBEROS_KEYTAB" +fi + +if ! $_KINIT -k -t "$ACME_KERBEROS_KEYTAB" "$ACME_KERBEROS_PRINCIPAL"; then _fatal "failed to obtain a Kerberos ticket" fi @@ -40,7 +47,7 @@ _add_record() { local domain="$1" local auth="$2" - nsupdate -g <