lightdm (1.17.0-0ubuntu1) UNRELEASED; urgency=medium
* New upstream release:
- - ...
+ - Don't backup system log files to *.old when starting. Handling of these
+ log files is now left to the system (e.g., through logrotate).
* Build with multi-arch
* debian/patches/xorg-1.17.patch:
- Fix xserver-allow-tcp=true option not working with X.org 1.17
* data/apparmor/abstractions/lightdm_chromium-browser: cgroups support for
guest sessions. (LP: #1504049, LP: #1464958)
+ * debian/lightdm.logrotate:
+ - Use logrotate to handle log files placed in the default system log
+ directory (/var/log/lightdm).
-- Robert Ancell <robert.ancell@canonical.com> Mon, 12 Oct 2015 14:57:47 +0100
--- /dev/null
+/var/log/lightdm/*.log {
+ daily
+ missingok
+ rotate 7
+ compress
+ notifempty
+ maxsize 10M
+ copytruncate
+}
logger.h \
login1.c \
login1.h \
+ log-file.c \
+ log-file.h \
+ log-mode.h \
mir-server.c \
mir-server.h \
plymouth.c \
#include "shared-data-manager.h"
#include "user-list.h"
#include "login1.h"
+#include "log-file.h"
static gchar *config_path = NULL;
static GMainLoop *loop = NULL;
static void
log_init (void)
{
- gchar *log_dir, *path, *old_path;
+ gchar *log_dir, *path;
log_timer = g_timer_new ();
path = g_build_filename (log_dir, "lightdm.log", NULL);
g_free (log_dir);
- /* Move old file out of the way */
- old_path = g_strdup_printf ("%s.old", path);
- rename (path, old_path);
- g_free (old_path);
-
- /* Create new file and log to it */
- log_fd = open (path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ log_fd = log_file_open (path, LOG_MODE_APPEND);
fcntl (log_fd, F_SETFD, FD_CLOEXEC);
g_log_set_default_handler (log_cb, NULL);
--- /dev/null
+/*
+ * Copyright (C) 2015 Alexandros Frantzis
+ * Author: Alexandros Frantzis <alexandros.frantzis@canonical.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+#include "log-file.h"
+
+int
+log_file_open (const gchar *log_filename, LogMode log_mode)
+{
+ int open_flags = O_WRONLY | O_CREAT;
+ int log_fd;
+
+ if (log_mode == LOG_MODE_BACKUP_AND_TRUNCATE)
+ {
+ /* Move old file out of the way */
+ gchar *old_filename;
+
+ old_filename = g_strdup_printf ("%s.old", log_filename);
+ rename (log_filename, old_filename);
+ g_free (old_filename);
+
+ open_flags |= O_TRUNC;
+ }
+ else if (log_mode == LOG_MODE_APPEND)
+ {
+ /* Keep appending to it */
+ open_flags |= O_APPEND;
+ }
+ else
+ {
+ g_warning ("Failed to open log file %s: invalid log mode %d specified",
+ log_filename, log_mode);
+ return -1;
+ }
+
+ /* Open file and log to it */
+ log_fd = open (log_filename, open_flags, 0600);
+ if (log_fd < 0)
+ g_warning ("Failed to open log file %s: %s", log_filename, g_strerror (errno));
+
+ return log_fd;
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Alexandros Frantzis
+ * Author: Alexandros Frantzis <alexandros.frantzis@canonical.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef LOG_FILE_H_
+#define LOG_FILE_H_
+
+#include <glib.h>
+
+#include "log-mode.h"
+
+int log_file_open (const gchar *log_filename, LogMode log_mode);
+
+#endif /* !LOG_FILE_H */
--- /dev/null
+/*
+ * Copyright (C) 2015 Alexandros Frantzis
+ * Author: Alexandros Frantzis <alexandros.frantzis@canonical.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef LOG_MODE_H_
+#define LOG_MODE_H_
+
+typedef enum
+{
+ LOG_MODE_INVALID = -1,
+ LOG_MODE_BACKUP_AND_TRUNCATE,
+ LOG_MODE_APPEND
+} LogMode;
+
+#endif /* !LOD_MODE_H_ */
#include <fcntl.h>
#include <signal.h>
#include <grp.h>
-#include <glib/gstdio.h>
#include <config.h>
+#include "log-file.h"
#include "process.h"
enum {
/* File to log to */
gchar *log_file;
gboolean log_stdout;
+ LogMode log_mode;
/* Command to run */
gchar *command;
Process *process = g_object_new (PROCESS_TYPE, NULL);
process->priv->run_func = run_func;
process->priv->run_func_data = run_func_data;
+ process->priv->log_mode = LOG_MODE_INVALID;
return process;
}
void
-process_set_log_file (Process *process, const gchar *path, gboolean log_stdout)
+process_set_log_file (Process *process, const gchar *path, gboolean log_stdout, LogMode log_mode)
{
g_return_if_fail (process != NULL);
g_free (process->priv->log_file);
process->priv->log_file = g_strdup (path);
process->priv->log_stdout = log_stdout;
+ process->priv->log_mode = log_mode;
}
void
}
if (process->priv->log_file)
- {
- gchar *old_filename;
-
- /* Move old file out of the way */
- old_filename = g_strdup_printf ("%s.old", process->priv->log_file);
- rename (process->priv->log_file, old_filename);
- g_free (old_filename);
-
- /* Create new file and log to it */
- log_fd = g_open (process->priv->log_file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
- if (log_fd < 0)
- g_warning ("Failed to open log file %s: %s", process->priv->log_file, g_strerror (errno));
- }
+ log_fd = log_file_open (process->priv->log_file, process->priv->log_mode);
/* Work out variables to set */
env_length = g_hash_table_size (process->priv->env);
#include <glib-object.h>
+#include "log-mode.h"
+
G_BEGIN_DECLS
#define PROCESS_TYPE (process_get_type())
Process *process_new (ProcessRunFunc run_func, gpointer run_func_data);
-void process_set_log_file (Process *process, const gchar *path, gboolean log_stdout);
+void process_set_log_file (Process *process, const gchar *path, gboolean log_stdout, LogMode log_mode);
void process_set_clear_environment (Process *process, gboolean clear_environment);
log_filename = g_build_filename (log_dir, filename, NULL);
g_free (log_dir);
g_free (filename);
- session_set_log_file (session, log_filename);
+ session_set_log_file (session, log_filename, LOG_MODE_APPEND);
g_free (log_filename);
}
#include "session.h"
#include "console-kit.h"
#include "login1.h"
+#include "log-file.h"
+#include "log-mode.h"
#include "privileges.h"
#include "x-authority.h"
#include "configuration.h"
int i, version, fd, result;
gboolean auth_complete = TRUE;
User *user = NULL;
- gchar *log_filename, *log_backup_filename = NULL;
+ gchar *log_filename;
+ LogMode log_mode = LOG_MODE_BACKUP_AND_TRUNCATE;
gsize env_length;
gsize command_argc;
gchar **command_argv;
/* Get the command to run (blocks) */
log_filename = read_string ();
+ if (version >= 3)
+ read_data (&log_mode, sizeof (log_mode));
if (version >= 1)
{
g_free (tty);
/* Redirect stderr to a log file */
if (log_filename)
{
- log_backup_filename = g_strdup_printf ("%s.old", log_filename);
if (g_path_is_absolute (log_filename))
{
- rename (log_filename, log_backup_filename);
- fd = open (log_filename, O_WRONLY | O_APPEND | O_CREAT, 0600);
+ fd = log_file_open (log_filename, log_mode);
dup2 (fd, STDERR_FILENO);
close (fd);
g_free (log_filename);
if (log_filename)
{
- rename (log_filename, log_backup_filename);
- fd = open (log_filename, O_WRONLY | O_APPEND | O_CREAT, 0600);
+ fd = log_file_open (log_filename, log_mode);
if (fd >= 0)
{
dup2 (fd, STDERR_FILENO);
/* File to log to */
gchar *log_filename;
+ LogMode log_mode;
/* tty this session is running on */
gchar *tty;
}
void
-session_set_log_file (Session *session, const gchar *filename)
+session_set_log_file (Session *session, const gchar *filename, LogMode log_mode)
{
g_return_if_fail (session != NULL);
g_free (session->priv->log_filename);
session->priv->log_filename = g_strdup (filename);
+ session->priv->log_mode = log_mode;
}
void
close (from_child_input);
/* Indicate what version of the protocol we are using */
- version = 2;
+ version = 3;
write_data (session, &version, sizeof (version));
/* Send configuration */
if (session->priv->log_filename)
l_debug (session, "Logging to %s", session->priv->log_filename);
write_string (session, session->priv->log_filename);
+ write_data (session, &session->priv->log_mode, sizeof (session->priv->log_mode));
write_string (session, session->priv->tty);
write_string (session, x_authority_filename);
g_free (x_authority_filename);
if (session_get_is_authenticated (session) && !session->priv->command_run)
{
gsize n = 0;
+ LogMode log_mode = LOG_MODE_INVALID;
session->priv->command_run = TRUE;
write_string (session, NULL); // log filename
+ write_data (session, &log_mode, sizeof (log_mode)); // log mode
write_string (session, NULL); // tty
write_string (session, NULL); // xauth filename
write_string (session, NULL); // xdisplay
{
session->priv = G_TYPE_INSTANCE_GET_PRIVATE (session, SESSION_TYPE, SessionPrivate);
session->priv->log_filename = g_strdup (".xsession-errors");
+ session->priv->log_mode = LOG_MODE_BACKUP_AND_TRUNCATE;
session->priv->to_child_input = -1;
session->priv->from_child_output = -1;
}
#include "accounts.h"
#include "x-authority.h"
#include "logger.h"
+#include "log-mode.h"
G_BEGIN_DECLS
gboolean session_get_is_guest (Session *session);
-void session_set_log_file (Session *session, const gchar *filename);
+void session_set_log_file (Session *session, const gchar *filename, LogMode log_mode);
void session_set_display_server (Session *session, DisplayServer *display_server);
/* Setup environment */
compositor->priv->process = process_new (run_cb, compositor);
- process_set_log_file (compositor->priv->process, log_file, TRUE);
+ process_set_log_file (compositor->priv->process, log_file, TRUE, LOG_MODE_APPEND);
g_free (log_file);
process_set_clear_environment (compositor->priv->process, TRUE);
process_set_env (compositor->priv->process, "XDG_SEAT", "seat0");
filename = g_strdup_printf ("%s.log", display_server_get_name (display_server));
dir = config_get_string (config_get_instance (), "LightDM", "log-directory");
log_file = g_build_filename (dir, filename, NULL);
- process_set_log_file (server->priv->x_server_process, log_file, TRUE);
+ process_set_log_file (server->priv->x_server_process, log_file, TRUE, LOG_MODE_APPEND);
l_debug (display_server, "Logging to %s", log_file);
g_free (log_file);
g_free (filename);
filename = g_strdup_printf ("%s.log", display_server_get_name (display_server));
dir = config_get_string (config_get_instance (), "LightDM", "log-directory");
log_file = g_build_filename (dir, filename, NULL);
- process_set_log_file (server->priv->x_server_process, log_file, FALSE);
+ process_set_log_file (server->priv->x_server_process, log_file, FALSE, LOG_MODE_APPEND);
l_debug (display_server, "Logging to %s", log_file);
g_free (log_file);
g_free (filename);