Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Aug 2002 02:26:28 -0700
From:      Jordan K Hubbard <jkh@queasyweasel.com>
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        Mikhail Teterin <mi+mx@aldan.algebra.com>, arch@FreeBSD.ORG, jkh@FreeBSD.ORG
Subject:   Re: pkg-routines ignore the recorded md5 checksums
Message-ID:  <BA165CBC-BCC3-11D6-A85D-0003938C7B7E@queasyweasel.com>
In-Reply-To: <20020831083923.GA90468@xor.obsecurity.org>

next in thread | previous in thread | raw e-mail | index | archive | help
[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) {
> <mime-attachment>
--
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BA165CBC-BCC3-11D6-A85D-0003938C7B7E>