Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 May 2001 01:01:55 +0300 (EEST)
From:      Maxim Sobolev <sobomax@mail-in.net>
To:        marcus@marcuscom.com, freebsd-ports@FreeBSD.ORG
Cc:        jkh@FreeBSD.ORG, rooneg@electricjellyfish.net
Subject:   Re: Patches to pkg_info
Message-ID:  <200105252201.f4PM1qS07604@mail.uic-in.net>
In-Reply-To: <20010523130009.F96799-400000@shumai.marcuscom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 23 May 2001 13:07:41 -0400 (EDT), Joe Clarke wrote:
> Here are some patches to the current version of pkg_info that add on to
> Garrett's which code.  When the -g option is specified with the -W option=
,
> the files MD5 checksum will also be checked.  This is similar to Solaris'
> pkgchk command.
> =

> This compliments the way the -g option works on packages, by extending th=
e
> option to individual files.
> =

> I have tested this on FreeBSD 4.3.
> =

> > pkg_info -g -W gmake
> /usr/local/bin/gmake was installed by package gmake-3.79.1
> Expected MD5 checksum: 0b8c0582b07a3eb8a8dd9fdd93ea71c8
> MD5 checksum matches.

I'll take a look at it in a few days.

Thank you for submission!

-Maxim

> --- perform.c.orig=09Wed May 23 12:11:24 2001=0D
> +++ perform.c=09Wed May 23 12:13:47 2001=0D
> @@ -26,6 +26,7 @@=0D
>  #include "lib.h"=0D
>  #include "info.h"=0D
>  #include <err.h>=0D
> +#include <md5.h>=0D
>  #include <signal.h>=0D
>  =0D
>  static int pkg_do(char *);=0D
> @@ -391,6 +392,12 @@=0D
>  =09=09=09      wp->package, installed[i], wp->file);=0D
>  =09=09    } else {=0D
>  =09=09=09strlcpy(wp->package, installed[i], PATH_MAX);=0D
> +=09=09=09/* Add code to check for file's MD5 checksum */=0D
> +=09=09=09if ((Flags & SHOW_CKSUM) && itr->next && =0D
> +=09=09=09=09itr->next->type =3D=3D PLIST_COMMENT && =0D
> +=09=09=09=09!strncmp(itr->next->name, "MD5:", 4)) {=0D
> +=09=09=09    strlcpy(wp->md5, (itr->next->name + 4), 33);=0D
> +=09=09=09}=0D
>  =09=09    }=0D
>  =09=09}=0D
>  =09    }=0D
> @@ -405,6 +412,21 @@=0D
>  =09    else=0D
>  =09=09printf("%s was installed by package %s\n", \=0D
>  =09=09       wp->file, wp->package);=0D
> +=09    if (Flags & SHOW_CKSUM) {=0D
> +=09=09/* If Verbose, check the installed files MD5 checksum=0D
> +=09=09   against the checksum in the +CONTENTS file. */=0D
> +=09=09char *cp, buf[33];=0D
> +=0D
> +=09=09printf("Expected MD5 checksum: %s\n", wp->md5);=0D
> +=09=09if ((cp =3D MD5File(wp->file, buf)) !=3D NULL) {=0D
> +=09=09    if (strncmp(cp, wp->md5, 33)) {=0D
> +=09=09=09printf("MD5 checksum does not match!\n");=0D
> +=09=09    }=0D
> +=09=09    else {=0D
> +=09=09=09printf("MD5 checksum matches.\n");=0D
> +=09=09    }=0D
> +=09=09}=0D
> +=09    }=0D
>  =09}=0D
>      }=0D
>      while (!TAILQ_EMPTY(which_list)) {=0D
> --- info.h.orig=09Sun May 20 00:12:46 2001=0D
> +++ info.h=09Sun May 20 00:05:46 2001=0D
> @@ -53,6 +53,7 @@=0D
>      TAILQ_ENTRY(which_entry) next;=0D
>      char file[PATH_MAX];=0D
>      char package[PATH_MAX];=0D
> +    char md5[33];=0D
>      Boolean skip;=0D
>  };=0D
>  TAILQ_HEAD(which_head, which_entry);=0D
> --- pkg_info.1.orig=09Wed May 23 12:11:24 2001=0D
> +++ pkg_info.1=09Wed May 23 13:03:27 2001=0D
> @@ -106,14 +106,19 @@=0D
>  .Nm=0D
>  automatically expands shell glob patterns in the=0D
>  .Ar pkg-name ) .=0D
> -.It Fl W=0D
> +.It Fl W Ar filename=0D
>  For the specified=0D
>  .Ar filename=0D
>  argument show which package it belongs to.  If the file is not in the=0D
>  current directory, and does not have an absolute path, then the =0D
>  .Ev PATH=0D
>  is searched using=0D
> -.Xr which 1 .=0D
> +.Xr which 1 .  =0D
> +When the=0D
> +.Fl g=0D
> +argument is also specified, the md5 checksum will be calculated for=0D
> +.Ar filename=0D
> +and compared against the expected value.=0D
>  .It Fl x=0D
>  Treat the=0D
>  .Ar pkg-name=0D
> =


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




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