varnish/vagent2 — pull request #94 by Dridi (2013-10-28 22:10:21+00:00)
Title: Various fixes, mostly around authentication

Sorry about the vague title, I've brought four unrelated fixes in the same pull request out of laziness. Some of them I fixed for the 2.1 version I'm currently [packaging](https://bitbucket.org/dridi/fedora_packages/src/9a23163dc428/varnish-agent.spec) for [Fedora](https://bugzilla.redhat.com/show_bug.cgi?id=varnish-agent). Since 2.2 is not out yet (#90) I decided not to wait before sending the pull request.

The two commits actually coming from issues with Fedora packaging guidelines are 88b5690 and 7433609. IIRC, the `agent_secret` file is used to authenticate with the varnish administration console. If it's generated at install time, it's very unlikely that varnish-agent will work out of the box when installed along with varnish. OTOH your default sysconfig does not use the `-S` option, so varnish-agent should find the shared secret in the shmlog.

One of my concerns is that if you wait long enough for the logs to cycle back to the start, the `-S` option will eventually disappear from the shmlog. For Fedora, I've configured the systemd [service](https://bitbucket.org/dridi/fedora_packages/src/9a23163dc428/varnish-agent.service) to use both varnish and varnish-agent params and pick what's relevant in each.

Which brings me to the next topic. If I use the `-S` option with, let's say, the generated `agent_secret` file from your rpm spec (and probably for the deb package too), varnish-agent won't be able to even read the file. It is owned by root with 0600 permissions. My fix opens the secret before varnish-agents gives up its privileges. Speaking of `agent_secret`, I've made the rpm package aware of it.

You might find additional information in the commit logs, but everything is pretty much here.