static void
log_init (void)
{
- gchar *log_dir, *path;
+ gchar *log_dir, *path, *old_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);
fcntl (log_fd, F_SETFD, FD_CLOEXEC);
g_log_set_default_handler (log_cb, NULL);
if (seat->priv->log_file)
{
int fd;
+ gchar *old_filename;
+ /* Move old file out of the way */
+ old_filename = g_strdup_printf ("%s.old", seat->priv->log_file);
+ rename (seat->priv->log_file, old_filename);
+ g_free (old_filename);
+
+ /* Create new file and log to it */
fd = g_open (seat->priv->log_file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd < 0)
l_warning (seat, "Failed to open log file %s: %s", seat->priv->log_file, g_strerror (errno));
if (server->priv->log_file)
{
int fd;
+ gchar *old_filename;
+ /* Move old file out of the way */
+ old_filename = g_strdup_printf ("%s.old", server->priv->log_file);
+ rename (server->priv->log_file, old_filename);
+ g_free (old_filename);
+
+ /* Create new file and log to it */
fd = g_open (server->priv->log_file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd < 0)
l_warning (server, "Failed to open log file %s: %s", server->priv->log_file, g_strerror (errno));