From patchwork Mon Nov 30 06:42:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Murray X-Patchwork-Id: 106351 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.27380.1796021014745885101 for ; Sun, 29 Nov 2026 22:43:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@konsulko.com header.s=google header.b=saE8//L8; spf=pass (domain: konsulko.com, ip: 209.85.221.49, mailfrom: scott.murray@konsulko.com) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-498f5fa4f70so8460466f8f.0 for ; Sun, 29 Nov 2026 22:43:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1796021013; x=1796625813; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=vTkbdm+KTABNBOysf7xEzGVD3j3UBzxGm0f7wUM8yss=; b=saE8//L8tfjQLW8AXH9F3auK7lgCTS5+9Xlb0hKF7RcsWVqY/6oLvyxt1fKR8nDAHE ouHJ30TlPadyiS/S/3z+c7SyYnLVytA/XZxNvtxkDIWBnn1GqTKuYPZ5U57r494+fSEl SswJLOlonW5H3Cb97XwU6PN5ThpeTBCwsGwrk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796021013; x=1796625813; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=vTkbdm+KTABNBOysf7xEzGVD3j3UBzxGm0f7wUM8yss=; b=eK6RiGaFAMBfzDAL7vb6/NoSx8YqlLm1k7WMSjVFC3y9dtNLw+lWKWWKVkUbKNR/lV wKRJS/EWD0uBTDAW5e8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M9Su7QVXIWNibuN/ku 4NUx6nRJn7by6WXx/FENKSpthnP5kAQ== X-Received: by 2002:a5d:5888:0:b0:487:1ac0:32af with SMTP id ffacd0b85a97d-4abb47b0fb1mr60894738f8f.51.1796021012703; Sun, 29 Nov 2026 22:43:32 -0800 (PST) Return-Path: Received: from tone.k.g (lan.nucleusys.com. [92.247.61.126]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab65cb41f4sm60434756f8f.7.2026.11.29.22.43.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 22:43:32 -0800 (PST) From: Scott Murray To: yocto-patches@lists.yoctoproject.org Subject: [meta-security][scarthgap][PATCH 04/27] swtpm: backport sysusers and tmpfiles support Date: Mon, 30 Nov 2026 08:42:49 +0200 Message-ID: <03292b5784f988f3d9b3db5f567face473e81cff.1796019369.git.scott.murray@konsulko.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Mon, 30 Nov 2026 06:43:39 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5604 From: Niranjan Reddy Mekala Backport the upstream sysusers.d and tmpfiles.d integration to provision the tss user and /var/lib/swtpm-localca declaratively. Also backport the follow-up change that aligns the tss sysusers definition with tpm2-tss to avoid conflicting definitions. Package the generated sysusers.d and tmpfiles.d configuration files. Signed-off-by: Niranjan Reddy Mekala (adapted to 0.8.2) Signed-off-by: Scott Murray --- ...ll-sysusers.d-and-tmpfiles.d-configs.patch | 89 +++++++++++++++++++ ...2-swtpm-sync-sysuser.d-with-tpm2-tss.patch | 29 ++++++ meta-tpm/recipes-tpm/swtpm/swtpm_0.8.2.bb | 9 +- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 meta-tpm/recipes-tpm/swtpm/swtpm/0001-swtpm-install-sysusers.d-and-tmpfiles.d-configs.patch create mode 100644 meta-tpm/recipes-tpm/swtpm/swtpm/0002-swtpm-sync-sysuser.d-with-tpm2-tss.patch diff --git a/meta-tpm/recipes-tpm/swtpm/swtpm/0001-swtpm-install-sysusers.d-and-tmpfiles.d-configs.patch b/meta-tpm/recipes-tpm/swtpm/swtpm/0001-swtpm-install-sysusers.d-and-tmpfiles.d-configs.patch new file mode 100644 index 0000000..877abc6 --- /dev/null +++ b/meta-tpm/recipes-tpm/swtpm/swtpm/0001-swtpm-install-sysusers.d-and-tmpfiles.d-configs.patch @@ -0,0 +1,89 @@ +From 9b9ad2cad821df4dff4ce032cfeafdefdaab850c Mon Sep 17 00:00:00 2001 +From: Luca Boccassi +Date: Mon, 22 Sep 2025 17:56:24 +0100 +Subject: [PATCH] swtpm: install sysusers.d and tmpfiles.d configs + +These configuration files will create the required user, group and +data directory on first boot/factory reset/package installation, +without requiring manual scripts or actions. This is very important +for image-based OSes, but it is useful in other cases to, to allow +using declarative configuration instead of scripts. + +RPM now has built-in support for sysusers.d too. + +https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html +https://www.freedesktop.org/software/systemd/man/latest/sysusers.d.html + +Signed-off-by: Luca Boccassi +Upstream-Status: Backport [https://github.com/stefanberger/swtpm/commit/d318d40469474eb8f3ccc4a6e9fe0ba100814e20] +--- + .gitignore | 2 ++ + configure.ac | 2 ++ + src/Makefile.am | 10 ++++++++++ + src/swtpm-sysusers.conf.in | 1 + + src/swtpm-tmpfiles.conf.in | 1 + + 5 files changed, 16 insertions(+) + create mode 100644 src/swtpm-sysusers.conf.in + create mode 100644 src/swtpm-tmpfiles.conf.in + +diff --git a/.gitignore b/.gitignore +index 648c270..130cd95 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -60,6 +60,8 @@ Makefile + /src/swtpm_ioctl/swtpm_ioctl + /src/swtpm_localca/swtpm_localca + /src/swtpm_localca/swtpm_localca_conf.h ++/src/swtpm-sysusers.conf ++/src/swtpm-tmpfiles.conf + src/swtpm_setup/swtpm_setup + src/swtpm_setup/swtpm_setup_conf.h + /test-driver +diff --git a/configure.ac b/configure.ac +index a2c2a0c..ccf8e6c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -622,6 +622,8 @@ AC_CONFIG_FILES([Makefile \ + src/swtpm_localca/swtpm_localca_conf.h \ + src/swtpm_setup/Makefile \ + src/swtpm_setup/swtpm_setup_conf.h \ ++ src/swtpm-sysusers.conf \ ++ src/swtpm-tmpfiles.conf \ + src/utils/Makefile \ + man/Makefile \ + man/man3/Makefile \ +diff --git a/src/Makefile.am b/src/Makefile.am +index 9e03c78..c36d5cc 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -17,3 +17,13 @@ if WITH_SELINUX + SUBDIRS += \ + selinux + endif ++ ++sysusersdir = $(prefix)/lib/sysusers.d ++sysusers_DATA = swtpm-sysusers.conf ++ ++tmpfilesdir = $(prefix)/lib/tmpfiles.d ++tmpfiles_DATA = swtpm-tmpfiles.conf ++ ++EXTRA_DIST = \ ++ swtpm-sysusers.conf \ ++ swtpm-tmpfiles.conf +diff --git a/src/swtpm-sysusers.conf.in b/src/swtpm-sysusers.conf.in +new file mode 100644 +index 0000000..0b02ca4 +--- /dev/null ++++ b/src/swtpm-sysusers.conf.in +@@ -0,0 +1 @@ ++u! @TSS_USER@ - "TPM software stack" @LOCALSTATEDIR@/lib/swtpm-localca +diff --git a/src/swtpm-tmpfiles.conf.in b/src/swtpm-tmpfiles.conf.in +new file mode 100644 +index 0000000..afe2d13 +--- /dev/null ++++ b/src/swtpm-tmpfiles.conf.in +@@ -0,0 +1 @@ ++d @LOCALSTATEDIR@/lib/swtpm-localca 0750 @TSS_USER@ root +-- +2.47.3 + diff --git a/meta-tpm/recipes-tpm/swtpm/swtpm/0002-swtpm-sync-sysuser.d-with-tpm2-tss.patch b/meta-tpm/recipes-tpm/swtpm/swtpm/0002-swtpm-sync-sysuser.d-with-tpm2-tss.patch new file mode 100644 index 0000000..edc0402 --- /dev/null +++ b/meta-tpm/recipes-tpm/swtpm/swtpm/0002-swtpm-sync-sysuser.d-with-tpm2-tss.patch @@ -0,0 +1,29 @@ +From b64b114c9c6941d9729fcc2ad511f108a3affaef Mon Sep 17 00:00:00 2001 +From: Luca Boccassi +Date: Wed, 7 Oct 2026 08:29:09 +0200 +Subject: [PATCH] swtpm: sync sysuser.d with tpm2-tss + +tpm2-tss has shipped a sysusers.d file since 2019 for the tss user: + +https://github.com/tpm2-software/tpm2-tss/commit/c43f3c2190eb06e731c5bf7c2849d07f5f8503a5 + +When two sysusers.d configs have a conflict, the tool raises a warning, +and the result depends on alphabetic sorting of the config names which +isn't great. Sync the content: drop the '!', drop the homedir (not used +anyway) and modify the GECOS string. + +Fixes: d318d4046947 ("swtpm: install sysusers.d and tmpfiles.d configs") + +Signed-off-by: Luca Boccassi +Upstream-Status: Backport [https://github.com/stefanberger/swtpm/commit/b64b114c9c6941d9729fcc2ad511f108a3affaef] +--- + src/swtpm-sysusers.conf.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/swtpm-sysusers.conf.in b/src/swtpm-sysusers.conf.in +index 0b02ca4..a9a1779 100644 +--- a/src/swtpm-sysusers.conf.in ++++ b/src/swtpm-sysusers.conf.in +@@ -1 +1 @@ +-u! @TSS_USER@ - "TPM software stack" @LOCALSTATEDIR@/lib/swtpm-localca ++u @TSS_USER@ - "tss user for tpm2" diff --git a/meta-tpm/recipes-tpm/swtpm/swtpm_0.8.2.bb b/meta-tpm/recipes-tpm/swtpm/swtpm_0.8.2.bb index 1c48eae..102e2c3 100644 --- a/meta-tpm/recipes-tpm/swtpm/swtpm_0.8.2.bb +++ b/meta-tpm/recipes-tpm/swtpm/swtpm_0.8.2.bb @@ -7,7 +7,10 @@ SECTION = "apps" DEPENDS = "libtasn1 coreutils-native expect-native socat-native glib-2.0 net-tools-native libtpm json-glib" SRCREV = "507d14219dde88eb3eb2d10d15872d4044aa9d3e" -SRC_URI = "git://github.com/stefanberger/swtpm.git;branch=stable-0.8;protocol=https" +SRC_URI = "git://github.com/stefanberger/swtpm.git;branch=stable-0.8;protocol=https \ + file://0001-swtpm-install-sysusers.d-and-tmpfiles.d-configs.patch \ + file://0002-swtpm-sync-sysuser.d-with-tpm2-tss.patch \ + " PE = "1" S = "${WORKDIR}/git" @@ -41,6 +44,10 @@ USERADD_PARAM:${PN} = "--system -g ${TSS_GROUP} --home-dir / \ PACKAGE_BEFORE_PN = "${PN}-cuse" FILES:${PN}-cuse = "${bindir}/swtpm_cuse" +FILES:${PN} += " \ + ${libdir}/sysusers.d/swtpm-sysusers.conf \ + ${libdir}/tmpfiles.d/swtpm-tmpfiles.conf \ +" INSANE_SKIP:${PN} += "dev-so"