Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Aug 2002 01:39:23 -0700
From:      Kris Kennaway <kris@obsecurity.org>
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        Jordan K Hubbard <jkh@queasyweasel.com>, Mikhail Teterin <mi+mx@aldan.algebra.com>, arch@FreeBSD.org, jkh@FreeBSD.org
Subject:   Re: pkg-routines ignore the recorded md5 checksums
Message-ID:  <20020831083923.GA90468@xor.obsecurity.org>
In-Reply-To: <20020831073845.GA74568@xor.obsecurity.org>
References:  <20020831070918.GA72640@xor.obsecurity.org> <049EDAFB-BCB3-11D6-A85D-0003938C7B7E@queasyweasel.com> <20020831073845.GA74568@xor.obsecurity.org>

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

--EeQfGwPcQSOJBaQU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Aug 31, 2002 at 12:38:45AM -0700, Kris Kennaway wrote:

> Perhaps we should change plist.c to make unrecognised commands
> non-fatal, so we can have more flexibility about extending the
> commandset in future.

Just for fun, I made the following patch which adds commands @md5,
@origin, @deporigin (while still recognizing the older @comment
forms).  I'd like to commit it after a transition period of a 4.x
release or so with my previous patch that makes unknown commands
non-fatal.

Kris

Index: create/pl.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr2/ncvs/src/usr.sbin/pkg_install/create/pl.c,v
retrieving revision 1.13.2.7
diff -u -r1.13.2.7 pl.c
--- create/pl.c	20 Aug 2002 06:35:07 -0000	1.13.2.7
+++ create/pl.c	31 Aug 2002 07:54:57 -0000
@@ -67,8 +67,8 @@
 	    if (cp !=3D NULL) {
 		PackingList tmp =3D new_plist_entry();
=20
-		tmp->name =3D copy_string(strconcat("MD5:", cp));
-		tmp->type =3D PLIST_COMMENT;
+		tmp->name =3D copy_string(cp);
+		tmp->type =3D PLIST_MD5;
 		tmp->next =3D p->next;
 		tmp->prev =3D p;
 		p->next =3D tmp;
Index: info/show.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr2/ncvs/src/usr.sbin/pkg_install/info/show.c,v
retrieving revision 1.32
diff -u -r1.32 show.c
--- info/show.c	11 May 2002 04:17:55 -0000	1.32
+++ info/show.c	31 Aug 2002 08:33:26 -0000
@@ -154,7 +154,7 @@
 	    break;
=20
 	case PLIST_DEPORIGIN:
-	    printf(Quiet ? "@comment DEPORIGIN:%s\n" :
+	    printf(Quiet ? "@deporigin %s\n" :
 		"\tdependency origin: %s\n", p->name);
 	    break;
=20
@@ -173,8 +173,12 @@
 	    break;
=20
 	case PLIST_ORIGIN:
-	    printf(Quiet ? "@comment ORIGIN:%s\n" :
+	    printf(Quiet ? "@origin %s\n" :
 		"\tPackage origin: %s\n", p->name);=20
+	    break;
+
+	case PLIST_MD5:
+	    printf(Quiet ? "@md5 %s\n" : "\tMD5 sum: %s\n", p->name);
 	    break;
=20
 	default:
Index: lib/lib.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr2/ncvs/src/usr.sbin/pkg_install/lib/lib.h,v
retrieving revision 1.29.2.10
diff -u -r1.29.2.10 lib.h
--- lib/lib.h	2 Aug 2002 11:09:05 -0000	1.29.2.10
+++ lib/lib.h	31 Aug 2002 08:29:06 -0000
@@ -91,7 +91,7 @@
     PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE,
     PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY,
     PLIST_PKGDEP, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST,
-    PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN
+    PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN, PLIST_MD5
 };
 typedef enum _plist_t plist_t;
=20
Index: lib/plist.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr2/ncvs/src/usr.sbin/pkg_install/lib/plist.c,v
retrieving revision 1.29.2.9
diff -u -r1.29.2.9 plist.c
--- lib/plist.c	20 Aug 2002 06:35:08 -0000	1.29.2.9
+++ lib/plist.c	31 Aug 2002 08:29:20 -0000
@@ -222,6 +222,10 @@
 	return PLIST_CHOWN;
     else if (!strcmp(cmd, "group"))
 	return PLIST_CHGRP;
+    else if (!strcmp(cmd, "origin"))
+	return PLIST_ORIGIN;
+    else if (!strcmp(cmd, "deporigin"))
+	return PLIST_DEPORIGIN;
     else if (!strcmp(cmd, "comment")) {
 	if (!strncmp(*arg, "ORIGIN:", 7)) {
 	    *arg +=3D 7;
@@ -247,6 +251,8 @@
 	return PLIST_DIR_RM;
     else if (!strcmp(cmd, "option"))
 	return PLIST_OPTION;
+    else if (!strcmp(cmd, "md5"))
+	return PLIST_MD5;
     else
 	return FAIL;
 }
@@ -276,7 +282,7 @@
 	cmd =3D plist_cmd(pline + 1, &cp);
 	if (cmd =3D=3D FAIL) {
 	    cleanup(0);
-	    errx(2, "%s: bad command '%s'", __func__, pline);
+	    warnx("%s: unknown command '%s' (package tools out of date?)", __func=
__, pline);
 	}
 	if (*cp =3D=3D '\0') {
 	    cp =3D NULL;
@@ -376,11 +382,15 @@
 	    break;
=20
 	case PLIST_ORIGIN:
-	    fprintf(fp, "%ccomment ORIGIN:%s\n", CMD_CHAR, plist->name);
+	    fprintf(fp, "%corigin %s\n", CMD_CHAR, plist->name);
 	    break;
=20
 	case PLIST_DEPORIGIN:
-	    fprintf(fp, "%ccomment DEPORIGIN:%s\n", CMD_CHAR, plist->name);
+	    fprintf(fp, "%cdeporigin %s\n", CMD_CHAR, plist->name);
+	    break;
+
+	case PLIST_MD5:
+	    fprintf(fp, "%cmd5 %s\n", CMD_CHAR, plist->name);
 	    break;
=20
 	default:
@@ -443,8 +453,15 @@
 	   "this packing list is incorrect - ignoring delete request", tmp);
 	    }
 	    else {
-		if (p->next && p->next->type =3D=3D PLIST_COMMENT && !strncmp(p->next->n=
ame, "MD5:", 4)) {
-		    char *cp =3D NULL, buf[33];
+		if (p->next && (( p->next->type =3D=3D PLIST_COMMENT &&
+		  !strncmp(p->next->name, "MD5:", 4)) ||
+		  p->next->type =3D=3D PLIST_MD5 )) {
+		    char *cp =3D NULL, buf[33], offset;
+
+                    if ( p->next->type =3D=3D PLIST_MD5)
+			offset =3D 0;
+		    else
+			offset =3D 4;
=20
 		    /*
 		     * For packing lists whose version is 1.1 or greater, the md5
@@ -462,7 +479,7 @@
=20
 		    if (cp !=3D NULL) {
 			/* Mismatch? */
-			if (strcmp(cp, p->next->name + 4)) {
+			if (strcmp(cp, p->next->name + offset)) {
 			    warnx("`%s' fails original MD5 checksum - %s",
 				       tmp, Force ? "deleted anyway." : "not deleted.");
 			    if (!Force) {

--EeQfGwPcQSOJBaQU
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE9cIC6Wry0BWjoQKURApIWAKDxR16z2IHY9MFZQS1VBpYzwRAgsACeNE9J
vJA10kcNP8kK8lDynbyy0U8=
=2K+k
-----END PGP SIGNATURE-----

--EeQfGwPcQSOJBaQU--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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