]> git.proxmox.com Git - swtpm.git/commitdiff
swtpm: Expose logging level to command line
authorStefan Berger <stefanb@us.ibm.com>
Mon, 23 Jan 2017 23:18:59 +0000 (18:18 -0500)
committerStefan Berger <stefanb@us.ibm.com>
Tue, 24 Jan 2017 00:09:50 +0000 (19:09 -0500)
Expose the logging level to the command line by extending the
log option with a level parameter.
Extend the man swtpm man page with the level parameter.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
man/man8/swtpm.8
man/man8/swtpm.pod
src/swtpm/common.c
src/swtpm/swtpm.c
src/swtpm/swtpm_chardev.c

index 0b6333d5cca731067a73892ebdc3213d21f6fc33..b42ed8e8fb56871b27bbdbdeb9b84cedbf313380 100644 (file)
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29)
+.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
 .\" ========================================================================
 .\"
 .IX Title "swtpm 8"
-.TH swtpm 8 "2017-01-13" "swtpm" ""
+.TH swtpm 8 "2017-01-23" "swtpm" ""
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -278,10 +278,13 @@ The following options are support by all interfaces:
 .IP "\fB\-\-tpmstate dir=<dir>\fR" 4
 .IX Item "--tpmstate dir=<dir>"
 Use the given path rather than using the environment variable \s-1TPM_PATH.\s0
-.IP "\fB\-\-log fd=<fd>|file=<path>\fR" 4
-.IX Item "--log fd=<fd>|file=<path>"
+.IP "\fB\-\-log [fd=<fd>|file=<path>\fR][,level=n]" 4
+.IX Item "--log [fd=<fd>|file=<path>][,level=n]"
 Enable logging to a file given its file descriptor or its path. Use '\-' for path to
 suppress the logging.
+.Sp
+The level parameter allows to choose the level of logging. Starting at log
+level 5, libtpms debug logging is activated.
 .IP "\fB\-\-key file=<keyfile>[,format=<hex|binary>][,mode=aes\-cbc],[remove[=true|false]]\fR" 4
 .IX Item "--key file=<keyfile>[,format=<hex|binary>][,mode=aes-cbc],[remove[=true|false]]"
 Enable encryption of the state files of the \s-1TPM.\s0 The keyfile must contain
index 5768e49ca6f7cbd6fb838ff363e4ffc9fd340fe1..5af310f4903071c13a64d2112cd3f2e9a0505630 100644 (file)
@@ -184,11 +184,14 @@ The following options are support by all interfaces:
 
 Use the given path rather than using the environment variable TPM_PATH.
 
-=item B<--log fd=E<lt>fdE<gt>|file=E<lt>pathE<gt>>
+=item B<--log [fd=E<lt>fdE<gt>|file=E<lt>pathE<gt>>][,level=n]
 
 Enable logging to a file given its file descriptor or its path. Use '-' for path to
 suppress the logging.
 
+The level parameter allows to choose the level of logging. Starting at log
+level 5, libtpms debug logging is activated.
+
 =item B<--key file=E<lt>keyfileE<gt>[,format=E<lt>hex|binaryE<gt>][,mode=aes-cbc],[remove[=true|false]]>
 
 Enable encryption of the state files of the TPM. The keyfile must contain
index 019930e93a64760e458c8b369f16d4345f9038e8..da619cb80d6ee784ee73c6f1f14e4fed4ce2b756 100644 (file)
@@ -71,6 +71,9 @@ static const OptionDesc logging_opt_desc[] = {
     }, {
         .name = "fd",
         .type = OPT_TYPE_INT,
+    }, {
+        .name = "level",
+        .type = OPT_TYPE_UINT,
     },
     END_OPTION_DESC
 };
@@ -176,6 +179,7 @@ handle_log_options(char *options)
     char *error = NULL;
     const char *logfile = NULL;
     int logfd;
+    unsigned int loglevel;
     OptionValues *ovs = NULL;
 
     if (!options)
@@ -189,6 +193,7 @@ handle_log_options(char *options)
     }
     logfile = option_get_string(ovs, "file", NULL);
     logfd = option_get_int(ovs, "fd", -1);
+    loglevel = option_get_uint(ovs, "level", 0);
     if (logfile && (log_init(logfile) < 0)) {
         fprintf(stderr,
             "Could not open logfile for writing: %s\n",
@@ -200,6 +205,7 @@ handle_log_options(char *options)
                 logfd, strerror(errno));
         goto error;
     }
+    log_set_level(loglevel);
 
     option_values_free(ovs);
 
index 8bdb120615863511c4a160725ba861ab18f00477..50a5ae55bb925474ebeb0f0332c223eb106cae05 100644 (file)
@@ -104,9 +104,10 @@ static void usage(FILE *file, const char *prgname, const char *iface)
     "                   be given in case the type is TCP; the TCP socket is bound\n"
     "                   to 127.0.0.1 by default and other bind addresses can be\n"
     "                   given with the bindaddr parameter\n"
-    "--log file=<path>|fd=<filedescriptor>\n"
+    "--log file=<path>|fd=<filedescriptor>[,level=n]\n"
     "                 : write the TPM's log into the given file rather than\n"
     "                   to the console; provide '-' for path to avoid logging\n"
+    "                   log level 5 and higher will enable libtpms logging\n"
     "--key file=<path>[,mode=aes-cbc][,format=hex|binary][,remove=[true|false]]\n"
     "                 : use an AES key for the encryption of the TPM's state\n"
     "                   files; use the given mode for the block encryption;\n"
index 82c2353a3df512b95dd3c23adc757c179a98c093..779eca2db294953289bd12aebfd3bbe1cd146e45 100644 (file)
@@ -132,9 +132,10 @@ static void usage(FILE *file, const char *prgname, const char *iface)
     "                   be given in case the type is TCP; the TCP socket is bound\n"
     "                   to 127.0.0.1 by default and other bind addresses can be\n"
     "                   given with the bindaddr parameter\n"
-    "--log file=<path>|fd=<filedescriptor>\n"
+    "--log file=<path>|fd=<filedescriptor>[,level=n]\n"
     "                 : write the TPM's log into the given file rather than\n"
     "                   to the console; provide '-' for path to avoid logging\n"
+    "                   log level 5 and higher will enable libtpms logging\n"
     "--key file=<path>[,mode=aes-cbc][,format=hex|binary][,remove=[true|false]]\n"
     "                 : use an AES key for the encryption of the TPM's state\n"
     "                   files; use the given mode for the block encryption;\n"