Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Feb 2002 21:54:02 -0500 (EST)
From:      Mikhail Teterin <mi@aldan.algebra.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/34628: pkg-routines ignore the recorded md5 checksums
Message-ID:  <200202050254.g152s2K41050@aldan.algebra.com>

next in thread | raw e-mail | index | archive | help

>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 <some package> test-<some package>
	vi test-<some package>/+CONTENTS
	[modify a checksum of a file]
	pkg_info -W <that file>

>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 <err.h>
+#include <md5.h>
 #include <signal.h>
 
@@ -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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202050254.g152s2K41050>