Skip to content

Commit

Permalink
testing: Add some debugging output into swtpm_ioctl's -h path
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanberger committed Jan 18, 2020
1 parent 930c7ba commit 7aff893
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/swtpm_ioctl/tpm_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,10 @@ int main(int argc, char *argv[])
goto exit;
}

if (command && !strcmp(command, "-h")) {
fprintf(stderr, "%s @ %d\n", __func__, __LINE__);
}

if (!tpm_device && !tcp_hostname && !unix_path) {
if (optind == argc) {
fprintf(stderr, "Error: Missing device name.\n");
Expand All @@ -995,6 +999,10 @@ int main(int argc, char *argv[])
}
}

if (command && !strcmp(command, "-h")) {
fprintf(stderr, "%s @ %d\n", __func__, __LINE__);
}

is_chardev = (tpm_device != NULL);
if (is_chardev) {
tmp = getenv("SWTPM_IOCTL_BUFFERSIZE");
Expand All @@ -1004,11 +1012,20 @@ int main(int argc, char *argv[])
}
}

if (command && !strcmp(command, "-h")) {
fprintf(stderr, "%s @ %d\n", __func__, __LINE__);
}

fd = open_connection(tpm_device, tcp_hostname, tcp_port, unix_path);
if (fd < 0) {
fprintf(stderr, "Could not create connection\n");
goto exit;
}

if (command && !strcmp(command, "-h")) {
fprintf(stderr, "%s @ %d\n", __func__, __LINE__);
}

if (!strcmp(command, "-c")) {
n = ctrlcmd(fd, PTM_GET_CAPABILITY, &cap, 0, sizeof(cap));
if (n < 0) {
Expand Down Expand Up @@ -1122,10 +1139,12 @@ int main(int argc, char *argv[])
}

} else if (!strcmp(command, "-h")) {
fprintf(stderr, "hashing now!\n");
if (do_hash_start_data_end(fd, is_chardev, hashdata)) {
fprintf(stderr, "hashing failed\n");
goto exit;
}

fprintf(stderr, "hashing succeeded\n");
} else if (!strcmp(command, "-C")) {
n = ctrlcmd(fd, PTM_CANCEL_TPM_CMD, &res, 0, sizeof(res));
if (n < 0) {
Expand Down Expand Up @@ -1231,5 +1250,10 @@ int main(int argc, char *argv[])

exit:
free(tcp_hostname);

if (command && !strcmp(command, "-h")) {
fprintf(stderr, "Exiting with ret=%d\n", ret);
}

return ret;
}

0 comments on commit 7aff893

Please sign in to comment.