From 2547cb6cce7823a1758fb7a4994e89f78e2dfc38 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Tue, 9 Nov 2021 08:32:04 -0500 Subject: [PATCH] This initial commit updates the location of the vendor-table.json which is used by the ACA and the eventlog tool. The previous change moved the vendor-table.json to a separate folder, however the code was not updated to reflect the change. This instead updates how the two install handle the file. The ACA was updated not to clobber the file if it exists and the eventlog tool was updated to do the same through an additional script called post install. --- package/rpm/HIRS.spec | 4 ++-- tools/tcg_eventlog_tool/README.md | 2 +- tools/tcg_eventlog_tool/build.gradle | 4 +++- .../tcg_eventlog_tool/scripts/vendor-table.sh | 22 +++++++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 tools/tcg_eventlog_tool/scripts/vendor-table.sh diff --git a/package/rpm/HIRS.spec b/package/rpm/HIRS.spec index aca84d8c..49d6a2ff 100644 --- a/package/rpm/HIRS.spec +++ b/package/rpm/HIRS.spec @@ -260,7 +260,7 @@ fi %attr(664, root, tomcat) /opt/hirs/default-properties/attestationca/banner.properties %attr(664, root, tomcat) /opt/hirs/default-properties/attestationca/persistence.properties %attr(664, root, tomcat) /opt/hirs/default-properties/component-class.json -%attr(664, root, tomcat) /opt/hirs/default-properties/attestationca/vendor-table.json +%attr(664, root, tomcat) /opt/hirs/default-properties/vendor-table.json %attr(774, root, tomcat) /opt/hirs/scripts/common/aca %attr(774, root, tomcat) /opt/hirs/scripts/aca %attr(774, root, tomcat) /opt/hirs/extras/aca/tomcat-mysql-hirs.pp @@ -330,7 +330,7 @@ cp HIRS_Utils/src/main/resources/persistence.properties %{buildroot}/opt/hirs/de cp HIRS_Utils/src/main/resources/logging.properties %{buildroot}/opt/hirs/default-properties/attestationca/ cp HIRS_Utils/src/main/resources/banner.properties %{buildroot}/opt/hirs/default-properties/attestationca/ cp HIRS_Utils/src/main/resources/component-class.json %{buildroot}/opt/hirs/default-properties/ -cp HIRS_Utils/src/main/resources/vendor-table.json %{buildroot}/opt/hirs/default-properties/attestationca/ +cp -n HIRS_Utils/src/main/resources/vendor-table.json %{buildroot}/opt/hirs/default-properties/ # install extras mkdir -p %{buildroot}/opt/hirs/extras diff --git a/tools/tcg_eventlog_tool/README.md b/tools/tcg_eventlog_tool/README.md index 18b23b33..b9532fbf 100644 --- a/tools/tcg_eventlog_tool/README.md +++ b/tools/tcg_eventlog_tool/README.md @@ -31,7 +31,7 @@ In both cases the tcg_eventlog_tool-X.X.jar file should have been placed in the Currenty only a install file for Linux RPM is supported. To create an RPM on a linux device use the following command in the dame directory: -> ./gradlew builRPM +> ./gradlew buildRPM # Installing Currenty only a install package for Linux is supported. diff --git a/tools/tcg_eventlog_tool/build.gradle b/tools/tcg_eventlog_tool/build.gradle index 3eb66a6b..1751e3ef 100644 --- a/tools/tcg_eventlog_tool/build.gradle +++ b/tools/tcg_eventlog_tool/build.gradle @@ -108,7 +108,7 @@ ospackage { link("/usr/local/bin/elt", "/opt/hirs/eventlog/scripts/eventlog.sh", 0x755) } - into('/opt/hirs/default-properties/eventlogtool') { + into('/tmp/') { fileMode 0664 from ('../../HIRS_Utils/src/main/resources/vendor-table.json') { addParentDirs true @@ -116,6 +116,8 @@ ospackage { } } + postInstall file('scripts/vendor-table.sh') + buildRpm { arch = I386 } diff --git a/tools/tcg_eventlog_tool/scripts/vendor-table.sh b/tools/tcg_eventlog_tool/scripts/vendor-table.sh new file mode 100644 index 00000000..24446253 --- /dev/null +++ b/tools/tcg_eventlog_tool/scripts/vendor-table.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +HIRS_DIR="/opt/hirs/default-properties" +VENDOR_FILE="vendor-table.json" + +# check that the directory exists +if [ ! -d "$HIRS_DIR" ]; then + mkdir -p $HIRS_DIR +fi + +# in case there was a problem, still check and if all is well +# move the file with no-clobber +if [ -d "$HIRS_DIR" ]; then + # if the file doesn't exist + if [ ! -f "$HIRS_DIR/$VENDOR_FILE" ]; then + mv -n "/tmp/$VENDOR_FILE" $HIRS_DIR + chmod 0644 "$HIRS_DIR/$VENDOR_FILE" + else + # if it does, then just remove the tmp folder version + rm "/tmp/$VENDOR_FILE" + fi +fi \ No newline at end of file