-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mgt: Always recreate secret file on startup
As both the varnish working directory and the secret file may pre-exist, this ensures permissions remain restrictive on it.
- Loading branch information
Showing
3 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
varnishtest "make sure an already setup secret file remains protected" | ||
|
||
varnish v1 -vcl { backend default none; } -start | ||
|
||
shell -match _.secret { | ||
find "${tmpdir}"/v1/_.secret -perm 0640 -size 256c | ||
} | ||
|
||
varnish v1 -stop -wait | ||
|
||
shell { | ||
test ! -f "${tmpdir}"/v1/_.secret | ||
} | ||
|
||
# since varnishtest destroys workdir silently before startup | ||
# this must fool varnishtest to not manage the workdir | ||
shell -match _.secret { | ||
set -e | ||
mkdir -p "${tmpdir}"/v2/ | ||
touch "${tmpdir}"/v2/_.secret | ||
chmod 0666 "${tmpdir}"/v2/_.secret | ||
find "${tmpdir}"/v2/_.secret -perm 0666 -size 0c | ||
} | ||
|
||
process p1 "exec varnishd -n ${tmpdir}/v2 -F -f '' -a :0" -start | ||
|
||
# wait for startup and check permissions have changed | ||
shell -match _.secret { | ||
set -e | ||
t=50 | ||
while [ "$t" -gt 0 ] && [ ! -d "${tmpdir}"/v2/_.vsm_mgt ]; do | ||
sleep 0.1 | ||
t=$(($t - 1)) | ||
done | ||
find "${tmpdir}"/v2/_.secret -perm 0640 -size 256c | ||
} | ||
|
||
process p1 -stop -wait | ||
|
||
shell { | ||
test ! -f "${tmpdir}"/v2/_.secret | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters