(#8193) Support new keytypes for ssh_authorized_key

Recent versions of openssh (at least openssh 5.8) support the following
keytypes in in the authorized_keys file: ecdsa-sha2-nistp256,
ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-dss or ssh-rsa.

Add support for ecdsa-sha2-nistp256, ecdsa-sha2-nistp384 and
ecdsa-sha2-nistp521.
(#8193) Support new keytypes for sshkey

Recent versions of openssh (at least openssh 5.8) support the following
keytypes in in the authorized_keys file: ecdsa-sha2-nistp256,
ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-dss or ssh-rsa.

Add support for ecdsa-sha2-nistp256, ecdsa-sha2-nistp384 and
ecdsa-sha2-nistp521.
(#8193) Add unit tests for new ssh keytypes

Add unit tests to prove that the ssh_authorized_key provider can parse
all different keytypes. This currently shows that the provider lacks
support for ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, and
ecdsa-sha2-nistp521 keys.
(#8193) Add support for new ssh keytypes in authorized_key provider

The provider now correctly detects lines that describe an
ecdsa-sha2-nistp256, ecdsa-sha2-nistp384 or ecdsa-sha2-nistp521 key.
(#12479) Don't make undef regexp match as the string undef.

As part of commit 53869e99 we did work to make the behaviour of variables that
were explicitly `undef` at least somewhat saner.

One unintended side-effect of this was that we started matching `undef` as the
literal string `undef`, not as the empty string, and not "not matching".

Either of the later would have been sane things to do; this fixes that by
picking "match undef as empty string".

That is for consistency: we already match the *literal* empty string as equal
to undef, so it makes sense to treat it the same way for a regular expression.
(Debate on that point is welcome elsewhere, but we should change literal and
regexp matching the same, consistent way if we change it anywhere.)

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#4862) Stop using EventLoop in the Puppet daemon.

This eliminates the places in the code that use the EventLoop model directly:
the two timers established to check configuration changes and run the agent,
and the invocation of the main loop in daemon mode.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#4862) `returning` is not a standard Ruby method.

The `returning(foo) do ... end` idiom used in this method isn't a standard
part of Ruby; it comes from the event-loop better definers code.  Since this
is the one occurrence in the source tree, might as well open-code it.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#4862) define_method is not a public method in Ruby.

The `better-definers` part of the EventLoop library change `define_method` to
be public on all objects, rather than private.  This isn't standard in Ruby,
and we only had one place that wasn't respecting this to start with.

Rather than retaining this divergence we just use `send` to trigger the
behaviour externally in the one place that is needed.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#4862) Finally remove the event-loop library.

Now that all the consumers of the event-loop abstraction have been removed,
delete the obsolete code from Puppet.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Maint: Remove unused variable in user spec

If rspec already gives us the described class why not using it.
Maint: Add a real provider class to user spec

Add a real provider class we can use in the tests.
Maint: Use real objects in user spec

Remove all references to the mock resource object
Maint: Remove unused mock objects in user spec

Also remove the modification of the PATH environment variable because we
will always have our :simple provider which does rely on any commands in
/sbin.
(#1076) Show warning if an empty group is specified

If the user passes an empty group to the user type, puppet will execute
an invalid `usermod` command.

e.g. if groups of user 'foo' is currently 'bar' and we do

    user { 'foo':
      groups     => '',
      membership => minimum # this is the default
    }

puppet will build a should value of ',bar' (old group + the new group '') and
will pass '-G ,bar' to the usermod command (which will then fail).

To really specifiy 'no group' the group property does allow an empty
array so we should fail if we find an empty string as a group.
(Maint) Don't change permissions on /etc/hosts

Previously, the acceptance test was backing up /etc/hosts, modifying it,
verifying that `puppet resource host` returned all of the host records,
and then moving the backup over /etc/hosts. In doing so, the permissions
on /etc/hosts were overwritten.

Since puppet runs as root on agent nodes, the test was setting the mode
of /etc/hosts to 0600 (based on root's umask).

However, when the node is also a master, the puppet master cannot read
the file, since it runs as `puppet`. This causes problems for any later
test that uses `with_master_running_on`, e.g.
ticket_7117_broke_env_criteria_authconf.rb:

   Could not resolve 192.168.100.114: Permission denied - /etc/hosts

This commit changes the test so that the existing /etc/hosts file is
truncated and the old contents restored, thereby preserving its old
mode.

Ideally, it would be nice to not have to overwrite /etc/hosts at all,
e.g. puppet resource host --param target=/my/tmp/file, but this only
works for a single host resource, not when querying all of them.
Merge pull request #577 from joshcooper/maint/2.7.x/fix-etc-hosts-test

Don't change /etc/hosts permissions in acceptance tests.
(#13117) Fix selmodule error on each_lines

This adds a test for selmodversion_loaded (which previously had no coverage at
all) and fixes the conflicting use of readline and each_line by choosing just
one.
Stub execpipe using StringIO

The real execpipe yields an IO object so this is more realistic as a test.
(Maint) Consistently use the same agent fqdn

Previously, the test would always fail when the rhel6-32-1 box was
reverted to its `git` snapshot, and the test executed. The box, for
better or worse, reports the following:

    [root@rhel6-32-1 ~]# hostname -f
    rhel6-32-1
    [root@rhel6-32-1 ~]# facter fqdn
    rhel6-32-1.puppetlabs.lan

The agent submits its report using the latter, but the test attempts to
retrieve the facts using the former:

    curl -k -H \"Accept: yaml\" https://rhel6-32-1:8140/override/facts/`hostname -f`"

And that always fails:

    Could not find facts rhel6-32-1

This issue does not occur when running the non-Windows acceptance tests,
because those jobs run on centos-55-386-1 and ubuntu-1004-32-1, which
don't have inconsistency in their domain as reported by facter and
`hostname -f`

This commit changes the test to request the facts from the master using
the same fqdn that the agent used in its report.
Merge pull request #581 from joshcooper/maint/2.7.x/fix-fqdn-rendezvous

(Maint) Consistently use the same agent fqdn