From nobody Mon Apr 04 05:32:12 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 804BA1A40BBF; Mon, 4 Apr 2022 05:32:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KWztN3BbWz3vRg; Mon, 4 Apr 2022 05:32:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649050332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ND25MqALoj2QaL2M0SJ6sS0ONYiQNwFJqwb8AeI3neg=; b=JJ4vwtjs+LmYWqSk8eDa79wUPz47aCvj5m6hHNPzpMIQf7pc0cWZo3MgVAFlJfdza5+CkL NSRI1UFqUKTY7q3oqok2JArCR4ja7zZAckuapO1glqqn/6f4WpukcPCu6ARKeJ+ZQqmU9a GaDsruqy9xwMAPks5g4bEYOPB+8AnpS8elVfSryeK8p5ikwkPabwunbA+y/q657F0L9U7O oqodK7e1g9HVCFVVRGb8SvMA72VPQXdkTbGpRlDk1Ta5y6zCzQxzp9K0zWGSwDHbBFAxje HrCerEDO+Ze7XnLG3y0JngeqM34jYv6rA2+rCALffh7dICpjiiky7rUVuXGg1g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 42EC740A9; Mon, 4 Apr 2022 05:32:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2345WCnV037565; Mon, 4 Apr 2022 05:32:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2345WCgb037564; Mon, 4 Apr 2022 05:32:12 GMT (envelope-from git) Date: Mon, 4 Apr 2022 05:32:12 GMT Message-Id: <202204040532.2345WCgb037564@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Guangyuan Yang Subject: git: 71b35fe2b1fb - main - security/tpm2-abrmd: Improve rc.d script and add devd config List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71b35fe2b1fbffcbd13ebeed2e4db0fe5fca0f2b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649050332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ND25MqALoj2QaL2M0SJ6sS0ONYiQNwFJqwb8AeI3neg=; b=EP2rDyP4MAxoT7Y1ZuxD2cUw/NOS7b24rHIE2Qkn7IcL9PDynhi78b9GuFvaeLwLdKetZL 0dFdK/tLAspB0hlE69YooLq+D+n0oBVePcXA2tR41QCztZHxaKZoLwef3xvNCXboQHp3di j0JotEVamGwBbe27DC7vKJcdgGRW/rklkHGyPG0lv6O2kduwRyMZZpnHaxLZkVFvoco2js EObdFJrkx3gjppuo2leJelJGdhdzMPeUwHF3lkXgwJFT2HcXnWQVtDGZBenu/Um5TeDsD4 3/QQbc+6JX5Tr7BumgL8LVd87pxxl7zz9TjKclYNWyhPwigx9UT3/XSEFRM2Lw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649050332; a=rsa-sha256; cv=none; b=IwBoHI7ao8R2x3vm/v/njSvdWhfgChVtOicPvb9tYckrRoTw18v5BthbEEsokw10oYm06w LGaIUDOhrNqPdkFj3MX5XRR4lK1o22zKLw3N4d1NM/6GuOYo7sz5LJ724dYiOf8RT0jTef eD1bsyGCHyzW0exrAtGzkTY1SqxMy+IFJCWZeuCEd+o+jLW4aG3pFB2+yLicGXL1+zcL4p cF0g7CJyq6H9IPuYp00dLHkPo1jPT2viA3CBpA6x/yDUtWlOBCHkl7PZ1SYc/MHYL+LfF1 Hn6ko3vqjKjoNBk16VpGyOYmU5p1SPG4ILAV72IzIDCvFWEXTjjO7ZIwr4Qf0w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by ygy: URL: https://cgit.FreeBSD.org/ports/commit/?id=71b35fe2b1fbffcbd13ebeed2e4db0fe5fca0f2b commit 71b35fe2b1fbffcbd13ebeed2e4db0fe5fca0f2b Author: Tadeusz Struk AuthorDate: 2022-04-04 05:32:01 +0000 Commit: Guangyuan Yang CommitDate: 2022-04-04 05:32:01 +0000 security/tpm2-abrmd: Improve rc.d script and add devd config - Improve tpm2-abrmd rc.d script - Add devd config file, which adds rules for /dev/tpm0 char device. It allows the _tss group members to read and write the tpm device, which is required by tpm2-abrmd to communicate with the device. Differential Revision: https://reviews.freebsd.org/D34744 --- security/tpm2-abrmd/Makefile | 4 ++ security/tpm2-abrmd/files/tpm2-abrmd-devd.conf | 6 +++ security/tpm2-abrmd/files/tpm2-abrmd.in | 52 +++++++++++++++++++++++++- security/tpm2-abrmd/pkg-plist | 1 + 4 files changed, 61 insertions(+), 2 deletions(-) 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,5 +1,6 @@ PORTNAME= tpm2-abrmd DISTVERSION= 2.4.1 +PORTREVISION= 1 CATEGORIES= security MASTER_SITES= https://github.com/tpm2-software/tpm2-abrmd/releases/download/${DISTVERSION}/ @@ -25,6 +26,9 @@ 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 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 @@ -12,13 +12,61 @@ . /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,5 +1,6 @@ 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