agent: Add cockpit_channel_get_strv_option() function

Used by channel implementors to get a string array from the
channel options. Implemented this using cockpit_json_get_strv()
utility function.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Simplify the mock service code a bit

We use the GDBusObjectManager to look up the extra objects rather
than having a separate hash table for them.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Add RequestPropertyMods method to mock service

A simple way to check PropertiesChanged signal

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Add a path which fails introspection to mock service

We can use this for checking our introspection logic.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Bug fix for using mock service more than once in a process

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Force mock service to always use a new dbus connection

Otherwise this can lead to races between tests.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Implement CockpitFakeManager a GDBusObjectManager clone

This implements GDBusObjectManager by using Introspect() and
PropertiesChanged signals to discover objects that show up.
We watch signals for object paths, and then Introspect() them to
see if they're valid and what interfaces are present.

We assume that each new, changed, removed interafce will have a
signal related to it emitted. Without this there's not much we
can do to track new objects etc.

At present this is a bit racy. If an object changes while we're
already looking at it we won't introspect it again.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: CockpitDBusJson works with plain GDBusObjectManager

Use only GDBusObjectManager interface in CockpitDBusJson. This way
we can switch in other implementations.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Support "object-paths" argument in dbus-json1 channel

When this option is specified instead of an "object-manager" option,
we use CockpitFakeManager to discover objects rather than
GDBusObjectManagerClient.

Fixes #251
Closes #460
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
daemon: Also find cgroups in the cpuacct hierarchy.

This makes cpu monitoring work with default docker 0.9.0.

Closes #452

Reviewed-by: Stef Walter <stefw@redhat.com>
web: Unbreak linting of undefined variables and functions.

Js-lint used to grep for "^function ..." and "^var ..." in all files
and register them as global definitions.  This meant that for example
resource_debug from cockpit-docker.js would be allowed to be used
everywhere even though it is a local function.

This is fixed by only registering functions and variables starting
with "cockpit_" and never using that prefix for local definitions.

Closes #462

Reviewed-by: Stef Walter <stefw@redhat.com>
ws: Fix up mock-sshd to handle retrying non-blocking writes

There were corner cases in our testing where we would expect
all data to be written out. In reality not all data is expected
to be written during a write() or ssh_channel_write() so,
buffer it appropriately and only write when we are ready for it.
ws: Add --broken-auth argument to mock-sshd

This lets us start mock-sshd in a way that ssh authentication should
always fail. We don't have host-based auth or public key auth, so
use those as our way of forcing failure.
ws: Don't mix stderr and stdout in mock-sshd

In fact for testing purposes, just leave it connected to our normal
stderr so we can see failures.
ws: Send exit termination signals from children of mock-sshd

We'll want to test these cases, even though we don't currently
do that.
ws: Add CockpitSshTransport which uses libssh

We'll migrate from our current sshpass + openssh client based
approach to libssh.

This doesn't use libgssh. libgssh unfortunately doesn't have a
pollable model (such as GPollableOutputStream and friends) which
is what we need to implement a CockpitTransport.

In addition the mechanism that it uses to do async work with
libssh (ie: eagain non-blocing based async) doesn't work well with
libssh 0.6.x upstream. Certain functions to make the corner cases
work are completely missing.

Lastly we need to authenticate in a thread, so we can support
kerberos (ie: GSSAPI). So implemented it this way in
CockpitSshTransport.

Part of fix for #69
common: Add cockpit_pipe_spawn() function to create process pipe

This is more general than cockpit_pipe_transport_spawn(). Once we
migrate to libssh then cockpit_pipe_transpown_spawn() should be
rewritten to use cockpit_pipe_spawn().

Since we'd like to use this as a cockpit_pipe_transport_spawn()
constructor, allow passing the gtype. In theory we would make all
these arguments be constructor arguments of CockpitPipe and then
pass it all in that way. But man that's tiring and less readable.
common: Close failed CockpitPipe in right thread context

CockpitPipe is not thread-safe, so it's close-on-fail-during-init
idle handler needs to be called in the thread main context for
the thread in which it was created.
ws: Use CockpitSshTransport for connecting to other hosts

Uses libssh instead of the openssh client for connecting to other
hosts.

We also remove some complexity from cockpit_pipe_transport_spawn()
which can no longer fail immedediately, but will close if failure.

Note that although the tests pass with this commit, running actual
webservice requires that you put known_hosts in the standard
format in the following file, for any hosts that you want to connect to:

  /var/lib/cockpit/known_hosts

This commit removes sshpass dependency.

Fixes #69
ws: Expose host key for CockpitSshTransport

This allows us to look at the host key that the server offered,
regardless of whether verification succeeded or failed. Via
cockpit_ssh_transport_get_host_key() and the 'host-key' property.

In addition we want to be able to tell CockpitSshTransport to
explicitly expect a certain key and ignore other host verification
via the known-hosts file. This happens via 'host-key' construct
property.