(maint) Use same prioritizer throughout catalog

Under normal system runs, there wasn't any problem with the prioritizer
being used, since the Puppet::Resource::Catalog created it and passed to
all of the correct places. However, the testing methods in
PuppetSpec::Compiler ended up lying to the user about the prioritizer
that could be used. The prioritizer that was passed in was not the one
actually used by the catalog for constructing the relationship graph.
This was because the Puppet::Parser::Catalog used the one it had
internally. The answer is to have the Puppet::Parser::Catalog act as one
possible factory of prioritizers, and pass the prioritizer around as it
needs it. This allows the tests to then pass in the correct prioritizer
and use it consistently throughout.
(PUP-2635) use generate instead of eval_generate to purge ssh keys

The generating of ssh_authorized_keys resources for purging is implemented
in Puppet::Type::User#eval_generate. The resources are added as the graph
is being traversed.

This exhibits unexpected behavior under certain circumstances. Specifically,
generated keys can be considered already absent (and hence in sync) if there
is a package resource in the catalog. The error disappears when the
functionality is moved from the eval_generate hook in favor of the generate
hook.

The reasons for the wrong behavior is an issue between the transaction code
and the eval_generate mode of operation. During evaluation, the transaction
will call its #prefetch_if_necessary hook for each resource in turn, which
relies on #resources_by_provider. The latter has a cache and misses all
resources that are added using eval_generate after the initial method call.
As a result, those resources are not passed to the provider for prefetching
and thus remain in an uninitialized state, just as though the resource
would not exist on the target system (ensure => absent). They are therefor
not eligible for syncing/purging.
(PUP-2635) integration test for the purging of authorized ssh keys

Compile manifests that purge keys from a specific file and verify
their effect. Adds a test that detects the eval_generate problem
fixed in this branch.
Merge pull request #2707 from ffrank/ticket/3.6.1/PUP-2635-issues-with-ssh-key-purging

(PUP-2635) use generate instead of eval_generate to purge ssh keys
(PUP-2635) Skip this test on windows
Merge pull request #2739 from zaphod42/maint/stable/allow-prioritizer-to-be-used-in-tests

(maint) Use same prioritizer throughout catalog
(PUP-2364) Fix usage of puppet vardir setting Win2003

 - Previous acceptance tests were using the Beaker puppetvardir
   setting.  On Windows, this uses cygpath to resolve to an 8.3
   style name that can be used in shell commands without quoting.
   By changing the acceptance tests to use the Puppet configuration
   value instead, a Windows long file name will be used instead of
   the 8.3 style. This does not affect any OS newer than Windows
   2003R2, because the vardir path does not contain spaces.  On
   Windows 2003R2, vardir is rooted in C:\Documents and Settings\
   which means it must be quoted when using it in shell commands
   within Cygwin.  Verified that other shells like Bash (on Linux
   and AIX) can still work properly quoted, and made changes to
   the acceptance tests to quote when in doubt.
 - Fixed string interpolation in acceptance test 6541 for invalid
   file bucket files.
Merge pull request #2743 from Iristyle/ticket/stable/PUP-2364-fix-vardir-Windows-2003R2

(PUP-2364) Quote vardir to work on Windows 2003R2
(PUP-837) FFI Puppet::Util::Windows::SID

 - FFI Win32 API functions IsValidSid, ConvertSidToStringSid,
   ConvertStringSidToSid and LocalFree
 - Unfortunately ConvertSidToStringSidW allocates a buffer and does not
   return it's length, therefore a new helper function has been added to
   FFI::Pointer that will return a string up to a maximum length. If the
   NULL terminator is encountered prior to the max size, no additional
   memory is read.  This is not ideal, but slightly more secure than the
   previous implementation, which picked a buffer size, read all memory
   to the buffer, then called .strip on what remained.  The helper
   function also imposes a maximum of 512 UTF16 characters (1024 bytes)
 - Presume a maximum SID string length of 184 characters when formatted
   per http://stackoverflow.com/a/1792930
 - Add additional FFI MemoryPointer aliases for :wchar, #read_wchar
 - Remove any dependenc on mixins Windows::Security, Windows::Memory or
   Windows::MSVCRT
 - Updated affected callsites in security.rb to properly use or create
   FFI::Pointer when dealing with IsValidSid and sid_ptr_to_string. Also
   updated a couple of existing "old school" calls that are expecting
   addresses instead of FFI::Pointer objects.  This is a partial
   refactor until work continues with making security FFI compatible.
(maint) Windows SID variable naming style

This is a minor change to be more specific with the naming of the variable
'string' to 'string_sid' for methods in Puppet::Util::Windows::SID.
(PUP-2364) Correct host variable reference

A change in the previous fix to this test put in double quotes so that
the embedded expression would actually interpolate, which exposed the
fact that it was referencing 'host' rather than the 'agent' variable
that is actually in scope.  Fixed that so that it can interpolate and run.
Merge branch 'ticket/master/PUP-837-FFI-Windows-SID'

* ticket/master/PUP-837-FFI-Windows-SID:
  (maint) Windows SID variable naming style
  (PUP-837) FFI Puppet::Util::Windows::SID
Merge branch 'stable'

* stable:
  (PUP-2364) Correct host variable reference
  (PUP-2364) Fix usage of puppet vardir setting Win2003
  (PUP-2635) Skip this test on windows
  (PUP-2635) integration test for the purging of authorized ssh keys
  (PUP-2635) use generate instead of eval_generate to purge ssh keys
  (maint) Use same prioritizer throughout catalog
Merge branch 'master' into puppet-4

* master:
  (PUP-2364) Correct host variable reference
  (maint) Windows SID variable naming style
  (PUP-837) FFI Puppet::Util::Windows::SID
  (PUP-2364) Fix usage of puppet vardir setting Win2003
  (PUP-2635) Skip this test on windows
  (PUP-2635) integration test for the purging of authorized ssh keys
  (PUP-2635) use generate instead of eval_generate to purge ssh keys
  (maint) Use same prioritizer throughout catalog