Skip to content

Commit

Permalink
set_xva_bridge: set owner and permissions in tar command
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Tu Dinh committed Jan 10, 2025
1 parent 9f9c1e2 commit f227499
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions scripts/set_xva_bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/<member><name>bridge<\/name><value>[^<]*<\/value><\/member>/<member><name>bridge<\/name><value>${BRIDGE_VALUE}<\/value><\/member>/g" ${TMPFOLDER}/ova.xml
chmod -rw "${TMPFOLDER}/ova.xml"
sed -i "s/<member><name>bridge<\/name><value>[^<]*<\/value><\/member>/<member><name>bridge<\/name><value>${BRIDGE_VALUE}<\/value><\/member>/g" "${TMPFOLDER}/ova.xml"
else
echo "Error: File ova.xml not found during the sed."
exit 1
Expand All @@ -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
Expand Down

0 comments on commit f227499

Please sign in to comment.