components/trousers/patches/tddl_tddl.c.patch
author Matt Keenan <matt.keenan@oracle.com>
Fri, 19 Jun 2015 09:35:02 +0100
branchs11-update
changeset 4508 d8924d870370
parent 777 e2e604cdbd6a
child 5941 db8aa9865e9f
permissions -rw-r--r--
PSARC 2015/172 OpenStack Ironic (OpenStack Bare Metal Provisioning Service) PSARC 2015/070 pecan - Lightweight Python web-framework PSARC 2015/071 PyCA Python Cryptography PSARC 2015/170 OpenStack client for Ironic (Bare Metal Provisioning) PSARC 2015/171 scp - python secure copy PSARC 2015/196 singledispatch - Single-dispatch generic functions for Python PSARC 2015/197 logutils - Set of handlers for standard Python logging library PSARC 2015/198 Support for enumerations in Python 2.6 and 2.7 PSARC 2015/250 paramiko - SSHv2 protocol implementation in Python 20547142 Request to integrate Ironic into userland 17502639 The Python paramiko module should be added to Userland 20172780 The Python module scp should be added to Userland 20180376 The Python module ironicclient should be added to Userland 20182588 The Python module pecan should be added to Userland 20465525 The PyCA cryptography module should be added to Userland 20904396 The Python module singledispatch should be added to Userland 20904413 The Python module logutils should be added to Userland 20917993 The Python enum34 module should be added to Userland

--- src/tddl/tddl.c	Mon Apr 12 22:24:21 2010
+++ src/tddl/tddl.c.new	Thu Sep 22 12:28:25 2011
@@ -18,13 +18,17 @@
 
 #include "trousers/tss.h"
 #include "trousers_types.h"
+#ifndef SOLARIS
 #include "linux/tpm.h"
+#endif
 #include "tcslog.h"
 #include "tddl.h"
 
 struct tpm_device_node tpm_device_nodes[] = {
+#ifndef SOLARIS
 	{"/dev/tpm0", TDDL_UNDEF, TDDL_UNDEF},
 	{"/udev/tpm0", TDDL_UNDEF, TDDL_UNDEF},
+#endif
 	{"/dev/tpm", TDDL_UNDEF, TDDL_UNDEF},
 	{NULL, 0, 0}
 };
@@ -42,6 +46,13 @@
 #include <netdb.h>
 #include <fcntl.h>
 
+#ifdef SOLARIS
+int
+get_device_fd()
+{
+	return (opened_device->fd);
+}
+#endif
 
 int
 open_device()
@@ -63,7 +74,7 @@
 	 
 		
 		fd = socket(AF_INET, SOCK_STREAM, 0);
-		if (fd > 0) {
+		if (fd >= 0) {
 			struct hostent *host = gethostbyname(tcp_device_hostname);
 			if (host != NULL) {   
 				struct sockaddr_in addr;
@@ -105,12 +116,16 @@
 		/* tpm_device_paths is filled out in tddl.h */
 		for (i = 0; tpm_device_nodes[i].path != NULL; i++) {
 			errno = 0;
-			if ((fd = open(tpm_device_nodes[i].path, O_RDWR)) >= 0)
+			if ((fd = open(tpm_device_nodes[i].path, O_RDWR)) >= 0) {
 				break;
+			} else {
+				fprintf(stderr, "Error opening %s: %s\n",
+				    tpm_device_nodes[i].path, strerror(errno));
+			}
 		}
 	}
-	
-	if (fd > 0) {
+
+	if (fd >= 0) {
 		opened_device = &(tpm_device_nodes[i]);
 		tpm_device_nodes[i].fd = fd;
 	}
@@ -181,11 +196,13 @@
 			/* fall through */
 		case TDDL_TRANSMIT_IOCTL:
 			errno = 0;
+#ifndef SOLARIS
 			if ((sizeResult = ioctl(opened_device->fd, TPMIOC_TRANSMIT, txBuffer)) != -1) {
 				opened_device->transmit = TDDL_TRANSMIT_IOCTL;
 				break;
 			}
 			LogWarn("ioctl: (%d) %s", errno, strerror(errno));
+#endif
 			LogInfo("Falling back to Read/Write device support.");
 			/* fall through */
 		case TDDL_TRANSMIT_RW:
@@ -255,6 +272,7 @@
 
 TSS_RESULT Tddli_Cancel(void)
 {
+#ifndef SOLARIS
 	int rc;
 
 	if (opened_device->transmit == TDDL_TRANSMIT_IOCTL) {
@@ -270,4 +288,7 @@
 	} else {
 		return TDDLERR(TSS_E_NOTIMPL);
 	}
+#else
+	return TDDLERR(TSS_E_NOTIMPL);
+#endif /* SOLARIS */
 }