mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-08-11 11:40:05 +00:00
Only compile vTPM proxy support if available on platform
Support for vTPM proxy is only available on Linux. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
parent
099c9cb64b
commit
c751e32ec7
@ -434,6 +434,14 @@ if test "$libtpms_cryptolib" != "$cryptolib"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
with_vtpm_proxy=no
|
||||
case $host_os in
|
||||
linux-gnu)
|
||||
with_vtpm_proxy=yes
|
||||
AC_DEFINE_UNQUOTED([WITH_VTPM_PROXY], 1,
|
||||
[whether to build in vTPM proxy support (Linux only)])
|
||||
esac
|
||||
|
||||
case $host_os in
|
||||
cygwin)
|
||||
CFLAGS="$CFLAGS -D__USE_LINUX_IOCTL_DEFS"
|
||||
@ -470,6 +478,7 @@ printf "with_selinux : %5s (no = SELinux policy extenions will NOT be built)
|
||||
printf "with_cuse : %5s (no = no CUSE interface)\n" $with_cuse
|
||||
printf "with_chardev : %5s (no = no chardev interface)\n" $with_chardev
|
||||
printf "with_swtpm_setup: %5s (no = swtpm_setup will NOT be built)\n" $with_swtpm_setup
|
||||
printf "with_vtpm_proxy : %5s (no = no vtpm proxy support; Linux only)\n" $with_vtpm_proxy
|
||||
echo
|
||||
echo "cryptolib: $cryptolib"
|
||||
echo
|
||||
|
||||
@ -65,7 +65,9 @@
|
||||
#include "utils.h"
|
||||
#include "ctrlchannel.h"
|
||||
#include "mainloop.h"
|
||||
#ifdef WITH_VTPM_PROXY
|
||||
#include "vtpm_proxy.h"
|
||||
#endif
|
||||
|
||||
/* local variables */
|
||||
static int notify_fd[2] = {-1, -1};
|
||||
@ -90,6 +92,7 @@ static void sigterm_handler(int sig __attribute__((unused)))
|
||||
mainloop_terminate = true;
|
||||
}
|
||||
|
||||
#ifdef WITH_VTPM_PROXY
|
||||
static int create_vtpm_proxy(struct vtpm_proxy_new_dev *vtpm_new_dev)
|
||||
{
|
||||
int fd, n, ret = 0;
|
||||
@ -110,6 +113,7 @@ static int create_vtpm_proxy(struct vtpm_proxy_new_dev *vtpm_new_dev)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void usage(FILE *file, const char *prgname, const char *iface)
|
||||
{
|
||||
@ -147,7 +151,9 @@ static void usage(FILE *file, const char *prgname, const char *iface)
|
||||
" into; the TPM_PATH environment variable can be used\n"
|
||||
" instead\n"
|
||||
"-r|--runas <user>: change to the given user\n"
|
||||
#ifdef WITH_VTPM_PROXY
|
||||
"--vtpm-proxy : spawn a Linux vTPM proxy driver device and read TPM\n"
|
||||
#endif
|
||||
" command from its anonymous file descriptor\n"
|
||||
"-h|--help : display this help screen and terminate\n"
|
||||
"\n",
|
||||
@ -172,7 +178,9 @@ int swtpm_chardev_main(int argc, char **argv, const char *prgname, const char *i
|
||||
char *tpmstatedata = NULL;
|
||||
char *ctrlchdata = NULL;
|
||||
char *runas = NULL;
|
||||
#ifdef WITH_VTPM_PROXY
|
||||
bool use_vtpm_proxy = false;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
time_t start_time;
|
||||
#endif
|
||||
@ -187,7 +195,9 @@ int swtpm_chardev_main(int argc, char **argv, const char *prgname, const char *i
|
||||
{"pid" , required_argument, 0, 'P'},
|
||||
{"tpmstate" , required_argument, 0, 's'},
|
||||
{"ctrl" , required_argument, 0, 'C'},
|
||||
#ifdef WITH_VTPM_PROXY
|
||||
{"vtpm-proxy", no_argument, 0, 'v'},
|
||||
#endif
|
||||
{NULL , 0 , 0, 0 },
|
||||
};
|
||||
|
||||
@ -277,9 +287,11 @@ int swtpm_chardev_main(int argc, char **argv, const char *prgname, const char *i
|
||||
runas = optarg;
|
||||
break;
|
||||
|
||||
#ifdef WITH_VTPM_PROXY
|
||||
case 'v':
|
||||
use_vtpm_proxy = true;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
usage(stderr, prgname, iface);
|
||||
@ -287,6 +299,7 @@ int swtpm_chardev_main(int argc, char **argv, const char *prgname, const char *i
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_VTPM_PROXY
|
||||
if (use_vtpm_proxy) {
|
||||
struct vtpm_proxy_new_dev vtpm_new_dev = {
|
||||
.flags = 0,
|
||||
@ -308,6 +321,7 @@ int swtpm_chardev_main(int argc, char **argv, const char *prgname, const char *i
|
||||
vtpm_new_dev.tpm_num,
|
||||
vtpm_new_dev.major, vtpm_new_dev.minor);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mlp.fd < 0) {
|
||||
logprintf(STDERR_FILENO, "Error: Missing character device or file descriptor\n");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user