summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-01-19 15:52:37 +0100
committerSimon Rettberg2024-01-19 15:52:37 +0100
commitff2787b613a7db70b979ee09284bdc713681a1ec (patch)
treed9a94b14f662b4a4a226854d16a754d5fc2e74c8
parent[run-virt] Make copy of downloaded vmx before passing it on to plugins (diff)
downloadmltk-ff2787b613a7db70b979ee09284bdc713681a1ec.tar.gz
mltk-ff2787b613a7db70b979ee09284bdc713681a1ec.tar.xz
mltk-ff2787b613a7db70b979ee09284bdc713681a1ec.zip
[vmware-common] Improve handling of syntax errors in vmx
-rw-r--r--core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc
index f8eb7d5d..e19d5a4e 100644
--- a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc
+++ b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc
@@ -7,14 +7,16 @@ parse_vmx() {
# it before continuing with filling in the gaps
local TMPTMPCONFIG="$(mktemp)"
grep -E '^\s*(#|[^=]+=[^"]*"[^"]*"\s*$|[^=]+=[^"]+$|$)' "$TMPCONFIG" > "$TMPTMPCONFIG"
- if ! diff -q "$TMPCONFIG" "$TMPTMPCONFIG"; then
+ if ! cmp -s "$TMPCONFIG" "$TMPTMPCONFIG"; then
# file was corrupted, log it
writelog "'$TMPCONFIG' had bad syntax and was pruned by the post-download sanitizer!"
- slxlog -s "virt-vmware-vmx-corrupt" "Downloaded .vmx for '$IMGUUID' has a corrupted format!" "$TMPCONFIG"
+ slxlog -s "virt-vmware-vmx-corrupt" "Downloaded .vmx for '$IMGUUID' has lines with invalid syntax!" "$TMPCONFIG"
+ mv -f -- "$TMPTMPCONFIG" "$TMPCONFIG"
+ else
+ rm -f -- "$TMPTMPCONFIG"
fi
- mv -f -- "$TMPTMPCONFIG" "$TMPCONFIG"
- writelog "Parsing virtual machine description file..."
+ writelog "Parsing virtual machine description file for hwVersion..."
local -i HW_VERSION=$(grep -i -m1 '^virtualHW.version *= *' "${TMPCONFIG}" | awk -F '=' '{print $2}' | sed -r 's/[^0-9]//g')
if notempty HW_VERSION; then
declare -g VM_HW_VERSION="${HW_VERSION}"