Merge pull request #615 from daniel-pittman/maint/master/ruby-1.9.3-support

Ruby 1.9.3-p0 support in spec tests.

This unbreaks the build, and gets everything moving forward as we would expect.
(#13584) in daemon mode, master can swallow errors during startup

This commit delays the closing of stdin/stdout/stderr to a time
a little later in the daemon startup process, in hopes of providing
a larger window in which the console is available as a fallback for
logging errors.
(#13588) fix permissions on log dir

When running puppet master as root, the log dir needs to
be permissioned as the service user (usually 'puppet').
This behavior had been inadvertently changed in the
work relating to #7749, but is fixed herein.
fix acceptance test that was relying on implicit 'apply'

As of Telly, we will no longer support the behavior of
puppet defaulting to 'apply' if you do not provide a
subcommand explicitly.  This commit fixes a test that
was relying on that behavior.
fix pluginsync acceptance tests
cleanup whitespace, ala pull request #527
Merge pull request #632 from cprice-puppet/cleanup/master/ssh_authorized_keys_whitespace

cleanup whitespace, ala pull request #527
Merge pull request #621 from puppetlabs/integration/master/13588-log-dir-perms

fix master acceptance tests
Make `replace_file` work on Windows, not just Unix.

The changes to enable Windows support in `replace_file` were not actually
complete, and it didn't work when the file didn't exist - because of
limitations of the emulation done on our side, rather than anything else.

This rewrites the code to work correctly on Ruby 1.8.7 and Windows.  It
doesn't add features, just gets the basic code flow working.

This doesn't yet support 1.9.3, just adapts to the changes that 1.9.3 support
brought to the tree.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Make `binwrite` emulation work on Windows.

So, it turns out that Ruby on Windows is pretty damn awesome, and that to
successfully sysopen a file, then use it as an IO, you need to write this:

    IO.new(IO::sysopen(filename, mode), mode) {|io| ... }

...yes, indeed, you need to repeat the mode, and pass the sysopen mode - which
is completely incompatible with the normal open.  It works when you pass a
file descriptor from sysopen, though, and gets Ruby convinced to use it right.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Fix Rails schema setup on Windows.

There were several problems with the StoreConfig Rails schema building code on
Windows, starting with the use of `/dev/null` to discard migration output.

Unfortunately, this was hard to debug - it broke tests silently because of the
hacking on $stdout, and didn't report anything about failures.

Now, instead of discarding the output we capture it in memory, and report any
exception we encounter along with the complete textual output at the time of
failure.

This improves the ability to debug errors in this code, along with making it
work transparently on any platform.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Forcibly remove temporary files in tests.

We have some test helpers, and they allow us to create scratch files and
directories that will be politely destroyed at the end of the run.

We also have some tests that result in permissions on files being changed; we
still want those destroyed, and turning on "force" mode for the delete
operation gives us what we need with no real cost - we have plenty of other
safety factors in place.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Recover better when `maxgroups` is not implemented.

Puppet tries to bump up the maximum number of supplementary groups for the
process, which works only on Unix-like platform, in C-like implementations of
Ruby.

Previously there was a blacklist of platforms where this didn't work, which
means that as new platforms come along we failed in new and exciting ways.

Instead we can just rescue any failure from invoking the method and carry on,
which works for any failure mode including "not implemented" nicely.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Store Rails logs on physical disk when testing.

On Unix, we stored the Rails log from our StoreConfigs scratch database in
`/dev/null`, which is reasonable enough - we don't generally care for them,
and that works.

On Windows this is harder because their NUL device is magic, and it is hard to
configure the Rails logs to actually go there.  The system loves to interpret
it as a random file relative to the current directory and do the wrong thing
in various test scenarios.

Ultimately, it doesn't matter if we write the logs to physical disk, and we
already had a scratch directory for the physical database - so we can throw
the logs there too.

Just another reason to use a tmpfs to back /tmp, I guess.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Make a path absolute on Windows as well as Unix.

When this test was changed the path became relative on Windows, because it
doesn't have a drive letter.  This fixes that with `make_absolute`.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Accept paths with `~` for `generate` on Windows.

The `generate` function has a fairly strict definition of what is and isn't
legal as a command name, in an effort to keep it reasonably sanitary.

On Windows this included `.`, `-`, and any alpha-numeric characters, but not
the `~` character.  This blew up when faced with an "8.3" generated path -
something that we legitimately should accept since it can reduce problems
around spaces in path names.

This changes generate to accept that, and adds a specific test to verify that
it continues to work as expected.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Make the base service provider spec work on Windows.

The base service provider pushes the status command into an array, and Windows
has a little heartburn about that vs quoting.  While it isn't clear who is
right, it is easy to just use an array when creating the test service and have
things work.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Use platform path separator in tests.

When we test path modification, we should use the platform path separator.
Makes the test pass on Windows.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Use a platform temporary file instead of a Unix one.

The log test used a Unix path, which didn't work on Windows.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>