Subject: Re: why doesn't NetBSD ship with md5sum or sha1sum?
To: None <netbsd-help@NetBSD.org>
From: Jukka Salmi <j+nbsd@2006.salmi.ch>
List: netbsd-help
Date: 05/07/2006 04:29:46
--ikeVEW9yuYc//A+q
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hubert Feyrer --> netbsd-help (2006-04-25 01:07:21 +0200):
[...]
> You're welcome! FWIW, I've hacked it a bit more so that the checksum file 
> is now optional, and stdin is used when no file is given. Also, for input 
> formats where the hash algorithm can be determined from, it's used 
> according to that. 
> 
> For cksum(1) -o[12] and sum(1) those tools/options still need to be 
> specified, just like when -n ("normal"?!) is used. I think those should be 
> nuked from orbit / merged in consistently.

Thanks again!

BTW, it seems that Linux's (md5|sha1)sum puts _two_ spaces between the
ckecksum and the filename, but cksum doesn't parse this correctly and
prints `FAILED'. The attached patch should fix this.


Regards, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~

--ikeVEW9yuYc//A+q
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: usr.bin/cksum/cksum.c
===================================================================
RCS file: /cvsroot/src/usr.bin/cksum/cksum.c,v
retrieving revision 1.36
diff -u -p -r1.36 cksum.c
--- usr.bin/cksum/cksum.c	5 May 2006 22:07:22 -0000	1.36
+++ usr.bin/cksum/cksum.c	7 May 2006 02:26:22 -0000
@@ -366,6 +366,7 @@ main(int argc, char **argv)
 
 			} else {
 				if (hash) {
+					int nspaces = 1;
 					/*
 					 * 'normal' output, no (ck)sum
 					 */
@@ -380,9 +381,10 @@ main(int argc, char **argv)
 						rval = 1;
 						continue;
 					}
-					p_filename++;
+					while (*++p_filename == ' ')
+						++nspaces;
 					l_filename = strlen(p_filename);
-					l_cksum = p_filename - buf - 1;
+					l_cksum = p_filename - buf - nspaces;
 				} else {
 					/*
 					 * sum/cksum output format

--ikeVEW9yuYc//A+q--