]> git.proxmox.com Git - swtpm.git/commitdiff
swtpm: Add option to only display version info
authorStefan Berger <stefanb@us.ibm.com>
Fri, 4 Dec 2015 12:31:55 +0000 (07:31 -0500)
committerStefan Berger <stefanb@us.ibm.com>
Fri, 4 Dec 2015 12:32:53 +0000 (07:32 -0500)
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
src/swtpm_bios/tpm_bios.c
src/swtpm_cert/ek-cert.c
src/swtpm_ioctl/tpm_ioctl.c
src/swtpm_setup/swtpm_setup.c
src/swtpm_setup/swtpm_setup.sh.in

index f48f8a33a45442e5b6d3620fdc7281c044d1b5aa..9c1771794948f1227e07bcd5dfba45cfa3b191ce 100644 (file)
@@ -205,10 +205,17 @@ static int TPM_ContinueSelfTest(int *tpm_errcode)
        return talk(tpm_cst, sizeof(tpm_cst), tpm_errcode);
 }
 
+static void versioninfo(void)
+{
+        printf(
+"TPM emulator BIOS emulator version %d.%d.%d, Copyright (c) 2015 IBM Corp.\n"
+,SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO);
+}
+
 static void print_usage(const char *prgname)
 {
+        versioninfo();
        printf(
-"TPM emulator BIOS emulator version %d.%d.%d, Copyright (c) 2015 IBM Corp.\n"
 "\n"
 "%s [options]\n"
 "\n"
@@ -220,9 +227,10 @@ static void print_usage(const char *prgname)
 "\t-d  startup deactivate\n"
 "\t-n  no startup\n"
 "\t-o  startup only\n"
-"\t-cs run TPM_ContinueSelfTest\n",
-SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO, prgname);
-       return;
+"\t-cs run TPM_ContinueSelfTest\n"
+"\t-v  display version and exit\n"
+"\t-h  display this help screen and exit\n"
+, prgname);
 }
 
 int main(int argc, char *argv[])
@@ -246,6 +254,9 @@ int main(int argc, char *argv[])
                } else if (strcmp(argv[i],"-h") == 0) {
                        print_usage(argv[0]);
                        exit(EXIT_SUCCESS);
+               } else if (strcmp(argv[i],"-v") == 0) {
+                       versioninfo();
+                       exit(EXIT_SUCCESS);
                } else if (strcmp(argv[i],"-n") == 0) {
                        startupparm = 0xff;
                        do_more = 1;
index 11f1a71635ed8bd9f06a289856a031451cb9409f..b401667d7bfa02d2c1a5a0ddbe192c23e0b811a4 100644 (file)
@@ -68,12 +68,19 @@ extern const ASN1_ARRAY_TYPE tpm_asn1_tab[];
 ASN1_TYPE _tpm_asn;
 
 static void
-usage(const char *prg)
+versioninfo(const char *prg)
 {
     fprintf(stdout,
         "TPM certificate tool version %d.%d.%d, Copyright (c) 2015 IBM Corp.\n"
-        "\n"
-        "Usage: %s [options]\n"
+        ,SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO);
+}
+
+static void
+usage(const char *prg)
+{
+    versioninfo(prg);
+    fprintf(stdout,
+        "\nUsage: %s [options]\n"
         "\n"
         "Create TPM certificates without requiring the EK private key.\n"
         "\n"
@@ -97,9 +104,10 @@ usage(const char *prg)
         "--platform-version <version>   : The Platform version (firmware version)\n"
         "--subject <subject>       : Subject such as location in format\n"
         "                            C=US,ST=NY,L=NewYork\n"
+        "--version                 : Display version and exit\n"
         "--help                    : Display this help screen and exit\n"
         "\n",
-        SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO, prg);
+        prg);
 }
 
 static char
@@ -583,6 +591,9 @@ main(int argc, char *argv[])
             platf_version = argv[i];
         } else if (!strcmp(argv[i], "--pem")) {
             write_pem = true;
+        } else if (!strcmp(argv[i], "--version")) {
+            versioninfo(argv[0]);
+            exit(0);
         } else if (!strcmp(argv[i], "--help")) {
             usage(argv[0]);
             exit(0);
index e1b39d18669e49d507da2234a4fdc9039a917edf..03028414d0cc405519f7de4d50658fc0f41e85c3 100644 (file)
@@ -447,10 +447,17 @@ static int do_load_state_blob(int fd, const char *blobtype,
     return 0;
 }
 
-static void usage(const char *prgname)
+static void versioninfo(const char *prgname)
 {
     fprintf(stdout,
 "TPM emulator control tool version %d.%d.%d, Copyright (c) 2015 IBM Corp.\n"
+,SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO);
+}
+
+static void usage(const char *prgname)
+{
+    versioninfo(prgname);
+    fprintf(stdout,
 "\n"
 "Usage: %s command <device path>\n"
 "\n"
@@ -472,8 +479,10 @@ static void usage(const char *prgname)
 "--load <type> <file> : load the TPM state blob of given type from a file;\n"
 "                       type may be one of volatile, permanent, or savestate\n"
 "-g       : get configuration flags indicating which keys are in use\n"
+"--version: display version and exit\n"
+"-h|--help: display help screen and exit\n"
 "\n"
-,SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO, prgname);
+, prgname);
 }
 
 int main(int argc, char *argv[])
@@ -496,6 +505,14 @@ int main(int argc, char *argv[])
         return 1;
     }
 
+    if (!strcmp(argv[1], "--version")) {
+        versioninfo(argv[0]);
+        exit(0);
+    } else if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
+        usage(argv[0]);
+        exit(0);
+    }
+
     if (!strcmp(argv[1], "--save") ||
         !strcmp(argv[1], "--load")) {
         devindex = 4;
index e0370b1670e839970310a14c135c94d5f808a2a9..ae723fb92d92fdd68542edda2228bdb056f2360e 100755 (executable)
@@ -88,6 +88,8 @@ int main(int argc, char *argv[])
             userid = argv[i];
         } else if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) {
             show_help = true;
+        } else if (!strcmp("--version", argv[i])) {
+            show_help = true;
         }
         for (j = 0; one_arg_params[j] != NULL; j++) {
             if (!strcmp(one_arg_params[j], argv[i])) {
index 371619f6b68732d003e47648882369753e844ccc..e821482730ca5c5ea4f1ef1adeeb79b7b778a570 100755 (executable)
@@ -589,10 +589,17 @@ init_tpm()
        return 0
 }
 
-usage()
+versioninfo()
 {
        cat <<EOF
 TPM emulator setup tool version @SWTPM_VER_MAJOR@.@SWTPM_VER_MINOR@.@SWTPM_VER_MICRO@
+EOF
+}
+
+usage()
+{
+       versioninfo
+       cat <<EOF
 
 Usage: $1 [options]
 
@@ -650,6 +657,8 @@ The following options are supported:
                    This parameter will be passed to the TPM using
                    '--key pwdfile=<file>'.
 
+--verion         : Display version and exit
+
 --help,-h,-?     : Display this help screen
 EOF
 }
@@ -686,6 +695,7 @@ main()
                --pwdfile) shift; pwdfile="$1";;
                --runas) shift;; # ignore here
                --logfile) shift; LOGFILE="$1";;
+               --version) versioninfo $0; exit 0;;
                --help|-h|-?) usage $0; exit 0;;
                *) logerr "Unknown option $1"; usage $0; exit 1;;
                esac