From nobody Sat Sep 2 06:25:35 2023 X-Original-To: current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rd4f413Czz4s0xD; Sat, 2 Sep 2023 06:25:48 +0000 (UTC) (envelope-from kiri@truefc.org) Received: from kx.truefc.org (1.212.52.36.ap.yournet.ne.jp [36.52.212.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp", Issuer "smtp" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rd4f14kzyz4fBj; Sat, 2 Sep 2023 06:25:45 +0000 (UTC) (envelope-from kiri@truefc.org) Authentication-Results: mx1.freebsd.org; dkim=none; spf=pass (mx1.freebsd.org: domain of kiri@truefc.org designates 36.52.212.1 as permitted sender) smtp.mailfrom=kiri@truefc.org; dmarc=none Received: from kx.truefc.org (kx.truefc.org [36.52.212.1]) by kx.truefc.org (8.17.1/8.17.1) with ESMTP id 3826PaNR066435; Sat, 2 Sep 2023 15:25:36 +0900 (JST) (envelope-from kiri@kx.truefc.org) Message-Id: <202309020625.3826PaNR066435@kx.truefc.org> Date: Sat, 02 Sep 2023 15:25:35 +0900 From: KIRIYAMA Kazuhiko To: current@freebsd.org Cc: freebsd-rc@freebsd.org Subject: Re: Announce /etc/rc.d/sendmail does not work in default should be made at use time. In-Reply-To: References: <202308210638.37L6c9PJ074335@kx.truefc.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 MULE XEmacs/21.4 (patch 24) (Standard C) (amd64--freebsd) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Spamd-Bar: - X-Spamd-Result: default: False [-1.30 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; NEURAL_HAM_LONG(-0.99)[-0.995]; NEURAL_SPAM_SHORT(0.80)[0.795]; R_SPF_ALLOW(-0.20)[+ip4:36.52.212.0/29]; MIME_GOOD(-0.10)[text/plain]; RCVD_NO_TLS_LAST(0.10)[]; ONCE_RECEIVED(0.10)[]; TO_DN_NONE(0.00)[]; FREEFALL_USER(0.00)[kiri]; RCVD_COUNT_ONE(0.00)[1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MLMMJ_DEST(0.00)[freebsd-rc@freebsd.org,current@freebsd.org]; BLOCKLISTDE_FAIL(0.00)[36.52.212.1:server fail]; DMARC_NA(0.00)[truefc.org]; RCPT_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; ASN(0.00)[asn:10013, ipnet:36.52.208.0/21, country:JP]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 4Rd4f14kzyz4fBj Hi, lists On Mon, 21 Aug 2023 20:25:22 +0900, Christoph Moench-Tegeder wrote: > > ## KIRIYAMA Kazuhiko (kiri@truefc.org): > > > But there are nothing pointers to be changed default MTA > > changed to dma from sendmail ;-( > > There is: UPDATING 20221205. To aware default MTA is dma, I added required_vars_defin_files variable used by check_required_before function in /etc/rc.subr. For example in this sendmail case, required_vars_defin_files defines in /etc/rc.d/sendmail like this: required_vars_defin_files="sendmail:/usr/libexec/sendmail/sendmail /etc/mail/mailer.conf" This means "If sendmail -> /usr/libexec/sendmail/sendmail does not define in /etc/mail/mailer.conf, warn this". diff --git a/libexec/rc/rc.d/sendmail b/libexec/rc/rc.d/sendmail index 68803a957952..f14da832d8f2 100755 --- a/libexec/rc/rc.d/sendmail +++ b/libexec/rc/rc.d/sendmail @@ -17,6 +17,7 @@ name="sendmail" desc="Electronic mail transport agent" rcvar="sendmail_enable" required_files="/etc/mail/${name}.cf" +required_vars_defin_files="${name}:/usr/libexec/${name}/${name} /etc/mail/mailer.conf" start_precmd="sendmail_precmd" load_rc_config $name diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index 17ca904ff1e7..1816df26ef67 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -2140,7 +2140,7 @@ find_system_scripts() { # check_required_before() { - local _f + local _f _vars case "$1" in start) @@ -2170,6 +2170,60 @@ check_required_before() fi fi done + + IFS=$'\n' + for _f in $required_vars_defin_files; do + _vars=${_f% *} + _f=${_f##* } + if [ ! -f "${_f}" ]; then + warn "${_f} is not found." + return 1 + fi + _vars=$(awk -v vars="$_vars" -v file=$_f ' + BEGIN { + n = split(vars, v, /[[:space:]]+/) + for (i = 1; i <= n; i++) { + split(v[i], w, /:/) + var[w[1]] = w[2] + } + s = "" + found = 0 + } + { + for (i in var) { + if (match($0, "^" i "[[:space:]]+")) { + t = substr($0, RSTART + RLENGTH) + if (var[i] == t) { + delete var[i] + n-- + break + } + } + } + if (n <= 0) { + found = 1 + exit + } + } + END { + if (! found) { + for (i in var) { s = s ? s " " i "->" var[i] : i "->" var[i] } + if (n == 1) { + print "\"" s "\" is" + } else { + print "\"" s "\" are" + } + } + exit ! found + }' $_f) + if [ $? -ne 0 ]; then + warn "${_vars} not defined in ${_f}." + if [ -z "$rc_force" ]; then + return 1 + fi + fi + done + unset IFS ;; esac Regards --- Kazuhiko Kiriyama