diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2022-09-07 13:29:51 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2022-09-07 13:29:51 +0300 |
commit | bd179055cd591fa47f4be21cc08f71195656f789 (patch) | |
tree | c7455211236393f173660c284d44dbc69fc656ce /bin | |
parent | d8ea00662a931b438fa984b12d50387cd9f3c397 (diff) | |
download | arching-kaos-tools-bd179055cd591fa47f4be21cc08f71195656f789.tar.gz arching-kaos-tools-bd179055cd591fa47f4be21cc08f71195656f789.tar.bz2 arching-kaos-tools-bd179055cd591fa47f4be21cc08f71195656f789.zip |
Added some checks to make sure zblocks are zblocks and blocks are blocks
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/enter | 47 |
1 files changed, 45 insertions, 2 deletions
@@ -137,7 +137,33 @@ do # We concatenate the zblock's contents, pipe them through filter # json2bash and output them to tmp-file ipfs cat $zblock | json2bash > $TEMPASSIN/tmp-zblock - logthis "[INFO]" "ZBLOCK $zblock READ" + if [ "$?" == 0 ] + then + logthis "[INFO]" "ZBLOCK $zblock READ" + else + logthis "[ERROR]" "ZBLOCK $zblock READ failed" + exit 1 + fi + + # Be sure that there are the expected values + # We need 'block' and 'block_signature' inside a 'zblock' + # Exit if any is missing + grep -e 'block_signature' $TEMPASSIN/tmp-zblock > /dev/null 2>&1 + if [ "$?" == 0 ] + then + logthis "[INFO]" "ZBLOCK $zblock has block_signature" + else + logthis "[ERROR]" "ZBLOCK $zblock has no block_signature" + exit 1 + fi + grep -e 'block=' $TEMPASSIN/tmp-zblock > /dev/null 2>&1 + if [ "$?" == 0 ] + then + logthis "[INFO]" "ZBLOCK $zblock has block" + else + logthis "[ERROR]" "ZBLOCK $zblock has no block" + exit 1 + fi # Supposingly you are on a safe environment and you only have # access to your chain, I would consider mild secure to source @@ -150,6 +176,23 @@ do # BLOCKS echo '"block":"'$block'",' ipfs cat $block | json2bash > $TEMPASSIN/tmp-block + if [ "$?" == 0 ] + then + logthis "[INFO]" "BLOCK $block READ" + else + logthis "[ERROR]" "BLOCK $block READ failed" + exit 1 + fi + + grep -e 'timestamp' -e 'gpg' -e 'data' -e 'action' -e 'detach' -e 'previous' $TEMPASSIN/tmp-block > /dev/null 2>&1 + if [ "$?" == 0 ] + then + logthis "[INFO]" "BLOCK $block is a block" + else + logthis "[ERROR]" "BLOCK $block is NOT a valid block" + exit 1 + fi + source $TEMPASSIN/tmp-block logthis "[INFO]" "BLOCK $block SOURCED" touch $BLOCKDIR/$block @@ -184,7 +227,7 @@ do logthis "[ERROR]" "Could not get GPG key: $gpg ." exit 1 fi - ipfs get $block_signature > /dev/null 2>&1 + ipfs get $block_signature > /dev/null 2>&1 if [ "$?" == 0 ] then mv $block_signature $block.asc |