blob: 982992dcd121e0c1f469f03963056215d388a89f [file] [log] [blame]
Gaurav Shahbf6c4a72010-03-05 10:58:48 -08001diff -Naur old/README.experimental new/README.experimental
2--- old/README.experimental 1969-12-31 16:00:00.000000000 -0800
3+++ new/README.experimental 2010-01-15 16:35:45.000000000 -0800
4@@ -0,0 +1,42 @@
5+* Compilation for experimental use on Linux:
6+
7+$ /bin/sh ./bootstrap.sh
8+...
9+$ CFLAGS="-DDISABLE_SECURITY -w" ./configure --prefix=/usr/local --with-gui=openssl
10+...
11+$ make
12+...
13+$ sudo make install
14+...
15+
16+
17+* Compilation for experimental use on Mac OS X:
18+
19+$ /bin/sh ./bootstrap.sh
20+...
21+$ CFLAGS="-DDISABLE_SECURITY -w -arch i386" ./configure --prefix=/usr/local --with-gui=openssl
22+...
23+$ make
24+...
25+$ sudo make install
26+...
27+
28+If the "/bin/sh ./bootstrap.sh" step fails, which is quite likely to happen
29+on a Mac OS X installation, it's much easier to do that part on a recent Linux
30+machine rather than wrestle with GNU autoconf/automake/libtool etc. Simply
31+start off on a Linux machine, run bootstrap.sh, and assuming it goes well,
32+tar up the resultant directory and bring it to Mac OS X. Then continue with
33+the next steps.
34+
35+The first time you install TrouSerS, /usr/local/etc/tcsd.conf will be created.
36+To make tcsd accept all operations from remote clients, edit the newly
37+installed tcsd.conf to uncomment the section labeled `Remote DISABLED_SECURITY':
38+
39+...
40+# Remote DISABLED_SECURITY
41+# If you compiled TrouSerS with DISABLED_SECURITY defined, uncomment the
42+# following block to run tcsd in DISABLED_SECURITY mode for remote clients.
43+
44+port = 30003
45+remote_ops = seal,unseal,registerkey,unregisterkey,getregisteredkeybypublicinfo,getpubkey,loadkey,createkey,sign,random,getcapability,unbind,quote,readpubek,selftest
46+...
47diff -Naur old/configure.in new/configure.in
48--- old/configure.in 2010-01-15 03:58:42.000000000 -0800
49+++ new/configure.in 2010-01-15 16:21:01.000000000 -0800
50@@ -14,10 +14,10 @@
51 AM_INIT_AUTOMAKE([foreign 1.6])
52
53 # Debugging support
54-AC_ARG_ENABLE(debug,
55- AC_HELP_STRING([--enable-debug], [turn on all trousers debugging flags [default is off]]),
56- [enable_debug="yes"
57- AC_MSG_RESULT([*** Enabling debugging at user request ***])],)
58+#AC_ARG_ENABLE(debug,
59+ #AC_HELP_STRING([--enable-debug], [turn on all trousers debugging flags [default is off]]),
60+ #[enable_debug="yes"
61+ #AC_MSG_RESULT([*** Enabling debugging at user request ***])],)
62
63 # If the user has not set CFLAGS, do something appropriate
64 test_CFLAGS=${CFLAGS+set}
65diff -Naur old/dist/Makefile.am new/dist/Makefile.am
66--- old/dist/Makefile.am 2006-09-27 15:13:06.000000000 -0700
67+++ new/dist/Makefile.am 2010-01-15 16:21:01.000000000 -0800
68@@ -1,17 +1,15 @@
69
70 install: install-exec-hook
71 if test ! -e ${DESTDIR}/@sysconfdir@/tcsd.conf; then mkdir -p ${DESTDIR}/@sysconfdir@ && cp tcsd.conf ${DESTDIR}/@sysconfdir@; fi
72- /bin/chown tss:tss ${DESTDIR}/@sysconfdir@/tcsd.conf
73- /bin/chmod 0600 ${DESTDIR}/@sysconfdir@/tcsd.conf
74+ chown tss:tss ${DESTDIR}/@sysconfdir@/tcsd.conf
75+ chmod 0600 ${DESTDIR}/@sysconfdir@/tcsd.conf
76
77 install-exec-hook:
78- /usr/sbin/groupadd tss || true
79- /usr/sbin/useradd -r tss -g tss || true
80- /bin/chown tss:tss ${DESTDIR}/@sbindir@/tcsd
81+ /bin/sh ./platform_useradd || false
82+ chown tss:tss ${DESTDIR}/@sbindir@/tcsd
83 /bin/sh -c 'if [ ! -e ${DESTDIR}/@localstatedir@/lib/tpm ];then mkdir -p ${DESTDIR}/@localstatedir@/lib/tpm; fi'
84- /bin/chown tss:tss ${DESTDIR}/@localstatedir@/lib/tpm
85- /bin/chmod 0700 ${DESTDIR}/@localstatedir@/lib/tpm
86+ chown tss:tss ${DESTDIR}/@localstatedir@/lib/tpm
87+ chmod 0700 ${DESTDIR}/@localstatedir@/lib/tpm
88
89 uninstall-hook:
90- /usr/sbin/userdel tss
91- /usr/sbin/groupdel tss
92+ /bin/sh ./platform_userdel
93diff -Naur old/dist/platform_useradd new/dist/platform_useradd
94--- old/dist/platform_useradd 1969-12-31 16:00:00.000000000 -0800
95+++ new/dist/platform_useradd 2010-01-15 16:21:01.000000000 -0800
96@@ -0,0 +1,42 @@
97+#! /bin/bash
98+
99+PATH=/bin:/sbin:/usr/bin:/usr/sbin:
100+
101+OSNAME=`uname`
102+if [ "$OSNAME" == "Darwin" ]
103+then
104+
105+ LAST_USED_UID=`sudo dscl . -list /Users UniqueID | sort -n -k2 | tail -1 | awk '{print $2}'`
106+ if [ "$?" != 0 ]
107+ then
108+ exit 1
109+ fi
110+ NEXT_UID=$[$LAST_USED_UID + 1000]
111+
112+ LAST_USED_GID=`sudo dscl . -list /Groups PrimaryGroupID | sort -n -k2 | tail -1 | awk '{print $2}'`
113+ if [ "$?" != 0 ]
114+ then
115+ exit 1
116+ fi
117+ NEXT_GID=$[$LAST_USED_GID + 1000]
118+
119+ sudo dscl . -create /Groups/tss PrimaryGroupID $NEXT_GID || exit 1
120+
121+ sudo dscl . -create /Users/tss UniqueID $NEXT_UID
122+ if [ "$?" != 0 ]
123+ then
124+ sudo dscl . -delete /Groups/tss
125+ exit 1
126+ fi
127+
128+ sudo dscl . -append /Users/tss PrimaryGroupID $NEXT_GID
129+ if [ "$?" != 0 ]
130+ then
131+ sudo dscl . -delete /Groups/tss
132+ sudo dscl . -delete /Users/tss
133+ exit 1
134+ fi
135+
136+else
137+ useradd -U -r tss || true # hope that failure means tss exists
138+fi
139diff -Naur old/dist/platform_userdel new/dist/platform_userdel
140--- old/dist/platform_userdel 1969-12-31 16:00:00.000000000 -0800
141+++ new/dist/platform_userdel 2010-01-15 16:21:01.000000000 -0800
142@@ -0,0 +1,13 @@
143+#! /bin/bash
144+
145+PATH=/bin:/sbin:/usr/bin:/usr/sbin:
146+
147+OSNAME=`uname`
148+if [ "$OSNAME" == "Darwin" ]
149+then
150+ sudo dscl . -delete /Users/tss
151+ sudo dscl . -delete /Groups/tss
152+else
153+ userdel tss
154+ groupdel tss
155+fi
156diff -Naur old/dist/tcsd.conf.in new/dist/tcsd.conf.in
157--- old/dist/tcsd.conf.in 2007-08-30 14:53:37.000000000 -0700
158+++ new/dist/tcsd.conf.in 2010-01-15 16:35:02.000000000 -0800
159@@ -8,6 +8,14 @@
160 # Send questions to: trousers-users@lists.sourceforge.net
161 #
162
163+# Remote DISABLED_SECURITY
164+#
165+# If you compiled TrouSerS with DISABLED_SECURITY defined, uncomment the
166+# following block to run tcsd in DISABLED_SECURITY mode for remote clients.
167+
168+# port = 30003
169+# remote_ops = seal,unseal,registerkey,unregisterkey,getregisteredkeybypublicinfo,getpubkey,loadkey,createkey,sign,random,getcapability,unbind,quote,readpubek,selftest
170+
171 # Option: port
172 # Values: 1 - 65535
173 # Description: The port that the tcsd will listen on.
174diff -Naur old/src/include/tcsd.h new/src/include/tcsd.h
175--- old/src/include/tcsd.h 2007-11-19 12:05:11.000000000 -0800
176+++ new/src/include/tcsd.h 2010-01-15 16:21:01.000000000 -0800
177@@ -155,8 +155,10 @@
178 void *tcsd_thread_run(void *);
179 void thread_signal_init();
180
181+#ifndef __APPLE__
182 /* signal handling */
183 struct sigaction tcsd_sa_int;
184 struct sigaction tcsd_sa_chld;
185+#endif
186
187 #endif
188diff -Naur old/src/include/trousers_types.h new/src/include/trousers_types.h
189--- old/src/include/trousers_types.h 2007-11-19 11:33:14.000000000 -0800
190+++ new/src/include/trousers_types.h 2010-01-15 16:21:01.000000000 -0800
191@@ -122,6 +122,8 @@
192 #define BSD_CONST
193 #elif (defined (__OpenBSD__) || defined (__FreeBSD__))
194 #define BSD_CONST const
195+#elif (defined (__APPLE__))
196+#define BSD_CONST
197 #endif
198
199
200diff -Naur old/src/tcs/rpc/tcstp/rpc.c new/src/tcs/rpc/tcstp/rpc.c
201--- old/src/tcs/rpc/tcstp/rpc.c 2007-12-18 08:21:16.000000000 -0800
202+++ new/src/tcs/rpc/tcstp/rpc.c 2010-01-15 16:21:01.000000000 -0800
203@@ -516,6 +516,9 @@
204 int
205 access_control(struct tcsd_thread_data *thread_data)
206 {
207+#ifdef DISABLE_SECURITY
208+ return 0;
209+#else
210 int i = 0;
211 struct hostent *local_hostent = NULL;
212 static char *localhostname = NULL;
213@@ -560,6 +563,7 @@
214 }
215
216 return 1;
217+#endif
218 }
219
220 TSS_RESULT
221diff -Naur old/src/tcsd/platform.c new/src/tcsd/platform.c
222--- old/src/tcsd/platform.c 2009-10-29 06:45:12.000000000 -0700
223+++ new/src/tcsd/platform.c 2010-01-15 16:28:20.000000000 -0800
224@@ -32,6 +32,14 @@
225 #include "tcsps.h"
226 #include "tcslog.h"
227
228+#if DISABLE_SECURITY
229+
230+char platform_get_runlevel()
231+{
232+ return 's';
233+}
234+
235+#else
236
237 #if (defined (__linux) || defined (linux))
238 MUTEX_DECLARE_INIT(utmp_lock);
239@@ -131,4 +139,15 @@
240
241 return runlevel;
242 }
243+
244+#elif (defined (__APPLE__))
245+
246+char
247+platform_get_runlevel()
248+{
249+ return '5'; // XXX TBD
250+}
251+
252 #endif
253+
254+#endif /* DISABLED_SECURITY */
255diff -Naur old/src/tcsd/svrside.c new/src/tcsd/svrside.c
256--- old/src/tcsd/svrside.c 2008-10-13 19:40:53.000000000 -0700
257+++ new/src/tcsd/svrside.c 2010-01-15 16:21:01.000000000 -0800
258@@ -41,6 +41,14 @@
259 struct tcsd_config tcsd_options;
260 struct tpm_properties tpm_metrics;
261
262+#ifdef __APPLE__
263+/* signal handling */
264+struct sigaction tcsd_sa_int;
265+struct sigaction tcsd_sa_chld;
266+
267+#include <dlfcn.h>
268+#endif
269+
270 void
271 tcsd_shutdown()
272 {
273@@ -226,6 +234,10 @@
274 {"foreground", 0, NULL, 'f'},
275 {0, 0, 0, 0}
276 };
277+#ifdef __APPLE__
278+ typedef int (*daemon_funcptr_t)(int, int);
279+ daemon_funcptr_t daemon_funcptr = dlsym(RTLD_DEFAULT, "daemon");
280+#endif
281
282 while ((c = getopt_long(argc, argv, "fh", long_options, &option_index)) != -1) {
283 switch (c) {
284@@ -245,7 +257,11 @@
285 return (int)result;
286
287 if (getenv("TCSD_FOREGROUND") == NULL) {
288+#ifdef __APPLE__
289+ if (daemon_funcptr(0, 0) == -1) {
290+#else
291 if (daemon(0, 0) == -1) {
292+#endif
293 perror("daemon");
294 tcsd_shutdown();
295 return -1;
296@@ -281,6 +297,12 @@
297 }
298 client_len = (unsigned)sizeof(client_addr);
299 LogInfo("%s: TCSD up and running.", PACKAGE_STRING);
300+#ifdef DISABLE_SECURITY
301+ LogInfo("*** WARNING *** This experimental version of TCSD has critical caveats:");
302+ LogInfo("\t- It NEVER requires single-user mode.");
303+ LogInfo("\t- It allows ALL operations EVEN to remote clients.");
304+ LogInfo("*** WARNING *** DO NOT use this code in production.");
305+#endif
306 do {
307 newsd = accept(sd, (struct sockaddr *) &client_addr, &client_len);
308 LogDebug("accepted socket %i", newsd);
309diff -Naur old/src/tspi/ps/tspps.c new/src/tspi/ps/tspps.c
310--- old/src/tspi/ps/tspps.c 2009-07-20 11:49:35.000000000 -0700
311+++ new/src/tspi/ps/tspps.c 2010-01-15 16:21:01.000000000 -0800
312@@ -30,7 +30,7 @@
313
314 static int user_ps_fd = -1;
315 static MUTEX_DECLARE_INIT(user_ps_lock);
316-#if (defined (__FreeBSD__) || defined (__OpenBSD__))
317+#if (defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__APPLE__))
318 static MUTEX_DECLARE_INIT(user_ps_path);
319 #endif
320
321@@ -56,7 +56,7 @@
322 *file = strdup(file_name);
323 return (*file) ? TSS_SUCCESS : TSPERR(TSS_E_OUTOFMEMORY);
324 }
325-#if (defined (__FreeBSD__) || defined (__OpenBSD__))
326+#if (defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__APPLE__))
327 MUTEX_LOCK(user_ps_path);
328 #endif
329
330@@ -72,8 +72,8 @@
331 endpwent();
332 return TSPERR(TSS_E_INTERNAL_ERROR);
333 }
334-
335-#elif (defined (__FreeBSD__) || defined (__OpenBSD__))
336+
337+#elif (defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__APPLE__))
338 if ((pwp = getpwent()) == NULL) {
339 LogDebugFn("USER PS: Error getting path to home directory: getpwent: %s",
340 strerror(rc));
341diff -Naur old/src/tspi/tspi_context.c new/src/tspi/tspi_context.c
342--- old/src/tspi/tspi_context.c 2008-01-04 09:01:59.000000000 -0800
343+++ new/src/tspi/tspi_context.c 2010-01-15 16:21:01.000000000 -0800
344@@ -70,7 +70,22 @@
345 BYTE *machine_name = NULL;
346 TSS_HOBJECT hTpm;
347 UINT32 string_len = 0;
348+#ifdef DISABLE_SECURITY
349+ char* tss_server = getenv("TSS_SERVER");
350
351+ if ((wszDestination == NULL) && (tss_server != NULL)) {
352+ size_t machineNameLen = strlen(tss_server);
353+ machine_name = (BYTE*)malloc(machineNameLen + 1);
354+ if (machine_name != NULL) {
355+ (void)snprintf((char*)machine_name, machineNameLen + 1,
356+ "%s", tss_server);
357+ // XXX To ensure table is created.
358+ void* junk = calloc_tspi(tspContext, 32);
359+ free_tspi(tspContext, junk);
360+ goto machine_name_ok;
361+ }
362+ }
363+#endif
364
365 if (wszDestination == NULL) {
366 if ((result = obj_context_get_machine_name(tspContext,
367@@ -87,6 +102,9 @@
368 LogError("Error converting hostname to UTF-8");
369 return TSPERR(TSS_E_INTERNAL_ERROR);
370 }
371+#ifdef DISABLE_SECURITY
372+machine_name_ok:
373+#endif
374
375 if ((result = RPC_OpenContext(tspContext, machine_name,
376 CONNECTION_TYPE_TCP_PERSISTANT)))
377diff -Naur old/tools/ps_inspect.c new/tools/ps_inspect.c
378--- old/tools/ps_inspect.c 2009-07-27 05:57:33.000000000 -0700
379+++ new/tools/ps_inspect.c 2010-01-15 16:21:01.000000000 -0800
380@@ -68,7 +68,7 @@
381 #define PRINTERR(...) fprintf(stderr, ##__VA_ARGS__)
382 #define PRINT(...) printf("PS " __VA_ARGS__)
383
384-#if (defined (__FreeBSD__) || defined (__OpenBSD__))
385+#if (defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__APPLE__))
386 #define OFF_T_PRINTF "lld"
387 #else
388 #define OFF_T_PRINTF "ld"