Merge lp:~afrantzis/lightdm/logrotate into lp:lightdm
- logrotate
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 2226 | ||||
Proposed branch: | lp:~afrantzis/lightdm/logrotate | ||||
Merge into: | lp:lightdm | ||||
Diff against target: |
473 lines (+147/-38) 16 files modified
debian/changelog (+5/-1) debian/lightdm.logrotate (+9/-0) src/Makefile.am (+3/-0) src/lightdm.c (+3/-8) src/log-file.c (+53/-0) src/log-file.h (+21/-0) src/log-mode.h (+22/-0) src/process.c (+6/-15) src/process.h (+3/-1) src/seat.c (+1/-1) src/session-child.c (+8/-6) src/session.c (+8/-2) src/session.h (+2/-1) src/unity-system-compositor.c (+1/-1) src/x-server-local.c (+1/-1) src/x-server-xvnc.c (+1/-1) |
||||
To merge this branch: | bzr merge lp:~afrantzis/lightdm/logrotate | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Robert Ancell | Approve | ||
Review via email: mp+274999@code.launchpad.net |
This proposal supersedes a proposal from 2015-10-16.
Commit message
Use logrotate to handle files in the default log directory
Description of the change
Use logrotate to handle files in the default log directory
This MP introduces support for log rotation using the logrotate tool for file in the default log directory (/var/log/lightdm). To support this scenario, existing system log files are not moved to *.old when starting.
Robert Ancell (robert-ancell) wrote : Posted in a previous version of this proposal | # |
Robert Ancell (robert-ancell) : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2209
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal | # |
> Instead, I think open_log_file() should have a flag to say if the existing
> file should be backed up. For the system logs (i.e. in /var/log/lightdm, the
> main log, the X logs, the greeter logs etc) don't do the backup. For the other
> logs (session log) - do the backup.
OK. Let me know if the following plan sounds good:
1. process_
2. Session will perform a backup by default (since their default log file is .xsession-errors)
3. At all invocations of *_set_log_file() in the current code the flag will be set to FALSE (don't backup), since all of them are considered system logs (in the current code session logs use the default log value of Session)
> Ideally we'd actually have a configuration item to disable log backups but
> it's not essential and can be added later if necessary.
>
> Also please change the new logging code to match existing style:
> open_log_file() -> log_file_open()
Ack.
Robert Ancell (robert-ancell) wrote : Posted in a previous version of this proposal | # |
Sounds good!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2222
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Alexandros Frantzis (afrantzis) wrote : | # |
Updated branch in line with previous discussions.
Note that the CI failure is not caused by changes introduced in this MP, but rather by the application of the obsolete debian/
Robert Ancell (robert-ancell) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2222
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2015-10-12 16:56:46 +0000 |
3 | +++ debian/changelog 2015-10-20 10:31:37 +0000 |
4 | @@ -1,12 +1,16 @@ |
5 | lightdm (1.17.0-0ubuntu1) UNRELEASED; urgency=medium |
6 | |
7 | * New upstream release: |
8 | - - ... |
9 | + - Don't backup system log files to *.old when starting. Handling of these |
10 | + log files is now left to the system (e.g., through logrotate). |
11 | * Build with multi-arch |
12 | * debian/patches/xorg-1.17.patch: |
13 | - Fix xserver-allow-tcp=true option not working with X.org 1.17 |
14 | * data/apparmor/abstractions/lightdm_chromium-browser: cgroups support for |
15 | guest sessions. (LP: #1504049, LP: #1464958) |
16 | + * debian/lightdm.logrotate: |
17 | + - Use logrotate to handle log files placed in the default system log |
18 | + directory (/var/log/lightdm). |
19 | |
20 | -- Robert Ancell <robert.ancell@canonical.com> Mon, 12 Oct 2015 14:57:47 +0100 |
21 | |
22 | |
23 | === added file 'debian/lightdm.logrotate' |
24 | --- debian/lightdm.logrotate 1970-01-01 00:00:00 +0000 |
25 | +++ debian/lightdm.logrotate 2015-10-20 10:31:37 +0000 |
26 | @@ -0,0 +1,9 @@ |
27 | +/var/log/lightdm/*.log { |
28 | + daily |
29 | + missingok |
30 | + rotate 7 |
31 | + compress |
32 | + notifempty |
33 | + maxsize 10M |
34 | + copytruncate |
35 | +} |
36 | |
37 | === modified file 'src/Makefile.am' |
38 | --- src/Makefile.am 2015-08-21 03:20:27 +0000 |
39 | +++ src/Makefile.am 2015-10-20 10:31:37 +0000 |
40 | @@ -19,6 +19,9 @@ |
41 | logger.h \ |
42 | login1.c \ |
43 | login1.h \ |
44 | + log-file.c \ |
45 | + log-file.h \ |
46 | + log-mode.h \ |
47 | mir-server.c \ |
48 | mir-server.h \ |
49 | plymouth.c \ |
50 | |
51 | === modified file 'src/lightdm.c' |
52 | --- src/lightdm.c 2015-10-16 10:20:03 +0000 |
53 | +++ src/lightdm.c 2015-10-20 10:31:37 +0000 |
54 | @@ -33,6 +33,7 @@ |
55 | #include "shared-data-manager.h" |
56 | #include "user-list.h" |
57 | #include "login1.h" |
58 | +#include "log-file.h" |
59 | |
60 | static gchar *config_path = NULL; |
61 | static GMainLoop *loop = NULL; |
62 | @@ -124,7 +125,7 @@ |
63 | static void |
64 | log_init (void) |
65 | { |
66 | - gchar *log_dir, *path, *old_path; |
67 | + gchar *log_dir, *path; |
68 | |
69 | log_timer = g_timer_new (); |
70 | |
71 | @@ -133,13 +134,7 @@ |
72 | path = g_build_filename (log_dir, "lightdm.log", NULL); |
73 | g_free (log_dir); |
74 | |
75 | - /* Move old file out of the way */ |
76 | - old_path = g_strdup_printf ("%s.old", path); |
77 | - rename (path, old_path); |
78 | - g_free (old_path); |
79 | - |
80 | - /* Create new file and log to it */ |
81 | - log_fd = open (path, O_WRONLY | O_CREAT | O_TRUNC, 0600); |
82 | + log_fd = log_file_open (path, LOG_MODE_APPEND); |
83 | fcntl (log_fd, F_SETFD, FD_CLOEXEC); |
84 | g_log_set_default_handler (log_cb, NULL); |
85 | |
86 | |
87 | === added file 'src/log-file.c' |
88 | --- src/log-file.c 1970-01-01 00:00:00 +0000 |
89 | +++ src/log-file.c 2015-10-20 10:31:37 +0000 |
90 | @@ -0,0 +1,53 @@ |
91 | +/* |
92 | + * Copyright (C) 2015 Alexandros Frantzis |
93 | + * Author: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
94 | + * |
95 | + * This program is free software: you can redistribute it and/or modify it under |
96 | + * the terms of the GNU General Public License as published by the Free Software |
97 | + * Foundation, either version 3 of the License, or (at your option) any later |
98 | + * version. See http://www.gnu.org/copyleft/gpl.html the full text of the |
99 | + * license. |
100 | + */ |
101 | + |
102 | +#include <errno.h> |
103 | +#include <fcntl.h> |
104 | +#include <stdio.h> |
105 | + |
106 | +#include "log-file.h" |
107 | + |
108 | +int |
109 | +log_file_open (const gchar *log_filename, LogMode log_mode) |
110 | +{ |
111 | + int open_flags = O_WRONLY | O_CREAT; |
112 | + int log_fd; |
113 | + |
114 | + if (log_mode == LOG_MODE_BACKUP_AND_TRUNCATE) |
115 | + { |
116 | + /* Move old file out of the way */ |
117 | + gchar *old_filename; |
118 | + |
119 | + old_filename = g_strdup_printf ("%s.old", log_filename); |
120 | + rename (log_filename, old_filename); |
121 | + g_free (old_filename); |
122 | + |
123 | + open_flags |= O_TRUNC; |
124 | + } |
125 | + else if (log_mode == LOG_MODE_APPEND) |
126 | + { |
127 | + /* Keep appending to it */ |
128 | + open_flags |= O_APPEND; |
129 | + } |
130 | + else |
131 | + { |
132 | + g_warning ("Failed to open log file %s: invalid log mode %d specified", |
133 | + log_filename, log_mode); |
134 | + return -1; |
135 | + } |
136 | + |
137 | + /* Open file and log to it */ |
138 | + log_fd = open (log_filename, open_flags, 0600); |
139 | + if (log_fd < 0) |
140 | + g_warning ("Failed to open log file %s: %s", log_filename, g_strerror (errno)); |
141 | + |
142 | + return log_fd; |
143 | +} |
144 | |
145 | === added file 'src/log-file.h' |
146 | --- src/log-file.h 1970-01-01 00:00:00 +0000 |
147 | +++ src/log-file.h 2015-10-20 10:31:37 +0000 |
148 | @@ -0,0 +1,21 @@ |
149 | +/* |
150 | + * Copyright (C) 2015 Alexandros Frantzis |
151 | + * Author: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
152 | + * |
153 | + * This program is free software: you can redistribute it and/or modify it under |
154 | + * the terms of the GNU General Public License as published by the Free Software |
155 | + * Foundation, either version 3 of the License, or (at your option) any later |
156 | + * version. See http://www.gnu.org/copyleft/gpl.html the full text of the |
157 | + * license. |
158 | + */ |
159 | + |
160 | +#ifndef LOG_FILE_H_ |
161 | +#define LOG_FILE_H_ |
162 | + |
163 | +#include <glib.h> |
164 | + |
165 | +#include "log-mode.h" |
166 | + |
167 | +int log_file_open (const gchar *log_filename, LogMode log_mode); |
168 | + |
169 | +#endif /* !LOG_FILE_H */ |
170 | |
171 | === added file 'src/log-mode.h' |
172 | --- src/log-mode.h 1970-01-01 00:00:00 +0000 |
173 | +++ src/log-mode.h 2015-10-20 10:31:37 +0000 |
174 | @@ -0,0 +1,22 @@ |
175 | +/* |
176 | + * Copyright (C) 2015 Alexandros Frantzis |
177 | + * Author: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
178 | + * |
179 | + * This program is free software: you can redistribute it and/or modify it under |
180 | + * the terms of the GNU General Public License as published by the Free Software |
181 | + * Foundation, either version 3 of the License, or (at your option) any later |
182 | + * version. See http://www.gnu.org/copyleft/gpl.html the full text of the |
183 | + * license. |
184 | + */ |
185 | + |
186 | +#ifndef LOG_MODE_H_ |
187 | +#define LOG_MODE_H_ |
188 | + |
189 | +typedef enum |
190 | +{ |
191 | + LOG_MODE_INVALID = -1, |
192 | + LOG_MODE_BACKUP_AND_TRUNCATE, |
193 | + LOG_MODE_APPEND |
194 | +} LogMode; |
195 | + |
196 | +#endif /* !LOD_MODE_H_ */ |
197 | |
198 | === modified file 'src/process.c' |
199 | --- src/process.c 2015-10-16 10:04:18 +0000 |
200 | +++ src/process.c 2015-10-20 10:31:37 +0000 |
201 | @@ -17,9 +17,9 @@ |
202 | #include <fcntl.h> |
203 | #include <signal.h> |
204 | #include <grp.h> |
205 | -#include <glib/gstdio.h> |
206 | #include <config.h> |
207 | |
208 | +#include "log-file.h" |
209 | #include "process.h" |
210 | |
211 | enum { |
212 | @@ -39,6 +39,7 @@ |
213 | /* File to log to */ |
214 | gchar *log_file; |
215 | gboolean log_stdout; |
216 | + LogMode log_mode; |
217 | |
218 | /* Command to run */ |
219 | gchar *command; |
220 | @@ -90,16 +91,18 @@ |
221 | Process *process = g_object_new (PROCESS_TYPE, NULL); |
222 | process->priv->run_func = run_func; |
223 | process->priv->run_func_data = run_func_data; |
224 | + process->priv->log_mode = LOG_MODE_INVALID; |
225 | return process; |
226 | } |
227 | |
228 | void |
229 | -process_set_log_file (Process *process, const gchar *path, gboolean log_stdout) |
230 | +process_set_log_file (Process *process, const gchar *path, gboolean log_stdout, LogMode log_mode) |
231 | { |
232 | g_return_if_fail (process != NULL); |
233 | g_free (process->priv->log_file); |
234 | process->priv->log_file = g_strdup (path); |
235 | process->priv->log_stdout = log_stdout; |
236 | + process->priv->log_mode = log_mode; |
237 | } |
238 | |
239 | void |
240 | @@ -193,19 +196,7 @@ |
241 | } |
242 | |
243 | if (process->priv->log_file) |
244 | - { |
245 | - gchar *old_filename; |
246 | - |
247 | - /* Move old file out of the way */ |
248 | - old_filename = g_strdup_printf ("%s.old", process->priv->log_file); |
249 | - rename (process->priv->log_file, old_filename); |
250 | - g_free (old_filename); |
251 | - |
252 | - /* Create new file and log to it */ |
253 | - log_fd = g_open (process->priv->log_file, O_WRONLY | O_CREAT | O_TRUNC, 0600); |
254 | - if (log_fd < 0) |
255 | - g_warning ("Failed to open log file %s: %s", process->priv->log_file, g_strerror (errno)); |
256 | - } |
257 | + log_fd = log_file_open (process->priv->log_file, process->priv->log_mode); |
258 | |
259 | /* Work out variables to set */ |
260 | env_length = g_hash_table_size (process->priv->env); |
261 | |
262 | === modified file 'src/process.h' |
263 | --- src/process.h 2014-09-29 23:42:38 +0000 |
264 | +++ src/process.h 2015-10-20 10:31:37 +0000 |
265 | @@ -14,6 +14,8 @@ |
266 | |
267 | #include <glib-object.h> |
268 | |
269 | +#include "log-mode.h" |
270 | + |
271 | G_BEGIN_DECLS |
272 | |
273 | #define PROCESS_TYPE (process_get_type()) |
274 | @@ -49,7 +51,7 @@ |
275 | |
276 | Process *process_new (ProcessRunFunc run_func, gpointer run_func_data); |
277 | |
278 | -void process_set_log_file (Process *process, const gchar *path, gboolean log_stdout); |
279 | +void process_set_log_file (Process *process, const gchar *path, gboolean log_stdout, LogMode log_mode); |
280 | |
281 | void process_set_clear_environment (Process *process, gboolean clear_environment); |
282 | |
283 | |
284 | === modified file 'src/seat.c' |
285 | --- src/seat.c 2015-10-16 10:20:03 +0000 |
286 | +++ src/seat.c 2015-10-20 10:31:37 +0000 |
287 | @@ -602,7 +602,7 @@ |
288 | log_filename = g_build_filename (log_dir, filename, NULL); |
289 | g_free (log_dir); |
290 | g_free (filename); |
291 | - session_set_log_file (session, log_filename); |
292 | + session_set_log_file (session, log_filename, LOG_MODE_APPEND); |
293 | g_free (log_filename); |
294 | } |
295 | |
296 | |
297 | === modified file 'src/session-child.c' |
298 | --- src/session-child.c 2015-09-29 20:26:33 +0000 |
299 | +++ src/session-child.c 2015-10-20 10:31:37 +0000 |
300 | @@ -26,6 +26,8 @@ |
301 | #include "session.h" |
302 | #include "console-kit.h" |
303 | #include "login1.h" |
304 | +#include "log-file.h" |
305 | +#include "log-mode.h" |
306 | #include "privileges.h" |
307 | #include "x-authority.h" |
308 | #include "configuration.h" |
309 | @@ -257,7 +259,8 @@ |
310 | int i, version, fd, result; |
311 | gboolean auth_complete = TRUE; |
312 | User *user = NULL; |
313 | - gchar *log_filename, *log_backup_filename = NULL; |
314 | + gchar *log_filename; |
315 | + LogMode log_mode = LOG_MODE_BACKUP_AND_TRUNCATE; |
316 | gsize env_length; |
317 | gsize command_argc; |
318 | gchar **command_argv; |
319 | @@ -488,6 +491,8 @@ |
320 | |
321 | /* Get the command to run (blocks) */ |
322 | log_filename = read_string (); |
323 | + if (version >= 3) |
324 | + read_data (&log_mode, sizeof (log_mode)); |
325 | if (version >= 1) |
326 | { |
327 | g_free (tty); |
328 | @@ -522,11 +527,9 @@ |
329 | /* Redirect stderr to a log file */ |
330 | if (log_filename) |
331 | { |
332 | - log_backup_filename = g_strdup_printf ("%s.old", log_filename); |
333 | if (g_path_is_absolute (log_filename)) |
334 | { |
335 | - rename (log_filename, log_backup_filename); |
336 | - fd = open (log_filename, O_WRONLY | O_APPEND | O_CREAT, 0600); |
337 | + fd = log_file_open (log_filename, log_mode); |
338 | dup2 (fd, STDERR_FILENO); |
339 | close (fd); |
340 | g_free (log_filename); |
341 | @@ -680,8 +683,7 @@ |
342 | |
343 | if (log_filename) |
344 | { |
345 | - rename (log_filename, log_backup_filename); |
346 | - fd = open (log_filename, O_WRONLY | O_APPEND | O_CREAT, 0600); |
347 | + fd = log_file_open (log_filename, log_mode); |
348 | if (fd >= 0) |
349 | { |
350 | dup2 (fd, STDERR_FILENO); |
351 | |
352 | === modified file 'src/session.c' |
353 | --- src/session.c 2015-10-16 10:20:03 +0000 |
354 | +++ src/session.c 2015-10-20 10:31:37 +0000 |
355 | @@ -84,6 +84,7 @@ |
356 | |
357 | /* File to log to */ |
358 | gchar *log_filename; |
359 | + LogMode log_mode; |
360 | |
361 | /* tty this session is running on */ |
362 | gchar *tty; |
363 | @@ -198,11 +199,12 @@ |
364 | } |
365 | |
366 | void |
367 | -session_set_log_file (Session *session, const gchar *filename) |
368 | +session_set_log_file (Session *session, const gchar *filename, LogMode log_mode) |
369 | { |
370 | g_return_if_fail (session != NULL); |
371 | g_free (session->priv->log_filename); |
372 | session->priv->log_filename = g_strdup (filename); |
373 | + session->priv->log_mode = log_mode; |
374 | } |
375 | |
376 | void |
377 | @@ -619,7 +621,7 @@ |
378 | close (from_child_input); |
379 | |
380 | /* Indicate what version of the protocol we are using */ |
381 | - version = 2; |
382 | + version = 3; |
383 | write_data (session, &version, sizeof (version)); |
384 | |
385 | /* Send configuration */ |
386 | @@ -791,6 +793,7 @@ |
387 | if (session->priv->log_filename) |
388 | l_debug (session, "Logging to %s", session->priv->log_filename); |
389 | write_string (session, session->priv->log_filename); |
390 | + write_data (session, &session->priv->log_mode, sizeof (session->priv->log_mode)); |
391 | write_string (session, session->priv->tty); |
392 | write_string (session, x_authority_filename); |
393 | g_free (x_authority_filename); |
394 | @@ -857,9 +860,11 @@ |
395 | if (session_get_is_authenticated (session) && !session->priv->command_run) |
396 | { |
397 | gsize n = 0; |
398 | + LogMode log_mode = LOG_MODE_INVALID; |
399 | |
400 | session->priv->command_run = TRUE; |
401 | write_string (session, NULL); // log filename |
402 | + write_data (session, &log_mode, sizeof (log_mode)); // log mode |
403 | write_string (session, NULL); // tty |
404 | write_string (session, NULL); // xauth filename |
405 | write_string (session, NULL); // xdisplay |
406 | @@ -903,6 +908,7 @@ |
407 | { |
408 | session->priv = G_TYPE_INSTANCE_GET_PRIVATE (session, SESSION_TYPE, SessionPrivate); |
409 | session->priv->log_filename = g_strdup (".xsession-errors"); |
410 | + session->priv->log_mode = LOG_MODE_BACKUP_AND_TRUNCATE; |
411 | session->priv->to_child_input = -1; |
412 | session->priv->from_child_output = -1; |
413 | } |
414 | |
415 | === modified file 'src/session.h' |
416 | --- src/session.h 2014-11-21 07:45:05 +0000 |
417 | +++ src/session.h 2015-10-20 10:31:37 +0000 |
418 | @@ -23,6 +23,7 @@ |
419 | #include "accounts.h" |
420 | #include "x-authority.h" |
421 | #include "logger.h" |
422 | +#include "log-mode.h" |
423 | |
424 | G_BEGIN_DECLS |
425 | |
426 | @@ -84,7 +85,7 @@ |
427 | |
428 | gboolean session_get_is_guest (Session *session); |
429 | |
430 | -void session_set_log_file (Session *session, const gchar *filename); |
431 | +void session_set_log_file (Session *session, const gchar *filename, LogMode log_mode); |
432 | |
433 | void session_set_display_server (Session *session, DisplayServer *display_server); |
434 | |
435 | |
436 | === modified file 'src/unity-system-compositor.c' |
437 | --- src/unity-system-compositor.c 2015-10-16 10:04:18 +0000 |
438 | +++ src/unity-system-compositor.c 2015-10-20 10:31:37 +0000 |
439 | @@ -407,7 +407,7 @@ |
440 | |
441 | /* Setup environment */ |
442 | compositor->priv->process = process_new (run_cb, compositor); |
443 | - process_set_log_file (compositor->priv->process, log_file, TRUE); |
444 | + process_set_log_file (compositor->priv->process, log_file, TRUE, LOG_MODE_APPEND); |
445 | g_free (log_file); |
446 | process_set_clear_environment (compositor->priv->process, TRUE); |
447 | process_set_env (compositor->priv->process, "XDG_SEAT", "seat0"); |
448 | |
449 | === modified file 'src/x-server-local.c' |
450 | --- src/x-server-local.c 2015-10-16 10:04:18 +0000 |
451 | +++ src/x-server-local.c 2015-10-20 10:31:37 +0000 |
452 | @@ -493,7 +493,7 @@ |
453 | filename = g_strdup_printf ("%s.log", display_server_get_name (display_server)); |
454 | dir = config_get_string (config_get_instance (), "LightDM", "log-directory"); |
455 | log_file = g_build_filename (dir, filename, NULL); |
456 | - process_set_log_file (server->priv->x_server_process, log_file, TRUE); |
457 | + process_set_log_file (server->priv->x_server_process, log_file, TRUE, LOG_MODE_APPEND); |
458 | l_debug (display_server, "Logging to %s", log_file); |
459 | g_free (log_file); |
460 | g_free (filename); |
461 | |
462 | === modified file 'src/x-server-xvnc.c' |
463 | --- src/x-server-xvnc.c 2015-10-16 10:20:03 +0000 |
464 | +++ src/x-server-xvnc.c 2015-10-20 10:31:37 +0000 |
465 | @@ -201,7 +201,7 @@ |
466 | filename = g_strdup_printf ("%s.log", display_server_get_name (display_server)); |
467 | dir = config_get_string (config_get_instance (), "LightDM", "log-directory"); |
468 | log_file = g_build_filename (dir, filename, NULL); |
469 | - process_set_log_file (server->priv->x_server_process, log_file, FALSE); |
470 | + process_set_log_file (server->priv->x_server_process, log_file, FALSE, LOG_MODE_APPEND); |
471 | l_debug (display_server, "Logging to %s", log_file); |
472 | g_free (log_file); |
473 | g_free (filename); |
I don't like the logic in is_log_ file_managed_ by_logrotate( ) - as well as having the log directory hard-coded this is inferring behaviour about how Ubuntu has configured LightDM.
Instead, I think open_log_file() should have a flag to say if the existing file should be backed up. For the system logs (i.e. in /var/log/lightdm, the main log, the X logs, the greeter logs etc) don't do the backup. For the other logs (session log) - do the backup.
Ideally we'd actually have a configuration item to disable log backups but it's not essential and can be added later if necessary.
Also please change the new logging code to match existing style: open_log_file() -> log_file_open()
Thanks!