From f3501cbe8c989f620c1b3ff52249232c6ca4e5a3 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sun, 14 Apr 2019 00:19:38 +0300 Subject: [PATCH] OcStorageLib: Fix vault.plist format --- Library/OcStorageLib/OcStorageLib.c | 10 +++------- Tools/Vault/create_vault.sh | 10 +++++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Library/OcStorageLib/OcStorageLib.c b/Library/OcStorageLib/OcStorageLib.c index 6d1af304..346b3dc4 100644 --- a/Library/OcStorageLib/OcStorageLib.c +++ b/Library/OcStorageLib/OcStorageLib.c @@ -31,11 +31,7 @@ OC_STRUCTORS (OC_STORAGE_VAULT, ()) STATIC OC_SCHEMA -mVaultFilesEntrySchema = OC_SCHEMA_DATAF (NULL, UINT8 [SHA256_DIGEST_SIZE]); - -STATIC -OC_SCHEMA -mVaultFilesSchema = OC_SCHEMA_MAP (NULL, &mVaultFilesEntrySchema); +mVaultFilesSchema = OC_SCHEMA_DATAF (NULL, UINT8 [SHA256_DIGEST_SIZE]); /// /// WARNING: Field list must be alpabetically ordered here! @@ -269,7 +265,7 @@ OcStorageReadFileUnicode ( VaultDigest = OcStorageGetDigest (Context, FilePath); if (Context->HasVault && VaultDigest == NULL) { - DEBUG ((DEBUG_ERROR, "OCS: Aborting %s file access not present in vault", FilePath)); + DEBUG ((DEBUG_ERROR, "OCS: Aborting %s file access not present in vault\n", FilePath)); return NULL; } @@ -314,7 +310,7 @@ OcStorageReadFileUnicode ( if (VaultDigest != 0) { Sha256 (FileDigest, FileBuffer, Size); if (CompareMem (FileDigest, VaultDigest, SHA256_DIGEST_SIZE) != 0) { - DEBUG ((DEBUG_ERROR, "OCS: Aborting corrupted %s file access", FilePath)); + DEBUG ((DEBUG_ERROR, "OCS: Aborting corrupted %s file access\n", FilePath)); FreePool (FileBuffer); return NULL; } diff --git a/Tools/Vault/create_vault.sh b/Tools/Vault/create_vault.sh index 88ed01be..dad1b091 100755 --- a/Tools/Vault/create_vault.sh +++ b/Tools/Vault/create_vault.sh @@ -17,7 +17,7 @@ if [ ! -d "${OCPath}" ]; then exit 1 fi -if [ ! -x /usr/bin/find ] || [ ! -x /bin/rm ] || [ ! -x /usr/bin/sed ]; then +if [ ! -x /usr/bin/find ] || [ ! -x /bin/rm ] || [ ! -x /usr/bin/sed ] || [ ! -x /usr/bin/xxd ]; then echo "Unix environment is broken!" exit 1 fi @@ -33,7 +33,7 @@ if [ ! -x /usr/bin/shasum ]; then fi abort() { - /bin/rm -rf vault.plist vault.sig + /bin/rm -rf vault.plist vault.sig /tmp/vault_hash echo "Fatal error: ${1}!" exit 1 } @@ -59,8 +59,12 @@ echo "Hashing files in ${OCPath}..." fi echo "${wname}: ${sha}" - /usr/libexec/PlistBuddy -c "Add Files:'${wname}' data ${sha}" vault.plist || abort "Failed to append vault.plist!" + + echo "${sha}" | /usr/bin/xxd -r -p > /tmp/vault_hash || abort "Hashing failure" + /usr/libexec/PlistBuddy -c "Import Files:'${wname}' /tmp/vault_hash" vault.plist || abort "Failed to append vault.plist!" done +/bin/rm -rf /tmp/vault_hash + echo "All done!" exit 0