From f2274993fc73d9784478278193536fb39bfc5ef6 Mon Sep 17 00:00:00 2001 From: Tu Dinh Date: Fri, 10 Jan 2025 17:51:28 +0100 Subject: [PATCH] set_xva_bridge: set owner and permissions in tar command Erase the output archive members' owner and permissions directly through tar command line. Make extracted temp files readable with chmod to avoid using sudo for reading input files. Signed-off-by: Tu Dinh --- scripts/set_xva_bridge.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/set_xva_bridge.sh b/scripts/set_xva_bridge.sh index 14eb238c..7f3e97c6 100755 --- a/scripts/set_xva_bridge.sh +++ b/scripts/set_xva_bridge.sh @@ -105,10 +105,10 @@ else exit 1 fi +chmod -R u+rX "${TMPFOLDER}" + if [ -e "${TMPFOLDER}/ova.xml" ]; then - chmod +rw "${TMPFOLDER}/ova.xml" - sed -i "s/bridge<\/name>[^<]*<\/value><\/member>/bridge<\/name>${BRIDGE_VALUE}<\/value><\/member>/g" ${TMPFOLDER}/ova.xml - chmod -rw "${TMPFOLDER}/ova.xml" + sed -i "s/bridge<\/name>[^<]*<\/value><\/member>/bridge<\/name>${BRIDGE_VALUE}<\/value><\/member>/g" "${TMPFOLDER}/ova.xml" else echo "Error: File ova.xml not found during the sed." exit 1 @@ -118,15 +118,11 @@ fi # save first file mv "${XVA_NAME}" "${XVA_NAME}.save" -# create xva -cd "${TMPFOLDER}" - # Create the new XVA -sudo tar -cv --${COMPRESS_METHOD} -f ${XVA_NAME} --no-recursion -T ${TMP_LIST} +tar -C "${TMPFOLDER}" --${COMPRESS_METHOD} -cf "${XVA_NAME}" --no-recursion -T "${TMP_LIST}" --numeric-owner --owner=:0 --group=:0 --mode=ugo= --mtime=@0 rm -f "${TMP_LIST}" # clean TMPFOLDER -cd .. if [ -d "${TMPFOLDER}" ]; then rm -Rf "${TMPFOLDER}" else