Skip to content

Commit 81fd5b7

Browse files
dvzrvmoritzbuhl
authored andcommitted
dist: Fully lock the tss system user if supported
Use the `u!` notation to fully lock the system user. It is highly unlikely that the `tss` user should ever be logged into (e.g. via SSH). This sysusers.d feature has been released with systemd 257 on 2024-12-10. To support older systemd versions, we select a tpm2-tss.conf based on the systemd version and copy it to the build directory. With PKG_CHECK_MODULES we select the correct version during cross compilation. Avoid potential confusion by ensuring the generated file name is distinct from the input. Related-to: https://github.com/systemd/systemd/releases/tag/v257 Signed-off-by: David Runge <dave@sleepmap.de> Signed-off-by: Moritz Buhl <moritz.buhl@infineon.com>
1 parent f61bfe8 commit 81fd5b7

5 files changed

Lines changed: 23 additions & 3 deletions

File tree

Makefile.am

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,14 +716,23 @@ fapi-config.json: dist/fapi-config.json.in
716716
< "$<" > "$@"
717717

718718
if SYSD_SYSUSERS
719-
sysusers_DATA = dist/sysusers.d/tpm2-tss.conf
719+
sysusers_DATA = tpm2-tss.conf
720+
CLEANFILES += tpm2-tss.conf
720721
endif
721722

722723
if SYSD_TMPFILES
723724
tmpfiles_DATA = tpm2-tss-fapi.conf
724725
CLEANFILES += tpm2-tss-fapi.conf
725726
endif
726727

728+
if SYSD_SYSUSERS_FULLY_LOCKED
729+
tpm2-tss.conf: dist/sysusers.d/tpm2-tss.conf.fully-locked
730+
$(AM_V_GEN) cp "$<" "$@"
731+
else
732+
tpm2-tss.conf: dist/sysusers.d/tpm2-tss.conf.not-fully-locked
733+
$(AM_V_GEN) cp "$<" "$@"
734+
endif # SYSD_SYSUSERS_FULLY_LOCKED
735+
727736
# We have to do this ourselves, in order to get absolute paths
728737
tpm2-tss-fapi.conf: dist/tmpfiles.d/tpm2-tss-fapi.conf.in
729738
$(AM_V_GEN) $(SED) \
@@ -759,7 +768,8 @@ EXTRA_DIST += \
759768
dist/fapi-profiles/P_ECCP256SHA256-high-range.json \
760769
dist/fapi-profiles/P_RSA2048SHA256-low-range.json \
761770
dist/fapi-profiles/P_ECCP256SHA256-low-range.json \
762-
dist/sysusers.d/tpm2-tss.conf \
771+
dist/sysusers.d/tpm2-tss.conf.fully-locked \
772+
dist/sysusers.d/tpm2-tss.conf.not-fully-locked \
763773
dist/tmpfiles.d/tpm2-tss-fapi.conf.in \
764774
doc/fapi-config.md \
765775
doc/fapi-profile.md \

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SPDX-FileCopyrightText = "2019-2022 Fraunhofer SIT sponsored by Infineon"
2626
SPDX-License-Identifier = "BSD-2-Clause"
2727

2828
[[annotations]]
29-
path = "dist/sysusers.d/tpm2-tss.conf"
29+
path = ["dist/sysusers.d/tpm2-tss.conf.fully-locked", "dist/sysusers.d/tpm2-tss.conf.not-fully-locked"]
3030
precedence = "aggregate"
3131
SPDX-FileCopyrightText = "2020 Jonas Witschel"
3232
SPDX-License-Identifier = "BSD-2-Clause"

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,14 @@ AS_IF([test "x$enable_integration" = "xyes" && test "x$enable_self_generated_cer
655655
# Check for systemd helper tools used by make install
656656
AC_CHECK_PROG(systemd_sysusers, systemd-sysusers, yes)
657657
AM_CONDITIONAL([SYSD_SYSUSERS], [test "x$systemd_sysusers" = "xyes" && test "x$sysusersdir" != "xno"])
658+
659+
systemd_sysusers_fully_locked=no
660+
AS_IF([test "x$systemd_sysusers" = "xyes"],
661+
[PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd >= 257],
662+
[systemd_sysusers_fully_locked=yes],
663+
[systemd_sysusers_fully_locked=no])])
664+
AM_CONDITIONAL([SYSD_SYSUSERS_FULLY_LOCKED], [test "x$systemd_sysusers_fully_locked" = "xyes"])
665+
658666
AC_CHECK_PROG(systemd_tmpfiles, systemd-tmpfiles, yes)
659667
AM_CONDITIONAL([SYSD_TMPFILES], [test "x$systemd_tmpfiles" = "xyes" && test "x$tmpfilesdir" != "xno"])
660668

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Type Name ID GECOS Home directory Shell
2+
u! tss - "tss user for tpm2"
File renamed without changes.

0 commit comments

Comments
 (0)