Date: Fri, 2 Feb 2001 18:17:23 +0200 From: Roman Shterenzon <roman@xpert.com> To: jkh@freebsd.org, freebsd-stable@freebsd.org Subject: [PATCH for review] Add verify checksum functionality to pkg_info Message-ID: <20010202181722.A82035@alchemy.oven.org>
next in thread | raw e-mail | index | archive | help
--n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Can you please review this patch, thanks. --Roman Shterenzon, UNIX System Administrator and Consultant [ Xpert UNIX Systems Ltd., Herzlia, Israel. Tel: +972-9-9522361 ] --n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pkg_info.diff" diff -urN /usr/src/usr.sbin/pkg_install/info/info.h pkg_install/info/info.h --- /usr/src/usr.sbin/pkg_install/info/info.h Wed Nov 1 23:18:35 2000 +++ pkg_install/info/info.h Fri Feb 2 16:32:32 2001 @@ -45,6 +45,7 @@ #define SHOW_MTREE 0x0800 #define SHOW_SIZE 0x1000 #define SHOW_ORIGIN 0x2000 +#define SHOW_CKSUM 0x4000 extern int Flags; extern Boolean AllInstalled; diff -urN /usr/src/usr.sbin/pkg_install/info/main.c pkg_install/info/main.c --- /usr/src/usr.sbin/pkg_install/info/main.c Sun Dec 10 14:44:37 2000 +++ pkg_install/info/main.c Fri Feb 2 16:32:37 2001 @@ -28,7 +28,7 @@ "$FreeBSD: src/usr.sbin/pkg_install/info/main.c,v 1.22.2.5 2000/12/05 11:03:20 sobomax Exp $"; #endif -static char Options[] = "acdDe:fhiIkl:LmopqrRst:v"; +static char Options[] = "acdDe:fghiIkl:LmopqrRst:v"; int Flags = 0; Boolean AllInstalled = FALSE; @@ -86,6 +86,10 @@ case 'f': Flags |= SHOW_PLIST; + break; + + case 'g': + Flags |= SHOW_CKSUM; break; case 'i': diff -urN /usr/src/usr.sbin/pkg_install/info/perform.c pkg_install/info/perform.c --- /usr/src/usr.sbin/pkg_install/info/perform.c Wed Nov 1 23:18:35 2000 +++ pkg_install/info/perform.c Fri Feb 2 16:32:27 2001 @@ -205,6 +205,8 @@ show_files("Files:\n", &plist); if ((Flags & SHOW_SIZE) && installed) show_size("Package Size:\n", &plist); + if ((Flags & SHOW_CKSUM) && installed) + show_cksum("Mismatched Checksums:\n", &plist); if (Flags & SHOW_ORIGIN) show_origin("Origin:\n", &plist); if (!Quiet) diff -urN /usr/src/usr.sbin/pkg_install/info/pkg_info.1 pkg_install/info/pkg_info.1 --- /usr/src/usr.sbin/pkg_install/info/pkg_info.1 Thu Dec 28 23:54:17 2000 +++ pkg_install/info/pkg_info.1 Fri Feb 2 17:13:37 2001 @@ -25,7 +25,7 @@ .Nd a utility for displaying information on software packages .Sh SYNOPSIS .Nm -.Op Fl cdDfiIkLmopqrRsv +.Op Fl cdDfgiIkLmopqrRsv .Op Fl e Ar package .Op Fl l Ar prefix .Op Fl t Ar template @@ -69,6 +69,8 @@ Show the install-message file for each package. .It Fl f Show the packing list instructions for each package. +.It Fl g +Show files that don't match the recorded checksum. .It Fl i Show the install script (if any) for each package. .It Fl I diff -urN /usr/src/usr.sbin/pkg_install/info/show.c pkg_install/info/show.c --- /usr/src/usr.sbin/pkg_install/info/show.c Wed Nov 1 23:18:35 2000 +++ pkg_install/info/show.c Fri Feb 2 17:10:24 2001 @@ -30,6 +30,7 @@ #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> +#include <md5.h> void show_file(char *title, char *fname) @@ -255,6 +256,35 @@ printf("%lu\t(%s)\n", howmany(size, blksize), descr); else printf("%lu\n", size); +} + +/* Show files that don't match the recorded checksum */ +void +show_cksum(char *title, Package *plist) +{ + PackingList p; + char *dir = "."; + char tmp[FILENAME_MAX]; + + if (!Quiet) + printf("%s%s", InfoPrefix, title); + + for (p = plist->head; p != NULL; p = p->next) + if (p->type == PLIST_CWD) + dir = p->name; + else if (p->type == PLIST_FILE) { + snprintf(tmp, FILENAME_MAX, "%s/%s", dir, p->name); + if (!fexists(tmp)) + warnx("%s doesn't exist\n", tmp); + else if (p->next && p->next->type == PLIST_COMMENT && !strncmp(p->next->name, "MD5:", 4)) { + char *cp, buf[33]; + if ((cp = MD5File(tmp, buf)) != NULL) + if (strcmp(cp, p->next->name + 4)) + printf("%s fails the original MD5 checksum\n", tmp); + else if (Verbose) + printf("%s matched the original MD5 checksum\n", tmp); + } + } } /* Show an "origin" path (usually category/portname) */ --n8g4imXOkfNTN/H1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010202181722.A82035>