Commit 178459c3 authored by Martin Pitt's avatar Martin Pitt
Browse files

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
parent c32e97cd
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment