[gdm] Try to save session log to XDG cache dir
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm] Try to save session log to XDG cache dir
- Date: Mon, 30 Apr 2012 19:22:06 +0000 (UTC)
commit 06db2b1bcfa75cbb0cd58368e1ac0f1dcd0d7d52
Author: William Jon McCann <jmccann redhat com>
Date: Thu Apr 26 15:07:33 2012 -0400
Try to save session log to XDG cache dir
This moves the default location of the session log message
from ~/.xsession-errors to $XDG_CACHE_HOME/gdm/session.log
This helps avoid clobbering the log files when shared
home directories are used.
See https://live.gnome.org/GnomeGoals/XDGConfigFolders
https://bugzilla.gnome.org/show_bug.cgi?id=627939
daemon/gdm-session-worker.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 57f1071..8567e78 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -87,7 +87,7 @@
#endif
#ifndef GDM_SESSION_LOG_FILENAME
-#define GDM_SESSION_LOG_FILENAME ".xsession-errors"
+#define GDM_SESSION_LOG_FILENAME "session.log"
#endif
#define MAX_FILE_SIZE 65536
@@ -1886,9 +1886,30 @@ gdm_session_worker_start_session (GdmSessionWorker *worker,
if (worker->priv->is_program_session) {
fd = _open_program_session_log (worker->priv->log_file);
} else {
- fd = _open_user_session_log (home_dir);
+ if (home_dir != NULL && home_dir[0] != '\0') {
+ char *cache_dir;
+ char *log_dir;
+
+ cache_dir = gdm_session_worker_get_environment_variable (worker, "XDG_CACHE_HOME");
+ if (cache_dir == NULL || cache_dir[0] == '\0') {
+ cache_dir = g_build_filename (home_dir, ".cache", NULL);
+ }
+
+ log_dir = g_build_filename (cache_dir, "gdm", NULL);
+ g_free (cache_dir);
+
+ if (g_mkdir_with_parents (log_dir, S_IRWXU) == 0) {
+ fd = _open_user_session_log (log_dir);
+ } else {
+ fd = open ("/dev/null", O_RDWR);
+ }
+ g_free (log_dir);
+ } else {
+ fd = open ("/dev/null", O_RDWR);
+ }
}
g_free (home_dir);
+
dup2 (fd, STDOUT_FILENO);
dup2 (fd, STDERR_FILENO);
close (fd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]