Re: [PATCH] usr.sbin/rpki-client: remove -f (force) option

2020-06-30 Thread Klemens Nanni
OK kn with the manual's synopsis (`man -h rpki-client') updated as well.



Re: [PATCH] usr.sbin/rpki-client: remove -f (force) option

2020-06-30 Thread Claudio Jeker
On Tue, Jun 30, 2020 at 10:33:21AM +, Job Snijders wrote:
> Remove rpki-client's -f command line option
> 
> I haven't come across a use case that requires tricking the software
> into accepting out-of-date manifests. Anyone using -f? I think this is a
> leftover from the initial debugging era.
> 
> OK?

Agreed. I think the last time I used this was in Elk Lakes during
development. I would not encurage anyone to use -f in production.
OK claudio@

 
> Index: extern.h
> ===
> RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v
> retrieving revision 1.30
> diff -u -p -r1.30 extern.h
> --- extern.h  24 Jun 2020 14:39:21 -  1.30
> +++ extern.h  30 Jun 2020 10:21:04 -
> @@ -289,7 +289,7 @@ struct cert   *cert_read(int);
>  
>  void  mft_buffer(char **, size_t *, size_t *, const struct mft *);
>  void  mft_free(struct mft *);
> -struct mft   *mft_parse(X509 **, const char *, int);
> +struct mft   *mft_parse(X509 **, const char *);
>  int   mft_check(const char *, struct mft *);
>  struct mft   *mft_read(int);
>  
> Index: main.c
> ===
> RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v
> retrieving revision 1.71
> diff -u -p -r1.71 main.c
> --- main.c24 Jun 2020 14:39:21 -  1.71
> +++ main.c30 Jun 2020 10:21:05 -
> @@ -148,7 +148,7 @@ struct filepath_tree  fpt = RB_INITIALIZ
>  /*
>   * Mark that our subprocesses will never return.
>   */
> -static void  proc_parser(int, int) __attribute__((noreturn));
> +static void  proc_parser(int) __attribute__((noreturn));
>  static void  proc_rsync(char *, char *, int, int)
>   __attribute__((noreturn));
>  static void  build_chain(const struct auth *, STACK_OF(X509) **);
> @@ -892,8 +892,8 @@ proc_parser_roa(struct entity *entp,
>   * Return the mft on success or NULL on failure.
>   */
>  static struct mft *
> -proc_parser_mft(struct entity *entp, int force, X509_STORE *store,
> -X509_STORE_CTX *ctx, struct auth_tree *auths, struct crl_tree *crlt)
> +proc_parser_mft(struct entity *entp, X509_STORE *store, X509_STORE_CTX *ctx,
> + struct auth_tree *auths, struct crl_tree *crlt)
>  {
>   struct mft  *mft;
>   X509*x509;
> @@ -902,7 +902,7 @@ proc_parser_mft(struct entity *entp, int
>   STACK_OF(X509)  *chain;
>  
>   assert(!entp->has_dgst);
> - if ((mft = mft_parse(, entp->uri, force)) == NULL)
> + if ((mft = mft_parse(, entp->uri)) == NULL)
>   return NULL;
>  
>   a = valid_ski_aki(entp->uri, auths, mft->ski, mft->aki);
> @@ -1127,7 +1127,7 @@ build_crls(const struct auth *a, struct 
>   * The process will exit cleanly only when fd is closed.
>   */
>  static void
> -proc_parser(int fd, int force)
> +proc_parser(int fd)
>  {
>   struct tal  *tal;
>   struct cert *cert;
> @@ -1249,8 +1249,7 @@ proc_parser(int fd, int force)
>*/
>   break;
>   case RTYPE_MFT:
> - mft = proc_parser_mft(entp, force,
> - store, ctx, , );
> + mft = proc_parser_mft(entp, store, ctx, , );
>   c = (mft != NULL);
>   io_simple_buffer(, , , , sizeof(int));
>   if (mft != NULL)
> @@ -1500,8 +1499,7 @@ int
>  main(int argc, char *argv[])
>  {
>   int  rc = 1, c, proc, st, rsync,
> -  fl = SOCK_STREAM | SOCK_CLOEXEC, noop = 0,
> -  force = 0;
> +  fl = SOCK_STREAM | SOCK_CLOEXEC, noop = 0;
>   size_t   i, j, eid = 1, outsz = 0, talsz = 0;
>   pid_tprocpid, rsyncpid;
>   int  fd[2];
> @@ -1539,7 +1537,7 @@ main(int argc, char *argv[])
>   if (pledge("stdio rpath wpath cpath fattr proc exec unveil", NULL) == 
> -1)
>   err(1, "pledge");
>  
> - while ((c = getopt(argc, argv, "b:Bcd:e:fjnot:T:v")) != -1)
> + while ((c = getopt(argc, argv, "b:Bcd:e:jnot:T:v")) != -1)
>   switch (c) {
>   case 'b':
>   bind_addr = optarg;
> @@ -1556,9 +1554,6 @@ main(int argc, char *argv[])
>   case 'e':
>   rsync_prog = optarg;
>   break;
> - case 'f':
> - force = 1;
> - break;
>   case 'j':
>   outformats |= FORMAT_JSON;
>   break;
> @@ -1634,7 +1629,7 @@ main(int argc, char *argv[])
>   err(1, "%s: unveil", cachedir);
>   if (pledge("stdio rpath", NULL) == -1)
>   err(1, "pledge");
> - proc_parser(fd[0], force);
> + proc_parser(fd[0]);
>   /* NOTREACHED */
>   }
>  
> @@ -1826,7 +1821,7 @@ main(int argc, char 

[PATCH] usr.sbin/rpki-client: remove -f (force) option

2020-06-30 Thread Job Snijders
Remove rpki-client's -f command line option

I haven't come across a use case that requires tricking the software
into accepting out-of-date manifests. Anyone using -f? I think this is a
leftover from the initial debugging era.

OK?

Index: extern.h
===
RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v
retrieving revision 1.30
diff -u -p -r1.30 extern.h
--- extern.h24 Jun 2020 14:39:21 -  1.30
+++ extern.h30 Jun 2020 10:21:04 -
@@ -289,7 +289,7 @@ struct cert *cert_read(int);
 
 voidmft_buffer(char **, size_t *, size_t *, const struct mft *);
 voidmft_free(struct mft *);
-struct mft *mft_parse(X509 **, const char *, int);
+struct mft *mft_parse(X509 **, const char *);
 int mft_check(const char *, struct mft *);
 struct mft *mft_read(int);
 
Index: main.c
===
RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v
retrieving revision 1.71
diff -u -p -r1.71 main.c
--- main.c  24 Jun 2020 14:39:21 -  1.71
+++ main.c  30 Jun 2020 10:21:05 -
@@ -148,7 +148,7 @@ struct filepath_tree  fpt = RB_INITIALIZ
 /*
  * Mark that our subprocesses will never return.
  */
-static voidproc_parser(int, int) __attribute__((noreturn));
+static voidproc_parser(int) __attribute__((noreturn));
 static voidproc_rsync(char *, char *, int, int)
__attribute__((noreturn));
 static voidbuild_chain(const struct auth *, STACK_OF(X509) **);
@@ -892,8 +892,8 @@ proc_parser_roa(struct entity *entp,
  * Return the mft on success or NULL on failure.
  */
 static struct mft *
-proc_parser_mft(struct entity *entp, int force, X509_STORE *store,
-X509_STORE_CTX *ctx, struct auth_tree *auths, struct crl_tree *crlt)
+proc_parser_mft(struct entity *entp, X509_STORE *store, X509_STORE_CTX *ctx,
+   struct auth_tree *auths, struct crl_tree *crlt)
 {
struct mft  *mft;
X509*x509;
@@ -902,7 +902,7 @@ proc_parser_mft(struct entity *entp, int
STACK_OF(X509)  *chain;
 
assert(!entp->has_dgst);
-   if ((mft = mft_parse(, entp->uri, force)) == NULL)
+   if ((mft = mft_parse(, entp->uri)) == NULL)
return NULL;
 
a = valid_ski_aki(entp->uri, auths, mft->ski, mft->aki);
@@ -1127,7 +1127,7 @@ build_crls(const struct auth *a, struct 
  * The process will exit cleanly only when fd is closed.
  */
 static void
-proc_parser(int fd, int force)
+proc_parser(int fd)
 {
struct tal  *tal;
struct cert *cert;
@@ -1249,8 +1249,7 @@ proc_parser(int fd, int force)
 */
break;
case RTYPE_MFT:
-   mft = proc_parser_mft(entp, force,
-   store, ctx, , );
+   mft = proc_parser_mft(entp, store, ctx, , );
c = (mft != NULL);
io_simple_buffer(, , , , sizeof(int));
if (mft != NULL)
@@ -1500,8 +1499,7 @@ int
 main(int argc, char *argv[])
 {
int  rc = 1, c, proc, st, rsync,
-fl = SOCK_STREAM | SOCK_CLOEXEC, noop = 0,
-force = 0;
+fl = SOCK_STREAM | SOCK_CLOEXEC, noop = 0;
size_t   i, j, eid = 1, outsz = 0, talsz = 0;
pid_tprocpid, rsyncpid;
int  fd[2];
@@ -1539,7 +1537,7 @@ main(int argc, char *argv[])
if (pledge("stdio rpath wpath cpath fattr proc exec unveil", NULL) == 
-1)
err(1, "pledge");
 
-   while ((c = getopt(argc, argv, "b:Bcd:e:fjnot:T:v")) != -1)
+   while ((c = getopt(argc, argv, "b:Bcd:e:jnot:T:v")) != -1)
switch (c) {
case 'b':
bind_addr = optarg;
@@ -1556,9 +1554,6 @@ main(int argc, char *argv[])
case 'e':
rsync_prog = optarg;
break;
-   case 'f':
-   force = 1;
-   break;
case 'j':
outformats |= FORMAT_JSON;
break;
@@ -1634,7 +1629,7 @@ main(int argc, char *argv[])
err(1, "%s: unveil", cachedir);
if (pledge("stdio rpath", NULL) == -1)
err(1, "pledge");
-   proc_parser(fd[0], force);
+   proc_parser(fd[0]);
/* NOTREACHED */
}
 
@@ -1826,7 +1821,7 @@ main(int argc, char *argv[])
 
 usage:
fprintf(stderr,
-   "usage: rpki-client [-Bcfjnov] [-b sourceaddr] [-d cachedir]"
+   "usage: rpki-client [-Bcjnov] [-b sourceaddr] [-d cachedir]"
" [-e rsync_prog]\n"
"   [-T table] [-t tal] [outputdir]\n");
return 1;
Index: mft.c