Format filemode output in a tabular fashion to improve readability
authorjob <job@openbsd.org>
Fri, 4 Nov 2022 17:39:36 +0000 (17:39 +0000)
committerjob <job@openbsd.org>
Fri, 4 Nov 2022 17:39:36 +0000 (17:39 +0000)
OK tb@ claudio@

usr.sbin/rpki-client/filemode.c
usr.sbin/rpki-client/print.c

index 2982f2d..99ac65d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: filemode.c,v 1.15 2022/11/02 12:43:02 job Exp $ */
+/*     $OpenBSD: filemode.c,v 1.16 2022/11/04 17:39:36 job Exp $ */
 /*
  * Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
  * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -300,8 +300,8 @@ proc_parser_file(char *file, unsigned char *buf, size_t len)
                printf("{\n\t\"file\": \"%s\",\n", file);
                printf("\t\"hash_id\": \"%s\",\n", hash);
        } else {
-               printf("File: %s\n", file);
-               printf("Hash identifier: %s\n", hash);
+               printf("File:                     %s\n", file);
+               printf("Hash identifier:          %s\n", hash);
        }
 
        free(hash);
index e38411a..a50b952 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: print.c,v 1.18 2022/11/04 09:43:13 job Exp $ */
+/*     $OpenBSD: print.c,v 1.19 2022/11/04 17:39:36 job Exp $ */
 /*
  * Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
  * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -101,8 +101,8 @@ tal_print(const struct tal *p)
                }
                printf("],\n");
        } else {
-               printf("Trust anchor name: %s\n", p->descr);
-               printf("Subject key identifier: %s\n", pretty_key_id(ski));
+               printf("Trust anchor name:        %s\n", p->descr);
+               printf("Subject key identifier:   %s\n", pretty_key_id(ski));
                printf("Trust anchor locations:\n");
                for (i = 0; i < p->urisz; i++)
                        printf("%5zu: %s\n", i + 1, p->uri[i]);
@@ -134,7 +134,7 @@ x509_print(const X509 *x)
        if (outformats & FORMAT_JSON) {
                printf("\t\"cert_serial\": \"%s\",\n", serial);
        } else {
-               printf("Certificate serial: %s\n", serial);
+               printf("Certificate serial:       %s\n", serial);
        }
 
  out:
@@ -173,13 +173,13 @@ cert_print(const struct cert *p)
                printf("\t\"valid_until\": %lld,\n", (long long)p->expires);
                printf("\t\"subordinate_resources\": [\n");
        } else {
-               printf("Subject key identifier: %s\n", pretty_key_id(p->ski));
+               printf("Subject key identifier:   %s\n", pretty_key_id(p->ski));
                if (p->aki != NULL)
                        printf("Authority key identifier: %s\n",
                            pretty_key_id(p->aki));
                x509_print(p->x509);
                if (p->aia != NULL)
-                       printf("Authority info access: %s\n", p->aia);
+                       printf("Authority info access:    %s\n", p->aia);
                if (p->mft != NULL)
                        printf("Manifest: %s\n", p->mft);
                if (p->repo != NULL)
@@ -187,9 +187,9 @@ cert_print(const struct cert *p)
                if (p->notify != NULL)
                        printf("Notify URL: %s\n", p->notify);
                if (p->pubkey != NULL)
-                       printf("BGPsec P-256 ECDSA public key: %s\n",
+                       printf("BGPsec ECDSA public key:  %s\n",
                            p->pubkey);
-               printf("Valid until: %s\n", tbuf);
+               printf("Router key valid until:   %s\n", tbuf);
                printf("Subordinate Resources:\n");
        }
 
@@ -284,7 +284,7 @@ crl_print(const struct crl *p)
                if (outformats & FORMAT_JSON)
                        printf("\t\"crl_serial\": \"%s\",\n", serial);
                else
-                       printf("CRL Serial Number: %s\n", serial);
+                       printf("CRL Serial Number:        %s\n", serial);
        }
        free(serial);
        ASN1_INTEGER_free(crlnum);
@@ -294,8 +294,8 @@ crl_print(const struct crl *p)
                printf("\t\"valid_until\": %lld,\n", (long long)p->expires);
                printf("\t\"revoked_certs\": [\n");
        } else {
-               printf("CRL valid since: %s\n", time2str(p->issued));
-               printf("CRL valid until: %s\n", time2str(p->expires));
+               printf("CRL valid since:          %s\n", time2str(p->issued));
+               printf("CRL valid until:          %s\n", time2str(p->expires));
                printf("Revoked Certificates:\n");
        }
 
@@ -342,14 +342,15 @@ mft_print(const X509 *x, const struct mft *p)
                printf("\t\"valid_since\": %lld,\n", (long long)p->valid_since);
                printf("\t\"valid_until\": %lld,\n", (long long)p->valid_until);
        } else {
-               printf("Subject key identifier: %s\n", pretty_key_id(p->ski));
+               printf("Subject key identifier:   %s\n", pretty_key_id(p->ski));
                printf("Authority key identifier: %s\n", pretty_key_id(p->aki));
                x509_print(x);
-               printf("Authority info access: %s\n", p->aia);
-               printf("Subject info access: %s\n", p->sia);
-               printf("Manifest Number: %s\n", p->seqnum);
-               printf("Manifest valid since: %s\n", time2str(p->valid_since));
-               printf("Manifest valid until: %s\n", time2str(p->valid_until));
+               printf("Authority info access:    %s\n", p->aia);
+               printf("Subject info access:      %s\n", p->sia);
+               printf("Manifest Number:          %s\n", p->seqnum);
+               printf("Manifest valid since:     %s\n", time2str(p->valid_since));
+               printf("Manifest valid until:     %s\n", time2str(p->valid_until));
+               printf("Files and hashes:\n");
        }
 
        for (i = 0; i < p->filesz; i++) {
@@ -393,13 +394,13 @@ roa_print(const X509 *x, const struct roa *p)
                printf("\t\"sia\": \"%s\",\n", p->sia);
                printf("\t\"valid_until\": %lld,\n", (long long)p->expires);
        } else {
-               printf("Subject key identifier: %s\n", pretty_key_id(p->ski));
+               printf("Subject key identifier:   %s\n", pretty_key_id(p->ski));
                x509_print(x);
                printf("Authority key identifier: %s\n", pretty_key_id(p->aki));
-               printf("Authority info access: %s\n", p->aia);
-               printf("Subject info access: %s\n", p->sia);
-               printf("ROA valid until: %s\n", time2str(p->expires));
-               printf("asID: %u\n", p->asid);
+               printf("Authority info access:    %s\n", p->aia);
+               printf("Subject info access:      %s\n", p->sia);
+               printf("ROA valid until:          %s\n", time2str(p->expires));
+               printf("asID:                     %u\n", p->asid);
                printf("IP address blocks:\n");
        }
 
@@ -451,11 +452,11 @@ gbr_print(const X509 *x, const struct gbr *p)
                }
                printf("\",\n");
        } else {
-               printf("Subject key identifier: %s\n", pretty_key_id(p->ski));
+               printf("Subject key identifier:   %s\n", pretty_key_id(p->ski));
                x509_print(x);
                printf("Authority key identifier: %s\n", pretty_key_id(p->aki));
-               printf("Authority info access: %s\n", p->aia);
-               printf("Subject info access: %s\n", p->sia);
+               printf("Authority info access:    %s\n", p->aia);
+               printf("Subject info access:      %s\n", p->sia);
                printf("vcard:\n%s", p->vcard);
        }
 }
@@ -478,11 +479,11 @@ rsc_print(const X509 *x, const struct rsc *p)
                printf("\t\"valid_until\": %lld,\n", (long long)p->expires);
                printf("\t\"signed_with_resources\": [\n");
        } else {
-               printf("Subject key identifier: %s\n", pretty_key_id(p->ski));
+               printf("Subject key identifier:   %s\n", pretty_key_id(p->ski));
                printf("Authority key identifier: %s\n", pretty_key_id(p->aki));
                x509_print(x);
-               printf("Authority info access: %s\n", p->aia);
-               printf("Valid until: %s\n", tbuf);
+               printf("Authority info access:    %s\n", p->aia);
+               printf("Valid until:              %s\n", tbuf);
                printf("Signed with resources:\n");
        }
 
@@ -603,12 +604,12 @@ aspa_print(const X509 *x, const struct aspa *p)
                }
                printf("\t],\n");
        } else {
-               printf("Subject key identifier: %s\n", pretty_key_id(p->ski));
+               printf("Subject key identifier:   %s\n", pretty_key_id(p->ski));
                x509_print(x);
                printf("Authority key identifier: %s\n", pretty_key_id(p->aki));
-               printf("Authority info access: %s\n", p->aia);
-               printf("Subject info access: %s\n", p->sia);
-               printf("Customer AS: %u\n", p->custasid);
+               printf("Authority info access:    %s\n", p->aia);
+               printf("Subject info access:      %s\n", p->sia);
+               printf("Customer AS:              %u\n", p->custasid);
                printf("Provider Set:\n");
                for (i = 0; i < p->providersz; i++) {
                        printf("%5zu: AS: %d", i + 1, p->providers[i].as);
@@ -695,12 +696,12 @@ tak_print(const X509 *x, const struct tak *p)
                printf("\t\"takeys\": [\n");
        } else {
                strftime(tbuf, sizeof(tbuf), "%FT%TZ", gmtime(&p->expires));
-               printf("Subject key identifier: %s\n", pretty_key_id(p->ski));
+               printf("Subject key identifier:   %s\n", pretty_key_id(p->ski));
                x509_print(x);
                printf("Authority key identifier: %s\n", pretty_key_id(p->aki));
-               printf("Authority info access: %s\n", p->aia);
-               printf("Subject info access: %s\n", p->sia);
-               printf("TAK EE certificate valid until: %s\n", tbuf);
+               printf("Authority info access:    %s\n", p->aia);
+               printf("Subject info access:      %s\n", p->sia);
+               printf("TAK valid until:          %s\n", tbuf);
        }
 
        takey_print("current", p->current);