Skip to content

Commit

Permalink
Fixes #1611.
Browse files Browse the repository at this point in the history
Adapted `Makefile.am` to create 'tss' user and group as well as all FAPI
directories manually as a fallback solution, in case systemd is not available on the
system, such as in Docker (by default).

Included requested changes.

Signed-off-by: Michael Eckel <michael.eckel@sit.fraunhofer.de>
  • Loading branch information
eckelmeckel authored and tstruk committed May 12, 2020
1 parent 1074bdc commit 9965232
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,36 @@ endif #DOXYMAN

endif #FAPI

### Helper Functions ###
define make_parent_dir
if [ ! -d $(dir $1) ]; then mkdir -p $(dir $1); fi
endef

define make_tss_user_and_group
(id -g tss || groupadd -r tss) && \
(id -u tss || useradd -r -g tss tss)
endef

define make_tss_dir
($(call make_parent_dir,$1))
endef

define set_tss_permissions
(chown -R tss:tss "$1") && \
(chmod -R 775 "$1")
endef

define make_fapi_dirs
($(call make_tss_dir,$(DESTDIR)$(runstatedir)/tpm2-tss/eventlog/) || true) && \
($(call make_tss_dir,$(DESTDIR)$(localstatedir)/lib/tpm2-tss/system/keystore/))
endef

define set_fapi_permissions
($(call set_tss_permissions,$(DESTDIR)$(runstatedir)/tpm2-tss)
($(call set_tss_permissions,$(DESTDIR)$(localstatedir)/lib/tpm2-tss)
endef


### Man Pages
man3_MANS = \
man/man3/Tss2_Tcti_Device_Init.3 \
Expand Down Expand Up @@ -560,7 +590,8 @@ endif

# Create tss user and FAPI directories directly after installation (vs. after a reboot)
install-exec-hook:
systemd-sysusers && systemd-tmpfiles --create || true
(systemd-sysusers && systemd-tmpfiles --create) || \
($(call make_tss_user_and_group) && $(call make_fapi_dirs) && ($call set_fapi_permissions)) || true

uninstall-hook:
cd $(DESTDIR)$(man3dir) && \
Expand Down Expand Up @@ -588,11 +619,6 @@ CLEANFILES += \
$(man3_MANS) \
$(man7_MANS)

### Helper Functions ###
define make_parent_dir
if [ ! -d $(dir $1) ]; then mkdir -p $(dir $1); fi
endef

# function to transform man .in files to man pages
# $1: target
# $2: .in file
Expand Down

0 comments on commit 9965232

Please sign in to comment.