NetBSD Problem Report #50846

From www@NetBSD.org  Wed Feb 24 21:41:57 2016
Return-Path: <www@NetBSD.org>
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 5D9497ABDC
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 24 Feb 2016 21:41:57 +0000 (UTC)
Message-Id: <20160224214156.3D02F7ACB1@mollari.NetBSD.org>
Date: Wed, 24 Feb 2016 21:41:56 +0000 (UTC)
From: uwe@NetBSD.org
Reply-To: uwe@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: etcupdate -a doesn't handle destdir properly
X-Send-Pr-Version: www-1.0

>Number:         50846
>Category:       install
>Synopsis:       etcupdate -a doesn't handle destdir properly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kre
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 24 21:45:00 +0000 2016
>Last-Modified:  Wed Jun 19 16:10:01 +0000 2019
>Originator:     Valery Ushakov
>Release:        NetBSD 7.0
>Organization:
>Environment:
>Description:
From source code inspection, etcupdate has:

	if ${AUTOMATIC} && [ -f "${DESTDIR}/var/etcupdate/${1}" ]; then
		SUM1="$(md5 "${1}")"

The problem is that SUM1 is computed for the wrong file if -d destdir
is also specified.  Unfortunately, it can't be fixed by just using

  md5 "${DESTDIR}${1}"

since the file name is in the output and it will be different from the
one in SUM2.  See also the massage of the file name that the
install_checksum() does.

>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: install/50846: etcupdate -a doesn't handle destdir properly
Date: Thu, 25 Feb 2016 12:22:20 +0700

     Date:        Wed, 24 Feb 2016 21:45:00 +0000 (UTC)
     From:        uwe@NetBSD.org
     Message-ID:  <20160224214500.C41BF7ABEE@mollari.NetBSD.org>

   | The problem is that SUM1 is computed for the wrong file if -d destdir
   | is also specified.  Unfortunately, it can't be fixed by just using
   | 
   |   md5 "${DESTDIR}${1}"

 Maybe:
 	SUM1=$( cd "${DESTDIR:-.}" && md5 "${1}" )

 [Untested.  It shouldn't really need the extra set of enclosing quotes, but ...]

 kre

Responsible-Changed-From-To: install-manager->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Wed, 19 Jun 2019 01:16:27 +0000
Responsible-Changed-Why:
I am looking into this PR


From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: install/50846 (etcupdate -a doesn't handle destdir properly)
Date: Wed, 19 Jun 2019 15:30:06 +0300

 Ugh, I completely forgot all the details.  However we seem to have the
 code that does this at the very end of install_checksum(), fixing up
 md5 output with sed.

 So the problem seems to be that we do compute the wrong file checksum
 before calling install_checksum() but then we would compute the right
 file checksum in install_checksum() itself.

 Come to think of it, one thing that always kinda annoyed me about it
 is that etcupdate always overwrite the checksum file even if the old
 one is the same.  Since this is exactly the place where it happens, we
 might want to fix this in one swoop.

 -uwe

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: install/50846 (etcupdate -a doesn't handle destdir properly)
Date: Wed, 19 Jun 2019 23:08:08 +0700

     Date:        Wed, 19 Jun 2019 12:35:01 +0000 (UTC)
     From:        Valery Ushakov <uwe@stderr.spb.ru>
     Message-ID:  <20190619123501.654B97A1C4@mollari.NetBSD.org>

   |  the problem seems to be that we do compute the wrong file checksum
   |  before calling install_checksum() but then we would compute the right
   |  file checksum in install_checksum() itself.

 There are 3 different PRs (yours (50846), 51335, and 52109), all more
 recent that the last etcupdate commit, that at least refer to the same
 problem - with different proposals for fixes.   I will seek to find
 something that works.

   |  Come to think of it, one thing that always kinda annoyed me about it
   |  is that etcupdate always overwrite the checksum file even if the old
   |  one is the same.  Since this is exactly the place where it happens, we
   |  might want to fix this in one swoop.

 Seems reasonable, I will add that to the list.

 I'm not sure what I will do with Bill Simpson's PR (23212) from 2003
 (1.6ZD !) though, if anyone has any opinions on that one (it relates to
 what should update the /etc/moduli file) I'd love to hear them.

 kre


>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.