diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2011-06-07 20:02:46 +0200 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2011-06-07 20:16:52 +0200 |
commit | 178459c33a64170d9ebe83ebbaeabeb05574f169 (patch) | |
tree | 679b9bf254b1029765fd548a0cf017fd7ae191a7 | |
parent | c32e97cd5b6729c7e503a323c1b8d2b1e74e16f1 (diff) | |
download | gdm-178459c33a64170d9ebe83ebbaeabeb05574f169.tar.gz |
Allow .xsession-errors to be a symlink or FIFO
Don't rename .xsession-errors to .xsession-errors.old if the file is not a
regular file. The later code will truncate the file to zero anyway, so even in
that case the file won't grow indefinitely.
This is handy when the home directory is on NFS and you want to avoid network
contention when there are buggy programs which spam .xsession-errors.
Also drop the second check that .xsession-errors is a regular file even if the
opening succeeded. With that, we'd open a temporary .xsession-errors.XXXXXX
even if ~/.xsession-errors was perfectly writable (such as being a symlink to
/dev/null).
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=639527
Bug-Ubuntu: https://launchpad.net/bugs/771661
-rw-r--r-- | daemon/gdm-session-worker.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c index b0a4aa7f..d35755ca 100644 --- a/daemon/gdm-session-worker.c +++ b/daemon/gdm-session-worker.c @@ -1618,15 +1618,15 @@ gdm_session_worker_watch_child (GdmSessionWorker *worker) } static gboolean -_fd_is_normal_file (int fd) +_is_loggable_file (const char* filename) { struct stat file_info; - if (fstat (fd, &file_info) < 0) { + if (g_lstat (filename, &file_info) < 0) { return FALSE; } - return S_ISREG (file_info.st_mode); + return S_ISREG (file_info.st_mode) && g_access (filename, R_OK | W_OK) == 0; } static int @@ -1637,7 +1637,7 @@ _open_session_log (const char *dir) filename = g_build_filename (dir, GDM_SESSION_LOG_FILENAME, NULL); - if (g_access (dir, R_OK | W_OK | X_OK) == 0 && g_access (filename, R_OK | W_OK) == 0) { + if (g_access (dir, R_OK | W_OK | X_OK) == 0 && _is_loggable_file (filename)) { char *filename_old; filename_old = g_strdup_printf ("%s.old", filename); @@ -1647,7 +1647,7 @@ _open_session_log (const char *dir) fd = g_open (filename, O_RDWR | O_APPEND | O_CREAT, 0600); - if (fd < 0 || !_fd_is_normal_file (fd)) { + if (fd < 0) { char *temp_name; close (fd); @@ -1661,7 +1661,7 @@ _open_session_log (const char *dir) goto out; } - g_warning ("session log '%s' is not a normal file, logging session to '%s' instead.\n", filename, + g_warning ("session log '%s' is not appendable, logging session to '%s' instead.\n", filename, temp_name); g_free (filename); filename = temp_name; |