[rs-commit] r73 - in /redwax-tool/trunk: redwax-tool.c redwax-tool.h redwax_p11kit.c

rs-commit at redwax.eu rs-commit at redwax.eu
Wed Nov 24 20:28:39 CET 2021


Author: minfrin at redwax.eu
Date: Wed Nov 24 20:28:39 2021
New Revision: 73

Log:
dd a debug mode for more detail.

Modified:
    redwax-tool/trunk/redwax-tool.c
    redwax-tool/trunk/redwax-tool.h
    redwax-tool/trunk/redwax_p11kit.c

Modified: redwax-tool/trunk/redwax-tool.c
==============================================================================
--- redwax-tool/trunk/redwax-tool.c	(original)
+++ redwax-tool/trunk/redwax-tool.c	Wed Nov 24 20:28:39 2021
@@ -198,6 +198,8 @@
         "  -v, --version\t\t\tDisplay the version number." },
     { "quiet", 'q', 0,
         "  -q, --quiet\t\t\tBe quiet. Errors are suppressed." },
+    { "debug", 'd', 0,
+        "  -d, --debug\t\t\tBe loud. Print additional details of our progress." },
     { "text", 't', 0,
         "  -t, --text\t\t\tInclude text in certificate output." },
     { "secret-suffix-in", REDWAX_TOOL_SECRET_SUFFIX_IN, 1, "  --secret-suffix-in=suffix\tIf specified, secrets will be read from a file\n\t\t\t\twith the same name as the source file, and\n\t\t\t\tthe suffix specified. With value 'secret',\n\t\t\t\ta file 'key.pem' will have the secret loaded\n\t\t\t\tfrom 'key.secret' in the same directory." },
@@ -337,6 +339,22 @@
 apr_status_t redwax_print_error(redwax_tool_t *r, const char *fmt, ...)
 {
     if (!r->quiet && !r->complete) {
+
+        va_list ap;
+        char *res;
+
+        va_start(ap, fmt);
+        res = apr_pvsprintf(r->pool, fmt, ap);
+        va_end(ap);
+
+        return apr_file_puts(res, r->err);
+    }
+    return APR_SUCCESS;
+}
+
+apr_status_t redwax_print_debug(redwax_tool_t *r, const char *fmt, ...)
+{
+    if (r->debug && !r->quiet && !r->complete) {
 
         va_list ap;
         char *res;
@@ -2058,6 +2076,10 @@
             r->quiet++;
             break;
         }
+        case 'd': {
+            r->debug++;
+            break;
+        }
         }
 
     }

Modified: redwax-tool/trunk/redwax-tool.h
==============================================================================
--- redwax-tool/trunk/redwax-tool.h	(original)
+++ redwax-tool/trunk/redwax-tool.h	Wed Nov 24 20:28:39 2021
@@ -97,6 +97,7 @@
     int key_out;
     int auto_out;
     int quiet;
+    int debug;
     int complete;
     int text;
     int rc;
@@ -285,6 +286,9 @@
 apr_status_t redwax_print_error(redwax_tool_t *r, const char *fmt, ...)
         __attribute__((format(printf,2,3)));
 
+apr_status_t redwax_print_debug(redwax_tool_t *r, const char *fmt, ...)
+        __attribute__((format(printf,2,3)));
+
 apr_status_t redwax_complete_directory(redwax_tool_t *r, const char *arg,
         redwax_token_quoted_e quoted);
 apr_status_t redwax_complete_file(redwax_tool_t *r, const char *arg,

Modified: redwax-tool/trunk/redwax_p11kit.c
==============================================================================
--- redwax-tool/trunk/redwax_p11kit.c	(original)
+++ redwax-tool/trunk/redwax_p11kit.c	Wed Nov 24 20:28:39 2021
@@ -1236,7 +1236,7 @@
     ret = module->C_FindObjectsInit(session, attrs, n_attrs);
     if (ret != CKR_OK) {
 
-        redwax_print_error(r,
+        redwax_print_debug(r,
                 "pkcs11-in: could not find objects on '%s', skipping: %s\n",
                 redwax_pstrntrim(pool, (const char*) tokenInfo->label,
                         sizeof(tokenInfo->label)), pkcs11_errstr(ret));
@@ -1388,7 +1388,7 @@
                     }
                     default: {
 
-                        redwax_print_error(r, "pkcs11-in: unrecognised "
+                        redwax_print_debug(r, "pkcs11-in: unrecognised "
                                 "certificate, skipped: %s\n",
                                 cert->common.subject);
 
@@ -1403,7 +1403,7 @@
             /* 4.6.4 WTLS public key certificate objects */
             else if (CKC_WTLS == type) {
 
-                redwax_print_error(r,
+                redwax_print_debug(r,
                         "pkcs11-in: WTLS certificate found on '%s', skipping\n",
                         redwax_pstrntrim(pool, (const char*) tokenInfo->label,
                                 sizeof(tokenInfo->label)));
@@ -1413,7 +1413,7 @@
             /* all other certs */
             else {
 
-                redwax_print_error(r,
+                redwax_print_debug(r,
                         "pkcs11-in: Certificate '%s' with type %d not understood, skipping\n",
                         redwax_pstrntrim(pool, (const char*) tokenInfo->label,
                                 sizeof(tokenInfo->label)), (int)type);
@@ -1572,7 +1572,7 @@
             }
             else {
 
-                redwax_print_error(r,
+                redwax_print_debug(r,
                         "pkcs11-in: Private key type %d on '%s' not understood, skipping\n",
                         (int)type,
                         redwax_pstrntrim(pool, (const char*) tokenInfo->label,
@@ -1582,7 +1582,7 @@
         }
         else {
 
-            redwax_print_error(r,
+            redwax_print_debug(r,
                     "pkcs11-in: Object %lu found on '%s', skipping\n",
                     clazz, redwax_pstrntrim(pool, (const char*) tokenInfo->label,
                             sizeof(tokenInfo->label)));



More information about the rs-commit mailing list