components/trousers/patches/tddl.c.patch
author tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
Fri, 25 Nov 2011 01:35:48 -0800
changeset 598 398722c80922
parent 399 d877cc559d95
child 622 fd8f0e501744
permissions -rw-r--r--
7112588 proftpd in solaris 11 release does not handle spaces in filenames

--- src/tddl/tddl.c.old	2010-04-12 22:24:21.000000000 -0700
+++ src/tddl/tddl.c 2011-07-12 13:14:57.362305220 -0700
@@ -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}
 };
@@ -63,7 +67,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 +109,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 +189,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 +265,7 @@
 
 TSS_RESULT Tddli_Cancel(void)
 {
+#ifndef SOLARIS
 	int rc;
 
 	if (opened_device->transmit == TDDL_TRANSMIT_IOCTL) {
@@ -270,4 +281,7 @@
 	} else {
 		return TDDLERR(TSS_E_NOTIMPL);
 	}
+#else
+	return TDDLERR(TSS_E_NOTIMPL);
+#endif /* SOLARIS */
 }