Merge pull request #1771 from jimis/3.6.x

Cherry-picks from master to 3.6.x.
Pass GenericAgentConfig to NoteVar/Class plugin calls

(cherry picked from commit 6dbe12ff833e14186ecae6d5c7b1149005d823e2)
Add (partial) finalization for generic agent.

We have an initialization function for the generic agent, that calls
initialization code for cfnet; but neither had matching finalize code,
even though the cfnet one calls initializations that do have matching
shutdown code (that no-one calls).  Similar problems with server.

Begin sketching what relevant clean-up would look like, based on the
first few leaks I saw due to its absence ...

Fold EvalContextDestroy() and GenericAgentConfigDestroy() into
GenericAgentFinalize(), to simplify everywhere's final clean up.  In
the process, catch a few cases that used to neglect the former.

(cherry picked from commit ec9c10953192e2627a757ec92fb1a8b2e2a378b7)

Conflicts:
	cf-serverd/cf-serverd-functions.c
	cf-serverd/cf-serverd.c
Clear auth and ACL data on exit, when possible.

Moved clean-up code for SV, *_acl and friends to a separate function
(shortening CheckFileChanges) and arranged for StartServer() to call
this, when it safely can, on exit to (try to) avoid some boring leaks
that clutter valgrind's logs.

(cherry picked from commit bbfdf6c11b7311afa0a2550bcc319c9b53348e10)

Conflicts:
	cf-serverd/cf-serverd-functions.c
Leak-fix: clear away PRIVKEY and PUBKEY in TLSDeInitialize().

(cherry picked from commit d758fd4d9ec8a79dc757d5ed6a5a6b5a46f3847c)