-.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29)
+.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.31)
.\"
.\" Standard preamble:
.\" ========================================================================
.\" ========================================================================
.\"
.IX Title "swtpm_bios 8"
-.TH swtpm_bios 8 "2016-04-15" "swtpm" ""
+.TH swtpm_bios 8 "2016-04-18" "swtpm" ""
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.IX Item "--tpm-device <device>"
Use the given device rather than the default /dev/tpm0. This option overrides
the \s-1TPM_DEVICE\s0 environment variable.
+.IP "\fB\-\-tcp <server>:<port>\fR" 4
+.IX Item "--tcp <server>:<port>"
+Connect to the given server and port; if no server is given, 127.0.0.1 is used;
+if port is not given, the default port 6545 is used.
+.IP "\fB\-\-unixio <path>\fR" 4
+.IX Item "--unixio <path>"
+Connect to the given UnixIO path.
.IP "\fB\-c\fR" 4
.IX Item "-c"
Send TPM_Startup(\s-1ST_CLEAR\s0) (default). This instructs the \s-1TPM\s0 to start
static char *tcp_hostname;
static int tcp_port = DEFAULT_TCP_PORT;
+static char *unix_path;
+
static int parse_tcp_optarg(char *optarg, char **tcp_hostname, int *tcp_port)
{
char *pos = strchr(optarg, ':');
}
static int open_connection(char *devname, char *tcp_device_hostname,
- int tcp_device_port)
+ int tcp_device_port, const char *unix_path)
{
int fd = -1;
char *tcp_device_port_string = NULL;
if (tcp_device_hostname)
goto use_tcp;
+ if (unix_path) {
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd > 0) {
+ struct sockaddr_un addr;
+
+ if (strlen(unix_path) + 1 > sizeof(addr.sun_path)) {
+ fprintf(stderr, "Socket path is too long.\n");
+ return -1;
+ }
+
+ addr.sun_family = AF_UNIX;
+ strcpy(addr.sun_path, unix_path);
+
+ if (connect(fd,
+ (struct sockaddr*)&addr, sizeof(addr)) < 0) {
+ close(fd);
+ fd = -1;
+ }
+ }
+
+ if (fd < 0) {
+ fprintf(stderr, "Could not connect using UnixIO socket.\n");
+ }
+ return fd;
+ }
+
if (getenv("TCSD_USE_TCP_DEVICE")) {
if ((tcp_device_hostname = getenv("TCSD_TCP_DEVICE_HOSTNAME")) == NULL)
tcp_device_hostname = "localhost";
};
fd_set rfds;
- fd = open_connection(tpm_device, tcp_hostname, tcp_port);
+ fd = open_connection(tpm_device, tcp_hostname, tcp_port, unix_path);
if (fd < 0) {
goto err_exit;
}
"\t--tpm-device <device> use the given device; default is /dev/tpm0\n"
"\t--tcp [<host>]:[<prt>] connect to TPM on give host and port;\n"
"\t default host is 127.0.0.1, default port is %u\n"
+"\t--unix <path> connect to TPM using UnixIO socket\n"
"\t-c startup clear (default)\n"
"\t-s startup state\n"
"\t-d startup deactivate\n"
static struct option long_options[] = {
{"tpm-device", required_argument, NULL, 'D'},
{"tcp", required_argument, NULL, 'T'},
+ {"unix", required_argument, NULL, 'U'},
{"c", no_argument, NULL, 'c'},
{"d", no_argument, NULL, 'd'},
{"h", no_argument, NULL, 'h'},
return EXIT_FAILURE;
}
break;
+ case 'U':
+ unix_path = strdup(optarg);
+ if (!unix_path) {
+ fprintf(stderr, "Out of memory.\n");
+ return EXIT_FAILURE;
+ }
+ break;
case 'c':
startupparm = TPM_ST_CLEAR;
do_more = 1;