Skip to content

Commit

Permalink
common: Use cockpit.conf for fatal criticals
Browse files Browse the repository at this point in the history
The way that our testing uses environment variables to setup
fatal criticals during testing doesn't work for the privileged
bridge or other bridges. Both pkexec and sudo clean out the
environment.

So lets use cockpit.conf to configure this consistently across
all cockpit processes.

Closes #7315
  • Loading branch information
stefwalter authored and martinpitt committed Jul 18, 2017
1 parent c7d82fc commit 705c4b8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
13 changes: 13 additions & 0 deletions doc/man/cockpit.conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@ ProtocolHeader = X-Forwarded-Proto
</variablelist>
</refsect1>

<refsect1 id="cockpit-conf-log">
<title>Log</title>
<variablelist>
<varlistentry>
<term><option>Fatal</option></term>
<listitem>
<para>The kind of log messages in the bridge to treat as fatal. Separate multiple values
with spaces. Relevant values are: <code>criticals</code> and <code>warnings</code>.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 id="cockpit-conf-oauth">
<title>OAuth</title>
<para>Cockpit can be configured to support the <ulink url="https://tools.ietf.org/html/rfc6749#section-4.2">
Expand Down
17 changes: 17 additions & 0 deletions src/common/cockpitlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "config.h"

#include "cockpitlog.h"
#include "cockpitconf.h"

#include <systemd/sd-journal.h>
#include <syslog.h>
Expand Down Expand Up @@ -151,8 +152,24 @@ void
cockpit_set_journal_logging (const gchar *stderr_domain,
gboolean only)
{
GLogLevelFlags fatal;
const gchar **fatals;
int fd;

fatals = cockpit_conf_strv ("Log", "Fatal", ' ');
if (fatals)
{
fatal = G_LOG_LEVEL_ERROR;
for (; fatals[0] != NULL; fatals++)
{
if (g_ascii_strcasecmp ("criticals", fatals[0]) == 0)
fatal |= G_LOG_LEVEL_CRITICAL;
else if (g_ascii_strcasecmp ("warnings", fatals[0]) == 0)
fatal |= G_LOG_LEVEL_WARNING;
}
g_log_set_always_fatal (fatal);
}

/* Don't log to journal while being tested by test-server */
if (g_getenv ("COCKPIT_TEST_SERVER_PORT") != NULL)
only = FALSE;
Expand Down
4 changes: 2 additions & 2 deletions src/ws/Makefile-ws.am
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ testassetsdir = $(prefix)/lib/cockpit-test-assets
testserviceddir = $(systemdunitdir)/cockpit.service.d

install-tests::
$(MKDIR_P) $(DESTDIR)$(testassetsdir) $(DESTDIR)$(testserviceddir)
$(MKDIR_P) $(DESTDIR)$(testassetsdir) $(DESTDIR)$(testserviceddir) $(DESTDIR)/etc/cockpit
$(INSTALL_DATA) mock-pam-conv-mod.so $(DESTDIR)$(testassetsdir)
$(INSTALL_DATA) $(srcdir)/src/ws/fatal.conf $(DESTDIR)$(testserviceddir)
$(INSTALL_DATA) $(srcdir)/src/ws/fatal.conf $(DESTDIR)/etc/cockpit/cockpit.conf

install-exec-hook::
mkdir -p $(DESTDIR)$(sysconfdir)/cockpit/ws-certs.d $(DESTDIR)$(sysconfdir)/cockpit/machines.d
Expand Down
4 changes: 2 additions & 2 deletions src/ws/fatal.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[Service]
Environment=G_DEBUG=fatal-criticals
[Log]
Fatal = criticals
2 changes: 1 addition & 1 deletion tools/cockpit.spec
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ This package contains tests and files used while testing Cockpit.
These files are not required for running Cockpit.

%files tests
%{_unitdir}/cockpit.service.d
%config(noreplace) %{_sysconfdir}/cockpit/cockpit.conf
%{_datadir}/%{name}/playground
%{_prefix}/lib/cockpit-test-assets

Expand Down

0 comments on commit 705c4b8

Please sign in to comment.