[pve-devel] [PATCH manager 2/3] doc: spice-example-sh: fix ticket/csrf extraction

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Sep 25 10:56:02 CEST 2017


We extract them from the json data by first deleting all
quotes, then deleting everything up to their entries, then
everything after the next comma. If the entry is at the end
there's no comma, instead there are closing braces, so we
need to strip away these as well.
---
it's no fun when scripts error randomly

 spice-example-sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/spice-example-sh b/spice-example-sh
index 1d8bdc49..cc7c6b7f 100755
--- a/spice-example-sh
+++ b/spice-example-sh
@@ -66,10 +66,12 @@ echo "AUTH OK"
 TICKET="${DATA//\"/}"
 TICKET="${TICKET##*ticket:}"
 TICKET="${TICKET%%,*}"
+TICKET="${TICKET%%\}*}"
 
 CSRF="${DATA//\"/}"
 CSRF="${CSRF##*CSRFPreventionToken:}"
 CSRF="${CSRF%%,*}"
+CSRF="${CSRF%%\}*}"
 
 curl -f -s -S -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" "https://$PROXY:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy" -d "proxy=$PROXY" > spiceproxy
 
-- 
2.11.0





More information about the pve-devel mailing list