markokr/pgbouncer-dev — pull request #26 by guillaumeaubert (2014-05-26 05:03:52+00:00)
Title: Allow comments in PgBouncer's auth files

@sbranchaw and I were discussing how we use Puppet to manage the deployment of the PgBouncer's auth files, so those should never be edited directly on the target machines. To prevent accidental edits, it would be nice to be able to include a cautionary comment in the files, along the lines of "This file is managed by Puppet, edit the file in the Puppet repository instead and use Puppet to deploy it".

Unfortunately, PgBouncer doesn't support comment in auth files. A workaround is that PgBouncer will stop parsing when it encounters an incorrect line but it doesn't stop it from starting, so we can include the comments at the end of the auth files and they don't affect the operation of PgBouncer:

```
"user1" "password"
"user2" "password"
; Some comment
```

It is however quite inelegant on several levels:

1. PgBouncer logs an error when it encounters an incorrectly formatted file, while the comments are intentional. This can cause confusion or cause otherwise legitimate errors to get ignored.

2. Lines after the first incorrectly formatted line are ignored silently. In the following example, `user1` and `user2` would get added, but not `user3`:

```
"user1" "password"
"user2" "password"
; Some comment
"user3" "password"
```

Full support for commented-out lines in auth files would solve the two issues above, while providing a consistent way to comment across all the files used by PgBouncer. A corresponding patch is attached for your consideration. Thank you!