[go: nahoru, domu]

FAPI: use only tmpfiles.d to create keystore and eventlog directory

Using chown in make install is problematic because the user and group
are not guaranteed to exist and this approach does not work for
packaging. Use the already existing tmpfiles.d configuration to adjust
the owner and mode instead.

On the other hand, installing files to runstatedir does not make sense
since this directory might be cleaned on reboot. Since this directory is
already created by tmpfiles.d, remove the unnecessary installation
instruction.

Signed-off-by: Jonas Witschel <diabonas@gmx.de>
diff --git a/Makefile.am b/Makefile.am
index 4a3e926..afc491b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -413,6 +413,7 @@
 # We have to do this ourselves, in order to get absolute paths
 fapi-tmpfiles.conf: dist/fapi-tmpfiles.conf.in
 	$(AM_V_GEN) $(SED) \
+		-e 's|[@]localstatedir@|$(localstatedir)|g' \
 		-e 's|[@]runstatedir@|$(runstatedir)|g' \
 		< "$<" > "$@"
 
@@ -423,14 +424,6 @@
 fapiprofiles_DATA = dist/fapi-profiles/P_RSA2048SHA256.json \
                     dist/fapi-profiles/P_ECCP256SHA256.json
 
-EXTRA_DIST += dist/keep
-
-fapikeystoredir = @localstatedir@/tpm2-tss/system/keystore
-fapikeystore_DATA = dist/keep
-
-fapieventlogdir = @runstatedir@/tpm2-tss/eventlog
-fapieventlog_DATA = dist/keep
-
 libtss2_fapi = src/tss2-fapi/libtss2-fapi.la
 tss2_HEADERS += $(srcdir)/include/tss2/tss2_fapi.h
 lib_LTLIBRARIES += $(libtss2_fapi)
@@ -561,11 +554,6 @@
 	-rm $(DESTDIR)$(udevrulesdir)/$(udevrulesprefix)tpm-udev.rules
 endif
 
-install-exec-hook:
-	[ -d "$(DESTDIR)$(fapikeystoredir)" ] && \
-		chown tss:tss "$(DESTDIR)$(fapikeystoredir)" && \
-		chmod 775 "$(DESTDIR)$(fapikeystoredir)" || true
-
 uninstall-hook:
 	cd $(DESTDIR)$(man3dir) && \
 		[ -L Tss2_TctiLdr_Initialize_Ex.3 ] && \
diff --git a/configure.ac b/configure.ac
index 383f14d..9aa00c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,7 +64,7 @@
 
 AC_ARG_WITH([tmpfilesdir],
             [AS_HELP_STRING([--with-tmpfilesdir=<dir>],
-                            [sets the tpmfiles.d directory (default is "${sysconfdir}/tmpfiles.d")])],,
+                            [sets the tmpfiles.d directory (default is "${sysconfdir}/tmpfiles.d")])],,
             [with_tmpfilesdir="${sysconfdir}/tmpfiles.d"])
 AC_SUBST(tmpfilesdir, $with_tmpfilesdir)
 
diff --git a/dist/fapi-tmpfiles.conf.in b/dist/fapi-tmpfiles.conf.in
index c49a874..35c5ae2 100644
--- a/dist/fapi-tmpfiles.conf.in
+++ b/dist/fapi-tmpfiles.conf.in
@@ -1,2 +1,3 @@
-#Type   Path                                    Mode User Group Age         Argument
-d       @runstatedir@/tpm2-tss/eventlog/        775  tss  tss   -           -
+#Type   Path                                       Mode User Group Age         Argument
+d       @localstatedir@/tpm2-tss/system/keystore   775  tss  tss   -           -
+d       @runstatedir@/tpm2-tss/eventlog            775  tss  tss   -           -
diff --git a/dist/keep b/dist/keep
deleted file mode 100644
index 58293ad..0000000
--- a/dist/keep
+++ /dev/null
@@ -1 +0,0 @@
-Placeholder to create and keep directory