diff options
author | Jonathan Bauer | 2017-12-04 17:37:43 +0100 |
---|---|---|
committer | Jonathan Bauer | 2017-12-04 17:37:43 +0100 |
commit | a929da2e0be341ce0306b3d6245e3f5a07bee7e6 (patch) | |
tree | 81ba78c0e258d66fb1db6136bde4fb9d0e825d07 /core/modules/vmware | |
parent | [run-virt] more robust translation of / to \ (diff) | |
download | mltk-a929da2e0be341ce0306b3d6245e3f5a07bee7e6.tar.gz mltk-a929da2e0be341ce0306b3d6245e3f5a07bee7e6.tar.xz mltk-a929da2e0be341ce0306b3d6245e3f5a07bee7e6.zip |
[vmware] vmx pruning
Diffstat (limited to 'core/modules/vmware')
-rw-r--r-- | core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc b/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc index 6ca82acb..47330bb0 100644 --- a/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc +++ b/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/parse_vmx.inc @@ -3,6 +3,17 @@ ###################################################################### ## Functions parse_vmx() { + # To avoid potential syntax problems from the vmx served by dmsd, sanitize + # it before continuing with filling in the gaps + local TMPTMPCONFIG="$(mktemp)" + grep -E '^\s*(#|[^=]+=[^"]*"[^"]*"\s*$|[^=]+=[^"]+$|$)' "$TMPCONFIG" > "$TMPTMPCONFIG" + if ! diff -q "$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" + fi + mv -f -- "$TMPTMPCONFIG" "$TMPCONFIG" + writelog "Parsing virtual machine description file..." 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 @@ -19,4 +30,3 @@ else writelog "Path to VMX file is not set or empty! Aborting..." EXIT_TYPE="internal" EXIT_REASON="Konnte Pfad zur VMX-Datei nicht finden!" cleanexit 1 fi - |