(PUP-3190) Don't assume puppet is in a lib dir

The loaders previously assumed that any installation of puppet would be
under a directory called lib. This holds true when running puppet from
source (during development), or in some package cases, but is not
generally true. This simplifying assumption was made so that the loading
path for both puppet system extensions (built in functions) and module
extensions could be loaded in the same manner: find the root of the
extender and loading code from `lib/puppet/...`.

This changes to loading to instead only assume that there is a `puppet`
directory and not the name of the parent. This, however, forces the
loader for modules to become specialized to only be able to find ruby
extentions, because they are in the 'lib' directory, which is how the
loader must now be configured.
(maint) Remove unused constant from default_manifest_spec
(PUP-3162) Prevent $environment interpolation in directory environments

There are a few settings for which interpolation of $environment does
not make sense when using directory environments.

* default_manifest -> defines either the relative path to manifests
within a directory environment, or an absolute path to manifests to be
used by all directory environments. It is currently a configuration
error to set $environment within default_manifest.
* basemodulepath -> conceptually, this is intended for supplemental
modules required for all environments, and should not vary by
environment.
* environmentpath -> this is the base path defining what directory
environments can be found. Interpolating $environment within it makes no
sense.

Additionally, both environmentpath and basemodulepath are required by
the environment loaders during initialization. They will interpolate
relative to a specified environment if you interogate config, but in a
running master instance, will have interpolated to the default
environment regardless of the current environment being processed for a
catalog, for instance.

A last case, irregardless of type of environment, is the pathological
case of attempting to interpolate $environment within environment.
This, unsurprisingly, causes a stack overflow.

This patch adjusts the Puppet::Settings interpolation code so that
$environment is not interpolated within any of these four settings when
using directory environments (so, when the environmentpath has been
set).* So assuming a confdir=/etc/puppet,
basemodulepath=$confdir/modules/$environment will be interpolated as
'/etc/puppet/modules/$environment' and a warning will be logged.

*Currently setting $environment in default_manifest will error out
when puppet loads as a setting validation error, and this behavior will
never be reached.
(maint) Correct parameter type from SSLContext to StoreContext

Previously, our verify callback stated that it received an SSLContext
parameter, but that is not correct. While there are SSLContext classes
in ruby, the actual object passed is of type StoreContext.

    (rdb:1) store_context.class
    OpenSSL::X509::StoreContext
(maint) Only append to peer_certs if verify succeeded

Previously, we assumed that verify_callback was only called once for each
cert in the chain, with preverify_ok set to true or false depending on
whether the cert is verified.

However, openssl call invoke the verify_callback for a number of other
reasons, e.g. CRL not yet valid. In that case, the error is not with
the current_cert, but with the current_crl.

This commit moves the logic for appending the current_cert to the
@peer_certs array only in the case that preverify_ok is true. Does not
cause problems, because we only looked at @peer_certs array if every
cert in the chain was successfully verified.

This commit makes it easier to handle other types of verify errors.
(PUP-3190) Add acceptance test for 4x function calls
(PUP-3162) Switch to a whitelist for $environment interpolation

Previous commit blacklisted a small set of settings from having
$environment interpolated.  After some discussion, we decided to broaden
this to a whitelist, and the only setting we can currently think of
needing $environment interpolation when using directory environments is
config_version.

We also decided to not halt startup for default_manifest with
$environment in it, as these errors are difficult to read with the
current error reporting from a rack master.  So the validation for
default_manifest is removed.
(PUP-894) Add specs for current bebavior

This commit adds specs for current behavior, especially that the verify
callback rejects the connection if preverify_ok is false, and we reject
CRLs whose last_update time is more than 5 minutes in the future.
(PUP-894) Accept CRLs that were "recently" updated

Previously, the agent would reject an SSL connection if the CRL it
downloaded from the CA had a `last_update` time that was slightly in the
future. The agent reports this as "CRL is not yet valid." This issue can
happen when the CA's time is slightly ahead of the agent's time, the CRL
is recently updated, and the agent doesn't already have a cached version
of the CRL (due to PUP-2103).

The CRL not yet valid error sometimes happens during acceptance testing
when we delete the agent's ssl directory, revoke a cert on the master
(which updates the CRL's last_update field), and run the agent (which
downloads the latest CRL).

This commit modifies the verify callback to ignore CRL not yet valid
errors provided all of the following are true:

 * current_crl is not nil
 * current_crl.last_update is not nil
 * current_crl.last_update is strictly less than 5 minutes from now

It also adds specs around unspecified behavior, e.g. ensure the verify
callback returns false when errors are detected.
(maint) Fix typos in comments in acceptance test
(PUP-3173) Fix old references to jvm-puppet in tests.

Signed-off-by: Wayne <wayne@puppetlabs.com>
(PUP-3175) Isolate yamldir for node/check_woy_cache_works.rb

Signed-off-by: Wayne <wayne@puppetlabs.com>
Merge pull request #3065 from jpartlow/issue/stable/pup-3162-whitelist-environment-interpolation

(PUP-3162) Issue/stable/pup 3162 whitelist environment interpolation
(maint) Disable activerecord testcase against puppet-server

Signed-off-by: Wayne <wayne@puppetlabs.com>
Merge branch 'pr/3069' into stable

* pr/3069:
  (maint) Disable activerecord testcase against puppet-server
  (PUP-3173) Fix old references to jvm-puppet in tests.

Closes GH-3069
Merge remote-tracking branch 'upstream/pr/3070' into stable

* upstream/pr/3070:
  (PUP-3175) Isolate yamldir for node/check_woy_cache_works.rb
(PUP-3136) Fix Intermittent Acceptance Test Failures

It was discovered that when puppet attempted to start apache the
provider would say that it was stopped even though it was starting. On
agents where a puppet master was installed with passenger the apache
service would take longer than usual to start lengthening the starting
process. By the time puppet tested if the service was running or not
apache would still be attempting to start causing the test to fail.

This commit replaces the apache2 package with rabbitmq since it is not
used by puppet and therefore tests down the road will not fail with us
managing it with puppet. It also uses a manifest instead of the
`puppet_resource` function to ensure that there is not any more timing
problems giving us the errors.
(PUP-3136) Add detailed exit codes to tests

This commit modifies the existing test to include detailed exit codes on
the `apply_manifest_on` step so that when the test fails errors will be
helpful.
Merge pull request #3071 from jpartlow/issue/stable/pup-3136-upstart-acceptance

Issue/stable/pup 3136 upstart acceptance
(PUP-3227) Address man page ownship conflicts

Prior to this commit, upgrading from puppet=2.7.23-1~deb7u3 and
puppetmaster=2.7.23-1~deb7u3 to puppet=3.7.0.29-1puppetlabs1 and
puppetmaster=3.7.0.29-1puppetlabs1 fails. I believe this problem is due
to how Debian chose to package puppet-common, which owns
`/usr/share/man/man8/puppet-master.8.gz`.

This commit adds in a `Conflicts:` to the puppetmaster and
puppetmaster-common packages to make sure that we can successfully
upgrade from these older package versions. However, if a user has
puppetmaster and puppet older than 3.3.0 installed on a machine, and
only upgrades puppetmaster, this will uninstall the puppet package from
the system.