Merge pull request #215 from flatpak/revert-202-journal-setup

Revert "Set up logging to the journal"
tingping/wmclass
Alexander Larsson 2016-07-29 00:26:02 +02:00 committed by GitHub
commit 3d603bbb30
5 changed files with 3 additions and 95 deletions

View File

@ -45,30 +45,6 @@ static gboolean opt_log_session_bus;
static gboolean opt_log_system_bus;
static char *opt_runtime;
static char *opt_runtime_version;
static FlatpakRunFlags journal_flags;
static gboolean
opt_journal_cb (const char *option_name,
const char *value,
gpointer data,
GError **error)
{
if (strcmp (value, "yes") == 0)
journal_flags = FLATPAK_RUN_FLAG_JOURNAL;
else if (strcmp (value, "no") == 0)
journal_flags = FLATPAK_RUN_FLAG_NO_JOURNAL;
else if (strcmp (value, "auto") == 0)
journal_flags = 0;
else
{
journal_flags = 0;
g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
_("Unknown journal option %s, valid options are: yes, no, auto"), value);
return FALSE;
}
return TRUE;
}
static GOptionEntry options[] = {
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, N_("Arch to use"), N_("ARCH") },
@ -79,7 +55,6 @@ static GOptionEntry options[] = {
{ "runtime-version", 0, 0, G_OPTION_ARG_STRING, &opt_runtime_version, N_("Runtime version to use"), N_("VERSION") },
{ "log-session-bus", 0, 0, G_OPTION_ARG_NONE, &opt_log_session_bus, N_("Log session bus calls"), NULL },
{ "log-system-bus", 0, 0, G_OPTION_ARG_NONE, &opt_log_system_bus, N_("Log system bus calls"), NULL },
{ "journal", 0, 0, G_OPTION_ARG_CALLBACK, &opt_journal_cb, N_("Redirect stdout and stderr to the journal"), N_("VALUE") },
{ NULL }
};
@ -152,8 +127,7 @@ flatpak_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
opt_runtime_version,
(opt_devel ? FLATPAK_RUN_FLAG_DEVEL : 0) |
(opt_log_session_bus ? FLATPAK_RUN_FLAG_LOG_SESSION_BUS : 0) |
(opt_log_system_bus ? FLATPAK_RUN_FLAG_LOG_SYSTEM_BUS : 0) |
journal_flags,
(opt_log_system_bus ? FLATPAK_RUN_FLAG_LOG_SYSTEM_BUS : 0),
opt_command,
&argv[rest_argv_start + 1],
rest_argc - 1,

View File

@ -42,9 +42,6 @@
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include <syslog.h>
#include <systemd/sd-journal.h>
#include "flatpak-run.h"
#include "flatpak-proxy.h"
#include "flatpak-utils.h"
@ -3037,34 +3034,6 @@ clear_fd (gpointer data)
close (*fd_p);
}
static gboolean
connect_journal (const char *app_id, GError **error)
{
int fd;
/* redirect stdout and stderr to the systemd journal */
fd = sd_journal_stream_fd (app_id, LOG_INFO, TRUE);
if (fd < 0)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
_("Failed to create journal stream fd"));
return FALSE;
}
if (dup3 (fd, STDOUT_FILENO, 0) < 0 ||
dup3 (fd, STDERR_FILENO, 0) < 0)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
_("Failed to duplicate journal stream fd"));
return FALSE;
}
if (fd >= 3)
close (fd);
return TRUE;
}
static void
child_setup (gpointer user_data)
{
@ -3080,25 +3049,6 @@ child_setup (gpointer user_data)
fcntl (g_array_index (fd_array, int, i), F_SETFD, 0);
}
static void
child_setup_with_journal (gpointer user_data)
{
connect_journal ("", NULL);
child_setup (user_data);
}
static gboolean
should_use_journal (FlatpakRunFlags flags)
{
if ((flags & FLATPAK_RUN_FLAG_NO_JOURNAL) != 0)
return FALSE;
else if ((flags & FLATPAK_RUN_FLAG_JOURNAL) != 0)
return TRUE;
else if (isatty (fileno (stderr)))
return FALSE;
else
return TRUE;
}
gboolean
flatpak_run_app (const char *app_ref,
@ -3315,19 +3265,13 @@ flatpak_run_app (const char *app_ref,
(char **) real_argv_array->pdata,
envp,
G_SPAWN_DEFAULT,
should_use_journal (flags)
? child_setup_with_journal
: child_setup,
fd_array,
child_setup, fd_array,
NULL,
error))
return FALSE;
}
else
{
if (should_use_journal (flags) && !connect_journal (app_ref_parts[1], error))
return FALSE;
if (execvpe (flatpak_get_bwrap (), (char **) real_argv_array->pdata, envp) == -1)
{
g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errno),

View File

@ -98,8 +98,6 @@ typedef enum {
FLATPAK_RUN_FLAG_LOG_SESSION_BUS = (1 << 2),
FLATPAK_RUN_FLAG_LOG_SYSTEM_BUS = (1 << 3),
FLATPAK_RUN_FLAG_NO_SESSION_HELPER = (1 << 4),
FLATPAK_RUN_FLAG_JOURNAL = (1 << 5),
FLATPAK_RUN_FLAG_NO_JOURNAL = (1 << 6)
} FlatpakRunFlags;
gboolean flatpak_run_setup_base_argv (GPtrArray *argv_array,

View File

@ -125,7 +125,7 @@ AC_SUBST([GDBUS_CODEGEN], [`$PKG_CONFIG --variable gdbus_codegen gio-2.0`])
POLKIT_GOBJECT_REQUIRED=0.98
PKG_CHECK_MODULES(BASE, [glib-2.0 >= $GLIB_REQS gio-2.0 gio-unix-2.0 libsystemd])
PKG_CHECK_MODULES(BASE, [glib-2.0 >= $GLIB_REQS gio-2.0 gio-unix-2.0])
PKG_CHECK_MODULES(SOUP, [libsoup-2.4])
AC_ARG_ENABLE([system-helper],

View File

@ -319,14 +319,6 @@
your D-Bus policy.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--journal=VALUE</option></term>
<listitem><para>
Control whether to redirect stdout and stderr of the sandbox to the systemd journal. Possible values are yes, no or auto. In the latter case, only redirect if stderr is not a tty. The default is auto.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>