varnish/varnishgather

comments after include can cause varnishgather to compress the whole disk

Closed this issue · 4 comments

problematic line:

include "foo.vcl" // my foo vcl

// is interpreted as a path, chaos ensues

rezan commented

This would fix it:

diff --git a/varnishgather b/varnishgather
index 853a715..23535a0 100755
--- a/varnishgather
+++ b/varnishgather
@@ -157,7 +157,7 @@ vadmin_getvcls() {
 findvcls() {
        base_vcls=$(find /etc/varnish -name '*vcl' 2>/dev/null)
        [ -z "${base_vcls}" ] && return
-       include_vcls=$(sed -e '/^include /!d; s/include\s*//g; s/[\";]//g' ${base_vcls})
+       include_vcls=$(sed -e '/^include /!d; s/include\s*\"//g; s/\"\s*;.*//g' ${base_vcls})
 
        vcls=$(for file in $include_vcls ${base_vcls}; do
                is_absolute=$(echo $file | sed -e '/^\//!d')

I'll go with sed -n 's@^include\s*"\([^\\"]\+\)"\s*;.*@\1@p'

we'll be blind to "names" containing quotes and backslashes but rather that than doing crazy things

rezan commented

We should probably allow for whitespace before the include match.

uncommon, but sure. sed -n 's@^\s*include\s*"\([^\\"]\+\)"\s*;.*@\1@p' ?