blob: 34e5ecf1eeeffa163304e886c35cf22c58331562 [file] [log] [blame]
#!/bin/sh
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if [ -z "${LOCKBOX_CACHE_DIR}" ]; then
echo "LOCKBOX_CACHE_DIR is unset";
exit 1
fi
if [ -z "${LOCKBOX_NVRAM_FILE}" ]; then
echo "LOCKBOX_NVRAM_FILE is unset";
exit 1
fi
if [ -z "${INSTALL_ATTRS_CACHE}" ]; then
echo "INSTALL_ATTRS_CACHE is unset";
exit 1
fi
if [ -z "${INSTALL_ATTRS_FILE}" ]; then
echo "INSTALL_ATTRS_FILE is unset";
exit 1
fi
umask 022
mkdir -p -m 0711 "${LOCKBOX_CACHE_DIR}"
LOCKBOX_INDEX=0x9da5b0
# Use tpm_manager to read the NV space.
/usr/bin/gdbus wait --system -t 15 org.chromium.TpmManager
tpm_manager_client read_space --index="${LOCKBOX_INDEX}" \
--file="${LOCKBOX_NVRAM_FILE}"
# If the nvram file is not empty.
if [ -s "${LOCKBOX_NVRAM_FILE}" ]; then
lockbox-cache --cache="${INSTALL_ATTRS_CACHE}" \
--nvram="${LOCKBOX_NVRAM_FILE}" \
--lockbox="${INSTALL_ATTRS_FILE}"
fi
# There are no other consumers; remove the nvram data.
rm "${LOCKBOX_NVRAM_FILE}"