diff --git a/security/tpm2-abrmd/Makefile b/security/tpm2-abrmd/Makefile index c8842108ed14..c2d411f727af 100644 --- a/security/tpm2-abrmd/Makefile +++ b/security/tpm2-abrmd/Makefile @@ -1,38 +1,42 @@ PORTNAME= tpm2-abrmd DISTVERSION= 2.4.1 +PORTREVISION= 1 CATEGORIES= security MASTER_SITES= https://github.com/tpm2-software/tpm2-abrmd/releases/download/${DISTVERSION}/ MAINTAINER= tstruk@gmail.com COMMENT= TPM2 Access Broker & Resource Manager Deamon LICENSE= BSD2CLAUSE LIB_DEPENDS= libtss2-esys.so:security/tpm2-tss \ libgio-2.0.so:devel/glib20 RUN_DEPENDS= dbus-daemon:devel/dbus USES= gmake libtool pkgconfig gnome USE_LDCONFIG= yes USE_GNOME= glib20 USE_RC_SUBR= tpm2-abrmd GNU_CONFIGURE= yes CONFIGURE_ARGS= --with-dbuspolicydir=${PREFIX}/etc/dbus-1/system.d GROUPS= _tss USERS= _tss SUB_LIST= DBUS_DAEMON=dbus +pre-install: + @${INSTALL_DATA} ${FILESDIR}/tpm2-abrmd-devd.conf ${STAGEDIR}${PREFIX}/etc/devd + post-install: @${RM} ${STAGEDIR}${PREFIX}/lib/systemd/system-preset/tpm2-abrmd.preset @${RM} ${STAGEDIR}${PREFIX}/lib/systemd/system/tpm2-abrmd.service @${RM} ${STAGEDIR}${PREFIX}/share/dbus-1/system-services/com.intel.tss2.Tabrmd.service @${RMDIR} ${STAGEDIR}${PREFIX}/lib/systemd/system @${RMDIR} ${STAGEDIR}${PREFIX}/lib/systemd/system-preset @${RMDIR} ${STAGEDIR}${PREFIX}/lib/systemd @${RMDIR} ${STAGEDIR}${PREFIX}/share/dbus-1/system-services @${RMDIR} ${STAGEDIR}${PREFIX}/share/dbus-1 .include diff --git a/security/tpm2-abrmd/files/tpm2-abrmd-devd.conf b/security/tpm2-abrmd/files/tpm2-abrmd-devd.conf new file mode 100644 index 000000000000..27f804d89fb9 --- /dev/null +++ b/security/tpm2-abrmd/files/tpm2-abrmd-devd.conf @@ -0,0 +1,6 @@ +# Allow members of _tss group to access tpm device + +notify 100 { + device-name "tpm0"; + action "chgrp _tss /dev/$cdev; chmod g+rw /dev/$cdev"; +}; diff --git a/security/tpm2-abrmd/files/tpm2-abrmd.in b/security/tpm2-abrmd/files/tpm2-abrmd.in index 18e2c645a17d..62d61d98b1d6 100644 --- a/security/tpm2-abrmd/files/tpm2-abrmd.in +++ b/security/tpm2-abrmd/files/tpm2-abrmd.in @@ -1,24 +1,72 @@ #!/bin/sh # PROVIDE: tpm2_abrmd # REQUIRE: DAEMON %%DBUS_DAEMON%% # KEYWORD: shutdown # # Add the following to /etc/rc.conf[.local] to enable this service # # tpm2_abrmd_enable="YES" # . /etc/rc.subr name=tpm2_abrmd -desc=TPM2 Access Broker & Resource Management Daemon +desc="TPM2 Access Broker & Resource Management Daemon" rcvar=tpm2_abrmd_enable load_rc_config ${name} : ${tpm2_abrmd_enable:=NO} command=%%PREFIX%%/sbin/tpm2-abrmd -tpm2_abrmd_user=_tss +tpm2_abrmd_user="_tss" +tpm2_abrmd_group="_tss" +pidfile="/var/run/${name}.pid" +logfile="/var/log/${name}.log" +start_cmd="tpm2_abrmd_start" +stop_cmd="tpm2_abrmd_stop" +status_cmd="tpm2_abrmd_status" + +is_process_running() { + [ -f ${pidfile} ] && procstat `cat ${pidfile}` >/dev/null 2>&1 +} + +tpm2_abrmd_start() +{ + if is_process_running; then + echo "${name} already running as pid $(cat $pidfile)" + return 1 + fi + + touch $logfile + chmod 640 $logfile + chown -R ${tpm2_abrmd_user}:${tpm2_abrmd_group} ${logfile} + /usr/sbin/daemon -P ${pidfile} -u ${tpm2_abrmd_user} ${command} >>${logfile} 2>&1 + + if is_process_running; then + echo "Started ${name}, pid $(cat ${pidfile})" + else + echo "Failed to start ${name}" + fi +} + +tpm2_abrmd_stop() +{ + if is_process_running; then + echo "Stopping ${name}" + kill -- -$(cat ${pidfile}) + /bin/rm -f ${pidfile} + else + echo "${name} isn't running" + fi +} + +tpm2_abrmd_status() { + if is_process_running; then + echo "${name} is running as pid $(cat ${pidfile})" + else + echo "${name} isn't running" + fi +} run_rc_command "$1" diff --git a/security/tpm2-abrmd/pkg-plist b/security/tpm2-abrmd/pkg-plist index a069dd6b1073..fd348d11806c 100644 --- a/security/tpm2-abrmd/pkg-plist +++ b/security/tpm2-abrmd/pkg-plist @@ -1,11 +1,12 @@ include/tss2/tss2-tcti-tabrmd.h etc/dbus-1/system.d/tpm2-abrmd.conf +etc/devd/tpm2-abrmd-devd.conf lib/libtss2-tcti-tabrmd.a lib/libtss2-tcti-tabrmd.so lib/libtss2-tcti-tabrmd.so.0 lib/libtss2-tcti-tabrmd.so.0.0.0 libdata/pkgconfig/tss2-tcti-tabrmd.pc man/man3/Tss2_Tcti_Tabrmd_Init.3.gz man/man7/tss2-tcti-tabrmd.7.gz man/man8/tpm2-abrmd.8.gz sbin/tpm2-abrmd