[gdm] Allow .xsession-errors to be a symlink or FIFO
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm] Allow .xsession-errors to be a symlink or FIFO
- Date: Tue, 7 Jun 2011 19:09:13 +0000 (UTC)
commit 178459c33a64170d9ebe83ebbaeabeb05574f169
Author: Martin Pitt <martin pitt ubuntu com>
Date: Tue Jun 7 20:02:46 2011 +0200
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
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 b0a4aa7..d35755c 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]