dab335d901
This is a system daemon implementing the TPM2 access broker (TAB) & Resource Manager (RM) spec from the TCG. The daemon (tpm2-abrmd) is implemented using Glib and the GObject system. Communication between the daemon and clients using the TPM is done with a combination of DBus and Unix pipes. DBus is used for discovery, session management and the 'cancel', 'setLocality', and 'getPollHandles' API calls (mostly these aren't yet implemented). Pipes are used to send and receive TPM commands and responses (respectively) between client and server. The daemon owns the com.intel.tss2.Tabrmd name on dbus. It can be configured to connect to either the system or the session bus. The package also provides a client library for interacting with the daemon via TPM Command Transmission Interface (TCTI). It is intended for use with the SAPI library (libsapi) like any other TCTI. [Peter: drop add default DAEMON_ARGS to init script, drop /etc/default file, drop S30devtpmperms and fix permissions in S80tpm2-abrmd] Signed-off-by: Carlos Santos <casantos@datacom.ind.br> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
79 lines
1.6 KiB
Bash
Executable File
79 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
my_name="$0"
|
|
|
|
check_required_files() {
|
|
[ -x "$1" ] || {
|
|
echo "$my_name: $1 is missing"
|
|
exit 1
|
|
}
|
|
[ -z "$2" ] || [ -f "$2" ] || {
|
|
echo "$my_name: $2 is missing"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
check_device() {
|
|
ls -1 /dev/tpm[0-9]* > /dev/null 2>&1 || {
|
|
echo "device driver not loaded, skipping."
|
|
exit 0
|
|
}
|
|
chown tss:tss /dev/tpm[0-9]* && chmod 600 /dev/tpm*
|
|
}
|
|
|
|
rm_stale_pidfile() {
|
|
if [ -e "$1" ]; then
|
|
exe="/proc/$(cat "$1")/exe"
|
|
{ [ -s "$exe" ] && [ "$(readlink -f "$exe")" = "$2" ]; } || rm -f "$1"
|
|
fi
|
|
}
|
|
|
|
start() {
|
|
printf "Starting tpm2-abrmd: "
|
|
check_device
|
|
rm_stale_pidfile /var/run/tpm2-abrmd.pid /usr/sbin/tpm2-abrmd
|
|
start-stop-daemon -S -q -o -b -p /var/run/tpm2-abrmd.pid -c tss:tss -x /usr/sbin/tpm2-abrmd -- ${DAEMON_OPTS} || {
|
|
echo "FAIL"
|
|
exit 1
|
|
}
|
|
pidof /usr/sbin/tpm2-abrmd > /var/run/tpm2-abrmd.pid
|
|
echo "OK"
|
|
}
|
|
|
|
stop() {
|
|
printf "Stopping tpm2-abrmd: "
|
|
start-stop-daemon -K -q -o -p /var/run/tpm2-abrmd.pid -u tss -x /usr/sbin/tpm2-abrmd || {
|
|
echo "FAIL"
|
|
exit 1
|
|
}
|
|
rm_stale_pidfile /var/run/tpm2-abrmd.pid /usr/sbin/tpm2-abrmd
|
|
echo "OK"
|
|
}
|
|
|
|
check_required_files /usr/sbin/tpm2-abrmd /etc/dbus-1/system.d/tpm2-abrmd.conf
|
|
|
|
# defaults
|
|
DAEMON_OPTS="--tcti=device --logger=syslog --max-connections=20 --max-transient-objects=20 --fail-on-loaded-trans"
|
|
|
|
# Read configuration variable file if it is present
|
|
[ -r /etc/default/tpm2-abrmd ] && . /etc/default/tpm2-abrmd
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
restart|reload)
|
|
stop
|
|
sleep 1
|
|
start
|
|
;;
|
|
*)
|
|
echo "Usage: tpm2-abrmd {start|stop|restart|reload}" >&2
|
|
exit 1
|
|
esac
|
|
|
|
exit 0
|