NetBSD Problem Report #50838

From ef@math.uni-bonn.de  Mon Feb 22 17:42:46 2016
Return-Path: <ef@math.uni-bonn.de>
Received: from mail.netbsd.org (mail.NetBSD.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 3625F7A213
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 22 Feb 2016 17:42:46 +0000 (UTC)
Message-Id: <20160222174242.B94231BD42@trave.math.uni-bonn.de>
Date: Mon, 22 Feb 2016 18:42:42 +0100 (CET)
From: ef@math.uni-bonn.de
Reply-To: ef@math.uni-bonn.de
To: gnats-bugs@gnats.NetBSD.org
Subject: etcupdate's NEED_xxx logic broken
X-Send-Pr-Version: 3.95

>Number:         50838
>Category:       install
>Synopsis:       etcupdate's NEED_xxx logic broken
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kre
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 22 17:45:00 +0000 2016
>Last-Modified:  Tue Jun 18 23:33:38 +0000 2019
>Originator:     Edgar Fuß <ef@math.uni-bonn.de>
>Release:        NetBSD 6.1_STABLE
>Organization:
Mathematisches Institut der Universität Bonn
>Environment:


System: NetBSD trave.math.uni-bonn.de 6.1_STABLE NetBSD 6.1_STABLE (MI-Server) #5: Mon Feb 15 12:26:39 CET 2016 support@trave.math.uni-bonn.de:/usr/obj/sys/arch/amd64/compile/miserv amd64
Architecture: x86_64
Machine: amd64
>Description:
	The NEED_xxx feature of etcupdate (that i.e. asks you to run passwd_mkdb in case a new version of master.passwd is installed) is broken. 
	The problem is that diff_and_merge_files() and thus install_file() (which sets the NEED_xxx variables to "true") is run after a pipe and thus in a subshell. So the "true" values never make it to the end of the script where their values are used. 
	The easiest way to fix it appears to create some special (.etcupdate._NEED_xxx) files in $TEMPROOT. Means that the removal of $TEMPROOT has to be moved after the NEED_xxx checks. 
>How-To-Repeat:
	Run etcupdate when master.passwd has changed
>Fix:
	--- etcupdate	2016-02-18 18:18:49.000000000 +0100
	+++ etcupdate-x	2016-02-19 16:03:49.000000000 +0100
	@@ -76,13 +76,6 @@
	 OVERWRITE_FILES=" "	# files to overwrite (Install)
	 MERGE_FILES=" "		# files to merge

	-# Settings for post-installation procedures
	-NEED_MAKEDEV=false
	-NEED_MTREE=false
	-NEED_NEWALIASES=false
	-NEED_PWD_MKDB=false
	-NEED_SERVICES_MKDB=false
	-

	 usage() {
		cat << EOF >&2
	@@ -168,7 +161,7 @@
		if ${AUTO_MISSING} || yesno "Create ${1}"; then
			verbose "Creating ${1}"
			mkdir -p "${1}" || exit 1
	-		NEED_MTREE=true
	+		touch "${TEMPROOT}"/.etcupdate.NEED_MTREE
		fi
	 }

	@@ -182,19 +175,19 @@
		# Check if this was a special file
		case "${1}" in
		/dev/MAKEDEV)
	-		NEED_MAKEDEV=true
	+		touch "${TEMPROOT}"/.etcupdate.NEED_MAKEDEV
			;;
		/dev/MAKEDEV.local)
	-		NEED_MAKEDEV=true
	+		touch "${TEMPROOT}"/.etcupdate.NEED_MAKEDEV
			;;
		/etc/mail/aliases)
	-		NEED_NEWALIASES=true
	+		touch "${TEMPROOT}"/.etcupdate.NEED_NEWALIASES
			;;
		/etc/master.passwd)
	-		NEED_PWD_MKDB=true
	+		touch "${TEMPROOT}"/.etcupdate.NEED_PWD_MKDB
			;;
		/etc/services)
	-		NEED_SERVICES_MKDB=true
	+		touch "${TEMPROOT}"/.etcupdate.NEED_SERVICES_MKDB
			;;
		esac
	 }
	@@ -744,12 +737,6 @@
		echo "${REMAINING}" | sed -e 's/^/  /'
		echo ""
	 fi
	-if yesno "Remove ${TEMPROOT}"; then
	-	echo "*** Removing ${TEMPROOT}"
	-	rm -rf "${TEMPROOT}"
	-else
	-	echo "*** Keeping ${TEMPROOT}"
	-fi

	 # Clean up after "make distribution"
	 if ${SOURCEMODE}; then
	@@ -764,7 +751,8 @@
	 fi

	 # Do some post-installation tasks
	-if ${NEED_PWD_MKDB}; then
	+if test -f "${TEMPROOT}"/.etcupdate.NEED_PWD_MKDB; then
	+	rm "${TEMPROOT}"/.etcupdate.NEED_PWD_MKDB
		if yesno "Do you want to rebuild the password databases from the" \
			 "new master.passwd"
		then
	@@ -780,13 +768,14 @@
		fi
	 fi

	-if ! ${NEED_SERVICES_MKDB}; then
	+if ! test -f "${TEMPROOT}"/.etcupdate.NEED_SERVICES_MKDB; then
		if test -e /var/db/services.db -a ! -e /var/db/services.cdb; then
	-		NEED_SERVICES_MKDB=true
	+		touch "${TEMPROOT}"/.etcupdate.NEED_SERVICES_MKDB
		fi
	 fi

	-if ${NEED_SERVICES_MKDB}; then
	+if test -f "${TEMPROOT}"/.etcupdate.NEED_SERVICES_MKDB; then
	+	rm "${TEMPROOT}"/.etcupdate.NEED_SERVICES_MKDB
		if yesno "Do you want to rebuild the services databases from the" \
			 "new /etc/services"
		then
	@@ -800,14 +789,16 @@
			echo ""
		fi
	 fi
	-if ${NEED_MTREE}; then
	+if test -f "${TEMPROOT}"/.etcupdate.NEED_MTREE; then
	+	rm "${TEMPROOT}"/.etcupdate.NEED_MTREE
		if yesno "You have created new directories. Run mtree to set" \
			 "permissions"
		then
			(cd / && mtree -Udef /etc/mtree/NetBSD.dist)
		fi
	 fi
	-if ${NEED_MAKEDEV}; then
	+if test -f "${TEMPROOT}"/.etcupdate.NEED_MAKEDEV; then
	+	rm "${TEMPROOT}"/.etcupdate.NEED_MAKEDEV
		if yesno "Do you want to rebuild the device nodes in /dev"; then
			verbose "Running MAKEDEV in /dev"
			(cd "/dev" && ./MAKEDEV all)
	@@ -819,7 +810,8 @@
			echo ""
		fi
	 fi
	-if ${NEED_NEWALIASES}; then
	+if test -f "${TEMPROOT}"/.etcupdate.NEED_NEWALIASES; then
	+	rm "${TEMPROOT}"/.etcupdate.NEED_NEWALIASES
		if yesno "Do you want to rebuild the mail alias database"; then
			verbose "Running newaliases"
			newaliases
	@@ -831,6 +823,14 @@
			echo ""
		fi
	 fi
	+
	+if yesno "Remove ${TEMPROOT}"; then
	+	echo "*** Removing ${TEMPROOT}"
	+	rm -rf "${TEMPROOT}"
	+else
	+	echo "*** Keeping ${TEMPROOT}"
	+fi
	+
	 if [ -x /usr/sbin/postinstall ]; then
		echo "*** Running /usr/sbin/postinstall"
		eval "/usr/sbin/postinstall ${SRC_ARGLIST} check"

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: install-manager->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Tue, 18 Jun 2019 23:33:38 +0000
Responsible-Changed-Why:
I am looking into this PR


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.