source function library *before* client sysconfig overrides

My client's environment mandates strict umask settings:
  - 027 for init scripts
  - 077 for normal users
This causes problems when using exec resources or any add-on functions
that exec external scripts/programs.

The fix is relatively simple - run umask in /etc/sysconfig/puppet
and set a more lenient umask for puppet.
However, the /etc/sysconfig/puppet is sourced before the init
function library so any umask changes made in the former are
overridden by any in the latter.

Looking in other init scripts (including the puppetmaster init
script), it is usual for the function library to be sourced at the
start of the init script, ie. before the sysconfig override.

This change simply moves the lines that source the init function
library to the start of the init script.
(PUP-1174) enable the purging of authorized ssh keys

Purging authorized ssh keys is difficult because there is no way know
where key files may be located. Users commented that for most it should
be sufficient to clean the keys from users that puppet manages.
John Bollinger suggested a design that's based on a new parameter to the
user type. There are two ways to use it:

user { "name": purge_ssh_keys => true }

to make puppet purge from the default ~/.ssh/authorized_keys file, or

user { "name": purge_ssh_keys => [ "/etc/keyfiles/name" ] }

to specify one or more files in non-standard locations.

The implementation is similar to the file type's purging code. The user
type now has an eval_trace method that searches the specified files for keys
and adds any unmanaged keys to the catalog with ensure => absent.
(PUP-1174) amend resources type documentation

Add a reference to the new purging feature to the documentation of the
resources type description.
(PUP-1174) add tests for the purge_ssh_keys parameter of the user type
Clarified `pattern` parameter for Service type (DOCUMENT-1)
Adds support for building puppet on RHEL7 via spec.
Add initial support for building in a RHEL 7 mock

Building in an x86_64 mock, since RHEL has not provided a 32-bit release.
(PUP-1278) Windows Puppet Agent Service gracefully terminates after succesfully being put into a Paused state

Removed redundant return statement
Added in logic to only start the Puppet Agent if the service is in a Running or Idle state
(maint) Fix another broken rspec restriction
Merge pull request #2303 from kylog/maint/fix-rspec-key

(maint) Fix another broken rspec restriction
Revert "Merge branch 'pull-2137'"

This reverts commit a20b16bb70446d43c51340f72c821fc3a93c7cb6, reversing
changes made to 00579976264da4b2b8492bb664291b9ba0d5987c.

Unfortunately this change introduced a number of problems that need to
be addressed before this code can be released.

1) The yum provider is always holdable

The package type detects the ability to hold packages based on the
presence of the #hold method. Even though there is a guarding clause
around the `has_feature :holdable` in the provider it's bypassed when it
fails since the provider defines the #hold method.

This ties into:

2) Holding a package without the yum-plugin-versionlock raises errors

Since the plugin isn't available but the provider looks like it's
holdable, applying a resource like:

    package { 'bash':
      ensure => held,
    }

results in a backtrace since `yum versionlock` returns 1, and a
Puppet::ExecutionFailure is raised.

3) Held packages are not idempotent

When the yum versionlock plugin is installed, the resulting resource is
not idempotent because the ensure value is always being changed from
$version to 'held':

    [root@localhost puppet]# puppet resource package bash ensure=held
    Notice: /Package[bash]/ensure: ensure changed '4.1.2-15.el6_4' to 'held'
    package { 'bash':
      ensure => '4.1.2-15.el6_4',
    }
    [root@localhost puppet]# puppet resource package bash ensure=held
    Notice: /Package[bash]/ensure: ensure changed '4.1.2-15.el6_4' to 'held'
    package { 'bash':
      ensure => '4.1.2-15.el6_4',
    }
(maint) Adding .ruby-version and .ruby-gemset to .gitignore for RVM users.
(maint) Fix acceptance test failure caused by backtrace preservation
change (GH-2293).
We should not be accessing the exception object from the else clause of
the begin/rescue/else.
(DOCUMENT-22) Clarify matching of crontab entries

This updates the documentation to be consistent with behavior introduced in
commit da9162c.
(PUP-1411) Initialize OpenSSL before starting TCP connection

Ruby's Net::HTTP#connect method makes a TCP connection before it creates
the OpenSSL::SSL::SSLContext and invokes the SSLSocket#connect method:

    def connect
      s = timeout(@open_timeout) { TCPSocket.open(conn_address(), conn_port()) }
      if use_ssl?
        ...
        @ssl_context = OpenSSL::SSL::SSLContext.new
        s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
        ...
      end
      ...
      timeout(@open_timeout) { s.connect }

Between the time that the TCP connection is established (TCPSocket.open)
and when the client starts the SSL handshake (SSLSocket#connect), the server
must hold the TCP connection open[1].

The first time this code path is taken on the client, the call to
SSLContext.new causes the openssl library to be initialized. This can
take a non-trivial amount of time and is highly platform dependent, e.g.
openssl will initialize the cryptographically strong pseudo-random
number generator. On Windows, this typically calls CryptGenRandom among
other things.

In our CI environment, we are seeing this call take upwards of 7
seconds on Windows agents. If the agent connects to a webrick
puppetmaster, then the server will only hold the connection open for 6.2
seconds. See redmine #4762 and commit 711344836. This can lead to the
puppetmaster closing the connection, to protect against DoS attacks.

This commit ensures that we initialize the openssl library prior to
establishing the TCP connection. This reduces the amount of time the
server needs to wait for the client to send the CLIENT_HELLO message and
decreases the likelihood that the server will timeout the connection
unnecessarily.

[1] https://bugs.ruby-lang.org/issues/9459
(PUP-1411) Increase CLIENT_HELLO timeout

Previously, if a client established a TCP connection to the webrick server,
but the server did not receive any data within 6.2 seconds, the server
would close the connection, and report that the client disconnected.

The error message is actually misleading, because if the client did
actively disconnect, e.g. sent FIN or RST, then IO.select would report that the
socket is ready and timeout would not be reached.

This commit increases the timeout to 10 seconds and updates the error
message to more clearly say that the client did not send any data
before the timeout expired.

Note that we perform this check, because OpenSSL's SSL_accept will block
indefinitely, since the underlying socket is blocking by default.
(pup-640) Update report schema for error events

Previously, special handling was added to synthesize a report
event even when the property application failed early. However,
when this change was made the report schema wasn't updated,
so the schema did not allow for several fields in the event
to be null (as they are for one of these synthesized events).

This change updates the report schema to reflect that certain
fields can be null. It also adds a spec test including an error
event, which requires the schema change in order to pass.
Merge pull request #2305 from joshcooper/issue/stable/PUP-1411-SSL_connect_timeout

(PUP-1411) Protect against SSL_connect errors
(PUP-1118) Add acceptance test for using directory envs

This checks that an environment that comes from the environmentdir
setting is usable as an environment.
(PUP-1118) Stop using Environment.new

Instead of creating environments directly, we need to go through the
configured environment loaders, otherwise environments can't come from
other places.