Re: md5: new -C flag to skip non-existent files in checklist
On Thu, Mar 15, 2012 at 03:26:44AM -0400, Ted Unangst wrote: > On Mon, Mar 12, 2012, Stuart Henderson wrote: > > On 2012/03/12 00:49, Daniel C. Sinclair wrote: > >> What do you think of making cksum output: > >> > >> (SHA256) nonexistant.txt: MISSING > >> > >> instead of FAILED and the extra output to stderr saying "No such file > >> or directory"? > > > > I think this would be useful (in particular, for people downloading a set > > of packages and wanting to check them against the SHA256 file). > > Index: md5.c > === > RCS file: /home/tedu/cvs/src/bin/md5/md5.c,v > retrieving revision 1.53 > diff -u -p -r1.53 md5.c > --- md5.c 5 Jul 2011 23:39:27 - 1.53 > +++ md5.c 15 Mar 2012 07:25:21 - > @@ -655,8 +655,7 @@ digest_filelist(const char *file, struct > found = 1; > > if ((fp = fopen(filename, "r")) == NULL) { > - warn("cannot open %s", filename); > - (void)printf("(%s) %s: FAILED\n", algorithm, filename); > + (void)printf("(%s) %s: MISSING\n", algorithm, filename); > error = 1; > continue; > } I guess you want to only print missing on ENOENT, any other like EACCES should still print FAILED. -Otto
Re: md5: new -C flag to skip non-existent files in checklist
On Mon, Mar 12, 2012, Stuart Henderson wrote: > On 2012/03/12 00:49, Daniel C. Sinclair wrote: >> What do you think of making cksum output: >> >> (SHA256) nonexistant.txt: MISSING >> >> instead of FAILED and the extra output to stderr saying "No such file >> or directory"? > > I think this would be useful (in particular, for people downloading a set > of packages and wanting to check them against the SHA256 file). Index: md5.c === RCS file: /home/tedu/cvs/src/bin/md5/md5.c,v retrieving revision 1.53 diff -u -p -r1.53 md5.c --- md5.c 5 Jul 2011 23:39:27 - 1.53 +++ md5.c 15 Mar 2012 07:25:21 - @@ -655,8 +655,7 @@ digest_filelist(const char *file, struct found = 1; if ((fp = fopen(filename, "r")) == NULL) { - warn("cannot open %s", filename); - (void)printf("(%s) %s: FAILED\n", algorithm, filename); + (void)printf("(%s) %s: MISSING\n", algorithm, filename); error = 1; continue; }
Re: md5: new -C flag to skip non-existent files in checklist
On 2012/03/12 00:49, Daniel C. Sinclair wrote: > What do you think of making cksum output: > > (SHA256) nonexistant.txt: MISSING > > instead of FAILED and the extra output to stderr saying "No such file > or directory"? I think this would be useful (in particular, for people downloading a set of packages and wanting to check them against the SHA256 file).
Re: md5: new -C flag to skip non-existent files in checklist
What do you think of making cksum output: (SHA256) nonexistant.txt: MISSING instead of FAILED and the extra output to stderr saying "No such file or directory"? This would make it easier to ignore the MISSING files but still see those that FAILED the checksum. Daniel On Thu, Feb 23, 2012 at 12:24 PM, Lawrence Teo wrote: > On Thu, Feb 23, 2012 at 11:46:11AM +0100, Mark Kettenis wrote: >> > Date: Thu, 23 Feb 2012 10:48:17 +0100 >> > From: Marc Espie >> > >> > On Thu, Feb 23, 2012 at 08:16:20AM +, Nicholas Marriott wrote: >> > > Hi >> > > >> > > Is this really much more useful than 2>/dev/null? >> > > >> > Note the FAILED that vanish. >> > >> > I'm not sure it's not bloat anyways. >> >> None of the other BSDs seem to implement an option like this (and >> md5(1) is pretty much a BSDism; Linux and Solaris don't have it). >> >> Our policy tends to be to not add non-standard options to our >> utilities to encourage people to write portable shell scripts. Of >> course we make exceptions if a strong case can be made for the added >> functionality. But personally I don't think that's the case here. > > md5(1) on FreeBSD, DragonFly BSD, and OS X do not even have -c, so in a > way shell scripts with "md5 -c" are already relatively unportable. :) > > I do appreciate your feedback and understand your point. > > Thanks, > Lawrence
Re: md5: new -C flag to skip non-existent files in checklist
On Thu, Feb 23, 2012 at 11:46:11AM +0100, Mark Kettenis wrote: > > Date: Thu, 23 Feb 2012 10:48:17 +0100 > > From: Marc Espie > > > > On Thu, Feb 23, 2012 at 08:16:20AM +, Nicholas Marriott wrote: > > > Hi > > > > > > Is this really much more useful than 2>/dev/null? > > > > > Note the FAILED that vanish. > > > > I'm not sure it's not bloat anyways. > > None of the other BSDs seem to implement an option like this (and > md5(1) is pretty much a BSDism; Linux and Solaris don't have it). > > Our policy tends to be to not add non-standard options to our > utilities to encourage people to write portable shell scripts. Of > course we make exceptions if a strong case can be made for the added > functionality. But personally I don't think that's the case here. md5(1) on FreeBSD, DragonFly BSD, and OS X do not even have -c, so in a way shell scripts with "md5 -c" are already relatively unportable. :) I do appreciate your feedback and understand your point. Thanks, Lawrence
Re: md5: new -C flag to skip non-existent files in checklist
On 23 February 2012 08:46, Mark Kettenis wrote: >> Date: Thu, 23 Feb 2012 10:48:17 +0100 >> From: Marc Espie >> >> On Thu, Feb 23, 2012 at 08:16:20AM +, Nicholas Marriott wrote: >> > Hi >> > >> > Is this really much more useful than 2>/dev/null? >> > >> Note the FAILED that vanish. >> >> I'm not sure it's not bloat anyways. > > None of the other BSDs seem to implement an option like this (and > md5(1) is pretty much a BSDism; Linux and Solaris don't have it). > > Our policy tends to be to not add non-standard options to our > utilities to encourage people to write portable shell scripts. Of > course we make exceptions if a strong case can be made for the added > functionality. But personally I don't think that's the case here. > Since this is just a small specialization of the -c case, how about an environment var ? /me ducks
Re: md5: new -C flag to skip non-existent files in checklist
> Date: Thu, 23 Feb 2012 10:48:17 +0100 > From: Marc Espie > > On Thu, Feb 23, 2012 at 08:16:20AM +, Nicholas Marriott wrote: > > Hi > > > > Is this really much more useful than 2>/dev/null? > > > Note the FAILED that vanish. > > I'm not sure it's not bloat anyways. None of the other BSDs seem to implement an option like this (and md5(1) is pretty much a BSDism; Linux and Solaris don't have it). Our policy tends to be to not add non-standard options to our utilities to encourage people to write portable shell scripts. Of course we make exceptions if a strong case can be made for the added functionality. But personally I don't think that's the case here.
Re: md5: new -C flag to skip non-existent files in checklist
I almost put "or grep or so on" in my original mail, but the point is the same... On Thu, Feb 23, 2012 at 09:36:03AM +0100, Landry Breuil wrote: > On Thu, Feb 23, 2012 at 08:16:20AM +, Nicholas Marriott wrote: > > Hi > > > > Is this really much more useful than 2>/dev/null? > > Yes, return code would be 0 if all present files match... > > Landry
Re: md5: new -C flag to skip non-existent files in checklist
On Thu, Feb 23, 2012 at 08:16:20AM +, Nicholas Marriott wrote: > Hi > > Is this really much more useful than 2>/dev/null? > Note the FAILED that vanish. I'm not sure it's not bloat anyways.
Re: md5: new -C flag to skip non-existent files in checklist
On Thu, Feb 23, 2012 at 08:16:20AM +, Nicholas Marriott wrote: > Hi > > Is this really much more useful than 2>/dev/null? Yes, return code would be 0 if all present files match... Landry
Re: md5: new -C flag to skip non-existent files in checklist
Hi Is this really much more useful than 2>/dev/null? On Wed, Feb 22, 2012 at 11:15:50PM -0500, Lawrence Teo wrote: > This diff adds a new -C flag to the md5/cksum/sha1/sha256 programs, > which does the same thing as the -c flag except that it skips > non-existent files in the checklist. > > This is useful when you want to use a checklist file to only verify the > checksums of files that actually exist. A common example is when you > download just a few file sets from an OpenBSD mirror to test a > snapshot, and you want to verify the checksums of those files only. > > Here's an example that shows the difference between -c and -C: > > $ ls > SHA256 base51.tgz bsdbsd.rd etc51.tgz > > $ sha256 -c SHA256 > sha256: cannot open INSTALL.amd64: No such file or directory > (SHA256) INSTALL.amd64: FAILED > (SHA256) base51.tgz: OK > (SHA256) bsd: OK > sha256: cannot open bsd.mp: No such file or directory > (SHA256) bsd.mp: FAILED > (SHA256) bsd.rd: OK > sha256: cannot open cd51.iso: No such file or directory > (SHA256) cd51.iso: FAILED > sha256: cannot open cdboot: No such file or directory > (SHA256) cdboot: FAILED > sha256: cannot open cdbr: No such file or directory > (SHA256) cdbr: FAILED > sha256: cannot open comp51.tgz: No such file or directory > (SHA256) comp51.tgz: FAILED > (SHA256) etc51.tgz: OK > sha256: cannot open floppy51.fs: No such file or directory > (SHA256) floppy51.fs: FAILED > sha256: cannot open game51.tgz: No such file or directory > (SHA256) game51.tgz: FAILED > sha256: cannot open man51.tgz: No such file or directory > (SHA256) man51.tgz: FAILED > sha256: cannot open pxeboot: No such file or directory > (SHA256) pxeboot: FAILED > sha256: cannot open install51.iso: No such file or directory > (SHA256) install51.iso: FAILED > sha256: cannot open xbase51.tgz: No such file or directory > (SHA256) xbase51.tgz: FAILED > sha256: cannot open xetc51.tgz: No such file or directory > (SHA256) xetc51.tgz: FAILED > sha256: cannot open xfont51.tgz: No such file or directory > (SHA256) xfont51.tgz: FAILED > sha256: cannot open xserv51.tgz: No such file or directory > (SHA256) xserv51.tgz: FAILED > sha256: cannot open xshare51.tgz: No such file or directory > (SHA256) xshare51.tgz: FAILED > > $ sha256 -C SHA256 > (SHA256) base51.tgz: OK > (SHA256) bsd: OK > (SHA256) bsd.rd: OK > (SHA256) etc51.tgz: OK > > Comments? > > Thanks, > Lawrence > > > Index: cksum.1 > === > RCS file: /cvs/src/bin/md5/cksum.1,v > retrieving revision 1.23 > diff -u -p -r1.23 cksum.1 > --- cksum.1 7 Nov 2010 08:05:55 - 1.23 > +++ cksum.1 23 Feb 2012 03:53:44 - > @@ -44,7 +44,7 @@ > .Bk -words > .Op Fl bpqrtx > .Op Fl a Ar algorithms > -.Op Fl c Op Ar checklist ... > +.Op Fl c | Fl C Op Ar checklist ... > .Op Fl o Ar 1 | 2 > .Op Fl s Ar string > .Op Ar > @@ -162,6 +162,15 @@ The > option may not be used in conjunction with more than a single > .Fl a > option. > +.It Xo > +.Fl C > +.Op Ar checklist ... > +.Xc > +As option > +.Fl c > +above, but skip files in > +.Ar checklist > +that do not exist. > .It Fl o Ar 1 | 2 > Use historic algorithms instead of the (superior) default one > (see below). > Index: md5.1 > === > RCS file: /cvs/src/bin/md5/md5.1,v > retrieving revision 1.32 > diff -u -p -r1.32 md5.1 > --- md5.1 3 Sep 2010 09:53:20 - 1.32 > +++ md5.1 23 Feb 2012 03:53:44 - > @@ -27,7 +27,7 @@ > .Sh SYNOPSIS > .Nm md5 > .Op Fl bpqrtx > -.Op Fl c Op Ar checklist ... > +.Op Fl c | Fl C Op Ar checklist ... > .Op Fl s Ar string > .Op Ar > .Sh DESCRIPTION > @@ -67,6 +67,15 @@ and an OK or FAILED for the result of th > This will validate any of the supported checksums (see > .Xr cksum 1 ) . > If no file is given, stdin is used. > +.It Xo > +.Fl C > +.Op Ar checklist ... > +.Xc > +As option > +.Fl c > +above, but skip files in > +.Ar checklist > +that do not exist. > .It Fl p > Echoes stdin to stdout and appends the > .Em MD5 > Index: md5.c > === > RCS file: /cvs/src/bin/md5/md5.c,v > retrieving revision 1.53 > diff -u -p -r1.53 md5.c > --- md5.c 5 Jul 2011 23:39:27 - 1.53 > +++ md5.c 23 Feb 2012 03:53:46 - > @@ -32,6 +32,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -191,7 +192,7 @@ TAILQ_HEAD(hash_list, hash_function); > > void digest_end(const struct hash_function *, void *, char *, size_t, int); > void digest_file(const char *, struct hash_list *, int); > -int digest_filelist(const char *, struct hash_function *); > +int digest_filelist(const char *, struct hash_function *, int); > void digest_print(const struct hash_function *, const char *, const char *); > void digest_printstr(const struct hash_function *, const char *, const char > *); > void digest_string(char *, struct hash_list