From owner-freebsd-bugs Mon Feb 4 19: 0:30 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 1130C37B421 for ; Mon, 4 Feb 2002 19:00:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g15302H67759; Mon, 4 Feb 2002 19:00:02 -0800 (PST) (envelope-from gnats) Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224]) by hub.freebsd.org (Postfix) with ESMTP id 9CB1037B417 for ; Mon, 4 Feb 2002 18:54:25 -0800 (PST) Received: (from mi@localhost) by aldan.algebra.com (8.11.6/8.11.5) id g152s2K41050; Mon, 4 Feb 2002 21:54:02 -0500 (EST) (envelope-from mi) Message-Id: <200202050254.g152s2K41050@aldan.algebra.com> Date: Mon, 4 Feb 2002 21:54:02 -0500 (EST) From: Mikhail Teterin Reply-To: Mikhail Teterin To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/34628: pkg-routines ignore the recorded md5 checksums Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 34628 >Category: bin >Synopsis: pkg-routines ignore the recorded md5 checksums >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Feb 04 19:00:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Mikhail Teterin >Release: FreeBSD 5.0-CURRENT i386 >Organization: Virtual Estates, Inc. >Environment: System: FreeBSD aldan.algebra.com 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Thu Jan 3 21:38:15 EST 2002 mi@aldan.algebra.com:/ccd/obj/ccd/src/sys/DEBUG i386 >Description: Currently the pkg-plist handling code in pkg_install/lib and elsewhere ignores the recorded md5 checksums recorded for various files. Upgrading ports from source can often result in different versions of the same port claiming the same files and confusing things like ``pkg_info -W'', which is when md5 checksum can be helpful. There could be other uses. >How-To-Repeat: cd /var/db/pkg cp -Rp test- vi test-/+CONTENTS [modify a checksum of a file] pkg_info -W >Fix: The patch below makes pkg_install/lib parse and record the md5 checksums, and pkg_info's -W option -- use them if the same file is claimed by multiple packages -- the last one having the correct checksum wins. There could be other usages, I suppose. Requesting permission to commit this change myself. Index: info/perform.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/perform.c,v retrieving revision 1.44 diff -U2 -r1.44 perform.c --- info/perform.c 10 Oct 2001 08:21:41 -0000 1.44 +++ info/perform.c 5 Feb 2002 02:53:43 -0000 @@ -27,4 +27,5 @@ #include "info.h" #include +#include #include @@ -381,4 +382,5 @@ } else if (itr->type == PLIST_FILE) { TAILQ_FOREACH(wp, which_list, next) { + char chsum[33] = "\0"; if (wp->skip == TRUE) continue; @@ -388,4 +390,14 @@ warnx("both %s and %s claim to have installed %s\n", wp->package, installed[i], wp->file); + if (chsum[0] == '\0' && itr->chsum[0] != '\0' && + MD5File(wp->file, chsum) == NULL) + warnx("can not get %s's md5-sum\n", wp->file); + if (chsum[0] != '\0' && + memcmp(chsum, itr->chsum, 32) == 0) { + warnx("%s has the right checksum " + "recorded for %s (%s)\n", + installed[i], wp->file, chsum); + strlcpy(wp->package, installed[i], PATH_MAX); + } } else { strlcpy(wp->package, installed[i], PATH_MAX); cvs server: Diffing lib Index: lib/lib.h =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/lib/lib.h,v retrieving revision 1.40 diff -U2 -r1.40 lib.h --- lib/lib.h 10 Oct 2001 08:21:41 -0000 1.40 +++ lib/lib.h 5 Feb 2002 02:53:43 -0000 @@ -109,4 +109,5 @@ Boolean marked; plist_t type; + char chsum[33]; }; typedef struct _plist *PackingList; Index: lib/plist.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/lib/plist.c,v retrieving revision 1.36 diff -U2 -r1.36 plist.c --- lib/plist.c 10 Oct 2001 08:21:41 -0000 1.36 +++ lib/plist.c 5 Feb 2002 02:53:43 -0000 @@ -280,4 +280,7 @@ } } + /* This may be the MD5 sum of the last entry: */ + if (cmd == PLIST_COMMENT) + sscanf(cp, "MD5:%32s", pkg->tail->chsum); bottom: add_plist(pkg, cmd, cp); cvs server: Diffing pkg cvs server: Diffing sign cvs server: Diffing update cvs server: Diffing version >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message