OcStorageLib: Fix vault.plist format

This commit is contained in:
vit9696 2019-04-14 00:19:38 +03:00
parent 02edee8a87
commit f3501cbe8c
2 changed files with 10 additions and 10 deletions

View File

@ -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;
}

View File

@ -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