From owner-freebsd-arch Sat Aug 31 2:26:43 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 48A5137B400; Sat, 31 Aug 2002 02:26:34 -0700 (PDT) Received: from jkh-gw.queasyweasel.com (adsl-64-173-3-158.dsl.sntc01.pacbell.net [64.173.3.158]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7DFC143E6E; Sat, 31 Aug 2002 02:26:33 -0700 (PDT) (envelope-from jkh@queasyweasel.com) Received: from adsl-64-173-15-99.dsl.sntc01.pacbell.net (jkh@mango.freebsd.com [64.173.15.99]) by jkh-gw.queasyweasel.com (8.12.5/8.12.5) with ESMTP id g7V9QKWh025358; Sat, 31 Aug 2002 02:26:20 -0700 (PDT) (envelope-from jkh@queasyweasel.com) Date: Sat, 31 Aug 2002 02:26:28 -0700 Subject: Re: pkg-routines ignore the recorded md5 checksums Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v543) Cc: Mikhail Teterin , arch@FreeBSD.ORG, jkh@FreeBSD.ORG To: Kris Kennaway From: Jordan K Hubbard In-Reply-To: <20020831083923.GA90468@xor.obsecurity.org> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.543) Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG [review review] Looks good to me! - Jordan On Saturday, August 31, 2002, at 01:39 AM, Kris Kennaway wrote: > 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 > =================================================================== > 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 != NULL) { > PackingList tmp = new_plist_entry(); > > - tmp->name = copy_string(strconcat("MD5:", cp)); > - tmp->type = PLIST_COMMENT; > + tmp->name = copy_string(cp); > + tmp->type = PLIST_MD5; > tmp->next = p->next; > tmp->prev = p; > p->next = tmp; > Index: info/show.c > =================================================================== > 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; > > case PLIST_DEPORIGIN: > - printf(Quiet ? "@comment DEPORIGIN:%s\n" : > + printf(Quiet ? "@deporigin %s\n" : > "\tdependency origin: %s\n", p->name); > break; > > @@ -173,8 +173,12 @@ > break; > > case PLIST_ORIGIN: > - printf(Quiet ? "@comment ORIGIN:%s\n" : > + printf(Quiet ? "@origin %s\n" : > "\tPackage origin: %s\n", p->name); > + break; > + > + case PLIST_MD5: > + printf(Quiet ? "@md5 %s\n" : "\tMD5 sum: %s\n", p->name); > break; > > default: > Index: lib/lib.h > =================================================================== > 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; > > Index: lib/plist.c > =================================================================== > 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 += 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 = plist_cmd(pline + 1, &cp); > if (cmd == 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 == '\0') { > cp = NULL; > @@ -376,11 +382,15 @@ > break; > > case PLIST_ORIGIN: > - fprintf(fp, "%ccomment ORIGIN:%s\n", CMD_CHAR, plist->name); > + fprintf(fp, "%corigin %s\n", CMD_CHAR, plist->name); > break; > > 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; > > default: > @@ -443,8 +453,15 @@ > "this packing list is incorrect - ignoring delete request", tmp); > } > else { > - if (p->next && p->next->type == PLIST_COMMENT && > !strncmp(p->next->name, "MD5:", 4)) { > - char *cp = NULL, buf[33]; > + if (p->next && (( p->next->type == PLIST_COMMENT && > + !strncmp(p->next->name, "MD5:", 4)) || > + p->next->type == PLIST_MD5 )) { > + char *cp = NULL, buf[33], offset; > + > + if ( p->next->type == PLIST_MD5) > + offset = 0; > + else > + offset = 4; > > /* > * For packing lists whose version is 1.1 or greater, the md5 > @@ -462,7 +479,7 @@ > > if (cp != 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) { > -- Jordan K. Hubbard Engineering Manager, BSD technology group Apple Computer To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message