(PUP-1362) (PUP-1775) Use yum check-updates for latest yum packages

Early versions of the yum package provider used `yum list available` to
determine the latest version of packages that were `ensure => latest`.
However the versions of yum available around that time changed the
output formatting of yum, which meant that the parsing code would break
on a regular basis (#836).

Commit 8722e439 resolved this by using the yum python bindings to
interact with yum. This required shipping a python helper script to
provide the interface between Puppet and the python libraries. However
this opened up a host of other issues ranging from what version of
Python is symlinked to '/usr/bin/python', how the yum database is
locked, and so on (PUP-1362, #11380, #16623). In addition changes to
yumhelper.py were very hard to test or reason about since it doesn't
neatly plug into our existing tests.

This commit removes yumhelper.py and replaces the update checks by
calling `yum check-update`. The output format of this command has not
changed since CentOS 4 and works all the way up to RedHat 7 so we should
be able to rely on this for a while.
(docs) Note that the path setting only works in main section of puppet.conf

See PUP-3023 for more info.
(maint) Remove GC bug workaround for Ruby < 1.8.7

Commit bd5dc649 added a workaround for a Ruby GC bug that was present in
1.8.5, 1.8.6, and partially fixed but still residual in 1.8.7. Since
we're dropping Ruby 1.8 support entirely we can now remove the
workarounds.
(PUP-1106) Unschedule refreshes on skipped resources

If a given resource is being skipped (e.g. has failed dependencies, is
unscheduled, untagged, etc) that resource should not trigger any
additional behavior. However a resource could be skipped and still have
events trigger behavior. This commit changes the event processing logic
to only process events for resources that should be applied and dequeues
events on resources that should not be applied.
(maint) Use correct data type when unscheduling events

Commit 9d59f204 added the ability to dequeue events on a given resource,
but it did so by setting the value of the target callbacks to an empty
hash. However the value of target callbacks is an array, so if events
were re-queued for a given resource we would get an error like so:

    {}.concat(%w{one two three})
    NoMethodError: undefined method `concat' for {}:Hash

Currently we can't requeue events after dequeuing events, but if this
changes then this code is very incorrect.

This commit fixes the event reset to behave as expected.
(PUP-3302) Fix resource when using directory environments

Before this fix when `puppet resource file` was being used set with
source defined puppet would error out because we need an environment
object in Puppet::Indirector::Request#environment= and instead of the
none environment being passed around it is passed as the string "none"
which is a directory environment that does not exist. This is what is
raising the EnvironmentNotFound error in puppet.

Instead of passing around a string we pass around the none environment
to fix the issue.
(PUP-3479) Update Windows ffi dependency to new ffi

Ruby 2.1.3 on Windows requires ffi 1.9.5. Update our Windows dependencies
to allow 1.9.5+ to be selected.
(PUP-3302) Fix Puppet Resource

@jpartlow and I paired on this issue.
Before this commit when using puppet resource with any resource that
went through the ral and needed a real environment would fail since the
default behaviour of Puppet::Resource::Catalog#initialize was to create
a new catalog used the None environment. In places where we were
performing `Puppet.lookup(:environments).get` on the None environment
puppet would fail, causing the none environment not found error to be
raised.

This commit changes the default behavior of Puppet::Resource::Ral#save
to create a catalog with the `current_environment` that is setup at
application initialization instead of the none environment. It also
makes `default_file_terminus` set to `file_server` in
`Puppet::Application::Resource` to make `puppet resource` act like
`puppet apply`.

We wanted to make sure that this change was not going to harm any other
parts of the puppet codebase and at least in puppet the ral is only used
when using `puppet resource`. We do not believe that it will have any
adverse effects anywhere else.
(PUP-2706) Change adduser to useradd in postinst

There has been an intermittent error where the installation of
puppet-common is failing on Ubtuntu 14.04. This error is
```
chage: the shadow password file is not present
/usr/bin/chage failed with return code 15, shadow not enabled, password aging cannot be set. Continuing.
chfn: PAM: Authentication failure
adduser: `/usr/bin/chfn -f Puppet configuration management daemon puppet' returned error code 1. Exiting.
```

Though `chage` is complaining about the fact that shadow is not enabled,
it looks like the installation is failing sure to the `adduser` call.
The thought is that `adduser` does some things under the hood that
require PAM to be configured in the build environment, which it isn't.
If we change the call from `adduser` to `useradd`, hopefully we will not
run into this issue. Note: it is difficult to test this due to the
intermittent nature of the issue.

Also, since we're removing the use of `adduser`, we no longer need to
ensure that package is available on the system.
(PUP-3312) Remove deprecated methods from the Puppet module

This commit removes the `parse_config` and
`initialize_settings_for_run_mode` class methods from the Puppet
module. This commit is part of the code removal effort for Puppet 4.
(PUP-3514) Fix broken errors from future parser

When the future parser called the error method from within the parser
(the few remaining cases handled by the parser directly), that resulted
in the Factory being called to produce new expressions and these were
subsequently turned into strings - showing a series of (slice ...)
s-expression.

The error method was simply doing the wrong thing (copied from the 3x
parser). This commit fixes the problem by picking up as much as possible
of the known location and passing that along in the exception that is
raised.

One test is included to ensure we do not have regressions on this
behavior. The remaining error cases are still untested, but the
intention is for those to be moved out from the grammar and into
validation to improve the ability to give better error messages.

This commit only fixes the immediate problem of getting garbage output
instead of file, line and position in these cases.
(PUP-3553) Remove support for OSX versions <= 10.6
(PUP-3514) Fix test stylistic issues, remove unused parameter

This removes the unused parameter options in parser_support's 
error method.

The style of the tests for errors raised from the parser
has been changed to use expect(x).to ... to get better error messages
if test fails.
(maint) Remove extra agent from the debian init script

Previously when the debian puppet service was started, it would have
an extra agent in the name because we set both daemon_opts and name to
agent and pass both to the starting exec. This commit addresses that by
setting daemon_opts to be empty, it can be overridden in the defaults
file.
(PUP-3558) Fix offset error of '[' lexing when multibyte chars are used

If there were multibyte characters anywhere before a '[' and the '['
should have been lexed as a LBRACK the difference in byte position and
char position could result in looking at the wrong position for the
character preceding the '['. If that character (wrong position) was
a whitespace, the lexer would emit a LISTSTART token instead of LBRACK.

The correct way to translate byte offset to char offset is to
use the locator.char_offset(byte_offset) method (since the method varies
depending on Ruby version).

If jupiter aligned with mars the result could be a syntax error on the
'[' because a literal list was not accepted in that position, or worse,
an access expression (x[y]), could be broken apart into two expressions;
a value followed by a literal list. The latter could go unnoticed except
for not producing the wanted answer.

This commit changes the method to get the char offset to use the locator
instead of using the byte offset as a char index when looking at the
preceding character of a '['.
(Maint) Invert conditional to make it clearer

The behavior of environment bootstrapping is handled differently for
agent vs non-agent. The code that handled this expressed it as `run_mode
!= agent`, which became a little hard to parse when reading it. By
inverting the conditional it becomes a little easier to determine what
code path will be taken.
(Maint) Restore non-local behavior for resource

The puppet resource subcommand used to work with a remote file server
(`:rest`), a previous change made it behave more like puppet apply,
which uses a local file server. That wasn't a request from users, and it
isn't clear if it is actually the correct behavior. Normally it is used
for introspecting resources locally and so a local file server might
make sense. OTOH, remote is the behavior is has had for a very long
time...
(PUP-1426) Disallow Puppet SSL autodefenestration

The puppet cert command supports an '--all' and a '--signed' flag so
that operations take take a list of values can operate on matching
values without having to enumerate them. However these options would
also apply to the 'clean' and 'revoke' actions. This means that
accidentally running `puppet cert clean --all` promptly and without
warning revokes and then removes all certificates. In other parlance,
this kills the CA.

Because this command is extremely dangerous and doesn't have any sane
use cases that we could determine, this commit disallows using
'--signed' or '--all' with the 'clean' or 'revoke' options. If this
functionality is needed we can add a '--force' flag to allow this
operation later.
(PUP-3302) Ensure resource uses given environment

Before this commit when puppet created the catalog in
`Puppet::Resource::Ral#save` with the current_environment instead of the
environment that the request passed into the indirector had requested.

This commit also modifies existing spec tests to show the cases where
the behavior that the commits in this pull request had fixed regarding
puppet resource.

Paired with @zaphod42
(PUP-3302) Remove redundant spec test

The integration test that specifically tried to cover recursion for the
file type was no longer needed. We could get similar coverage by simply
tightening up the evaluation environment in
spec/integration/type/file_spec.rb to not have any environments
available, which caused the code under test to show the mistake.