NetBSD Problem Report #52109

From hf@spg.tu-darmstadt.de  Fri Mar 24 18:04:01 2017
Return-Path: <hf@spg.tu-darmstadt.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 6AFC77A26A
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 24 Mar 2017 18:04:01 +0000 (UTC)
Message-Id: <201703241617.v2OGH8cX002825@Gstoder.nt.e-technik.tu-darmstadt.de>
Date: Fri, 24 Mar 2017 17:17:08 +0100 (CET)
From: Hauke Fath <hf@spg.tu-darmstadt.de>
Reply-To: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: Hauke Fath <hf@spg.tu-darmstadt.de>
Subject: etcupdate(8) DESTDIR glitch
X-Send-Pr-Version: 3.95

>Number:         52109
>Category:       bin
>Synopsis:       etcupdate(8) DESTDIR glitch
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kre
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 24 18:05:00 +0000 2017
>Last-Modified:  Wed Jun 19 01:15:05 +0000 2019
>Originator:     Hauke Fath
>Release:        NetBSD 7.99.50
>Organization:
Technische Universitaet Darmstadt
>Environment:


System: NetBSD Gstoder 7.99.50 NetBSD 7.99.50 (MONOLITHIC) #0: Fri Dec 16 15:07:39 CET 2016 hf@Hochstuhl:/var/obj/netbsd-builds/developer/i386/sys/arch/i386/compile/MONOLITHIC i386
Architecture: i386
Machine: i386
>Description:

	When you use etcupdate(8) with a DESTDIR (etcupdate -a -d
	<DESTDIR>), the md5(1) call in the script duplicates DESTDIR
	in the file path, leading to

What do you want to do? [Leave it for later] i
md5: /mnt/mnt/etc/pam.d/README: No such file or directory
md5: /mnt/mnt/etc/pam.d/display_manager: No such file or directory
md5: /mnt/mnt/etc/pam.d/ftpd: No such file or directory
md5: /mnt/mnt/etc/pam.d/gdm: No such file or directory
md5: /mnt/mnt/etc/pam.d/imap: No such file or directory
md5: /mnt/mnt/etc/pam.d/kde: No such file or directory
md5: /mnt/mnt/etc/pam.d/login: No such file or directory
md5: /mnt/mnt/etc/pam.d/other: No such file or directory
md5: /mnt/mnt/etc/pam.d/passwd: No such file or directory
md5: /mnt/mnt/etc/pam.d/pop3: No such file or directory

	ad nauseam.


>How-To-Repeat:

	Run etcupdate -a -d <DESTDIR> with DESTDIR != '/' after a
	NetBSD base update, say, to a USB stick installation.


>Fix:

	It looks like in

install_checksum() {
        # $1 = target file (relative to ${DESTDIR})

        ${AUTOMATIC} || return

        NEED_ANYTHING=true
        D="$(dirname "${1}")"
        mkdir -p "${DESTDIR}/var/etcupdate/${D}"
        verbose "Saving MD5 checksum for ${DESTDIR}${1} to" \
            "${DESTDIR}/var/etcupdate/${1}"
        # The sed part of the following pipeline changes things like
        # "MD5 (/path/to/dest/dir/etc/filename) = abc123" to
        # "MD5 (/etc/filename) = abc123".
        md5 "${DESTDIR}${1}" | sed -e "s,(${DESTDIR_BRE},(," \
            > "${DESTDIR}/var/etcupdate/${1}"
}

	the initial comment and the md5 invocation are at odds.

	The following patch appears to fix the issue:

--- /usr/sbin/etcupdate~        2016-08-12 13:43:57.000000000 +0200
+++ /usr/sbin/etcupdate 2017-03-24 17:11:46.000000000 +0100
@@ -243,7 +243,7 @@
        # The sed part of the following pipeline changes things like
        # "MD5 (/path/to/dest/dir/etc/filename) = abc123" to
        # "MD5 (/etc/filename) = abc123".
-       md5 "${DESTDIR}${1}" | sed -e "s,(${DESTDIR_BRE},(," \
+       md5 "${1}" | sed -e "s,(${DESTDIR_BRE},(," \
            > "${DESTDIR}/var/etcupdate/${1}"
 }

	The related cvs log entry

revision 1.56
date: 2014-06-12 15:56:32 +0200;  author: apb;  state: Exp;  lines: +106 -48;  commitid: riDedw2FWXEBLeEx;
Add "-d destdir" option to etcupdate.
This has been only lightly tested.

	appears correct.  ;)



>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: bin-bug-people->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Wed, 19 Jun 2019 01:15:05 +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.