On Thu, Jan 13, 2022 at 02:24:59PM +0100, Theo Buehler wrote: > On Thu, Jan 13, 2022 at 02:16:02PM +0100, Claudio Jeker wrote: > > Right now a file can only exist in one place in the rpki-client cache. > > This will change when we split valid data to its own repo. > > > > One step to get closer to that is to alter valid_filehash() to take an > > open filedescriptor instead of using open(2) itself. This allows the > > callers to decide which file to pass. valid_filehash() handles fd == -1 > > and so the open call does not need to be checked for error. > > > > Additionally move mft_check() from mft.c to parser.c. It simplifies later > > work. > > > > ok > > > Index: validate.c > > =================================================================== > > RCS file: /cvs/src/usr.sbin/rpki-client/validate.c,v > > retrieving revision 1.23 > > diff -u -p -r1.23 validate.c > > --- validate.c 26 Dec 2021 12:32:28 -0000 1.23 > > +++ validate.c 13 Jan 2022 12:07:54 -0000 > > @@ -269,29 +269,29 @@ valid_filename(const char *fn) > > > > /* > > * Validate a file by verifying the SHA256 hash of that file. > > - * Returns 1 if valid, 0 otherwise. > > + * The file is passed a an open filedescriptor fd which can be -1. > > missing s: passed as > and "file descriptor" should be two words > (also: -1 can't be an open fd, but I guess it's clear what is meant) >
I simplified the comment a bit. The function is easy enough to understand. /* * Validate a file by verifying the SHA256 hash of that file. * The file to check is passed as a filedescriptor. * Returns 1 if hash matched, 0 otherwise. Closes fd when done. */ -- :wq Claudio