Edit

IABSD.fr/src/etc/rc.d/unbound

Branch :

  • Show log

    Commit

  • Author : kn
    Date : 2025-12-06 11:04:45
    Hash : 666b00fa
    Message : hoist OPTIND reset from rc.d(8) services to rc.subr(8) See unbound r1.10 and r.11 for context; in base only unbound and spamlogd use getopts and the problem is in rc.subr's getopts, parsing options when the service script is used directly: /etc/rc.d/unbound [-dqf] ... Reset getopts in rc.subr once for anything that comes afterwards instead of in every script using it. 'rcctl [-dqf] ...' and netstart are not affected as they run rc.subr in its own process and use FUNCS_ONLY=1, respectively. tested by obsd@mulh.net OK aja

  • etc/rc.d/unbound
  • #!/bin/ksh
    #
    # $OpenBSD: unbound,v 1.12 2025/12/06 11:04:45 kn Exp $
    
    daemon="/usr/sbin/unbound"
    daemon_flags="-c /var/unbound/etc/unbound.conf"
    
    . /etc/rc.d/rc.subr
    
    rc_pre() {
    	local _anchor _config _opt
    
    	while getopts :c: _opt $daemon_flags; do
    		[[ $_opt == c ]] && _config=$OPTARG
    	done
    
    	_anchor=$($daemon-checkconf -o auto-trust-anchor-file $_config)
    
    	if [[ -n $_anchor && ! -f $_anchor ]]; then
    		$daemon-anchor -v -a $_anchor
    	fi
    
    	$daemon-checkconf $_config
    }
    
    rc_cmd $1