common: Ignore zero byte data blocks in cockpit_pipe_write()

It doesn't make sense to write zero bytes to a stream, and
the logic in dispatch_output() isn't ready for it.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Clear input data POSTed to web server before freeing

This data may contain passwords and such.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: No threading or blocking in CockpitAuth

To do this we treat login separately from loading cookies. This was
already the case, but we make it clearer.

Actual PAM authentication happens in cockpit-session, so we simply
get notified when it completes and then complete the async login
web response.

There's room to make this cleaner, but will wait until we get GSSAPI
authentication in the mix before refactoring it further.

Closes #557
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
Cleanup the G_LOG_DOMAINS we use especially for debugging

 * cockpit-protocol: low level stuff, very busy repetetive messages
   produced by both cockpit-ws and cockpit-agent processes
 * cockpit-ws: web service higher level
 * WebSocket: the web socket code (separate from cockpit)
 * cockpit-agent: the agent specific code

You'll likely need to 'make clean' after applying this patch.

Closes #569
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
test: Remove *.pyc files when doing 'make clean'

git can confuse python, which checks the last modified date
of the pyc file.

Closes #570
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: G_LOG_DOMAIN fixes for clang

It seems that clang expands nested macros differently than gcc
so we need to redefine G_LOG_DOMAIN earlier in some cases.

Closes #569
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
Release version 0.7
ws: Make the HTTP parts of cockpit-ws log in cockpit-protocol domain

This lets us focus in on the semantic stuff, and leave the
mechanical shunting of bytes into the cockpit-protocol log domain.

Closes #572
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Fix race when disconnecting from an ssh transport

Closes #574
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Call pam_acct_mgmt() when creating user session

This allows PAM to deny access for the user, so we now
respect HBAC.

Fixes #493
Closes #566
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Add per test logging in test-sshtransport.c

And turn it on for the problematic
/ssh-transport/terminate-problem test that we're trying to diagnose.

Closes #576
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Close fds before spawning agent for security reasons

Don't leak fds into the agent child process after dropping
privileges.

Fixes #506
Closes #567
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
Try again to quieten down Travis in our IRC channel

Closes #575
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
static: Serve static files from a separate directory

These are files that will remain unauthenticated and retrieved
directly from the server connected to.

These files are served in such a way that they are cached for
a year, and not refreshed. They must be renamed when they are
updated.

Closes #561
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Add a timeout during test-webservice.c tests using alarm()

We may want to expand this further once we get some experience with
how it works.

Closes #577
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Don't send "ping" commands during test-webservice.c tests

This would previously limit the tests to having to run in
5 seconds or less, or erroneous results would result.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Separate function for parsing auth input in CockpitAuth

This allows us to test the real parsing functionality in our
test-auth tests.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Check that JSON is UTF8 before parsing it

Recent versions of json-glib do this (0.99.2 and later) but we need this
guarantee on earlier versions as well. Do the check on our own in
those cases. And define the JSON_PARSER_ERROR_INVALID_DATA error code
when it is not around.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Handle cases where login is not UTF8 valid

Produce an intelligent error message in these cases. cockpit-session
would have produced invalid JSON output here, and so we catch and
handle in properly.

Fixes #507
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
common: Fix JSON string encoding for control characters

The implementation we got from json-glib is totally broken here
and escapes using octal sequences which are invalid in JSON.

Closes #582
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>