[Xfce4-commits] [xfce/xfce4-session] 01/01: Gracefully handle the sessions dir being readonly (Bug #11307)

noreply at xfce.org noreply at xfce.org
Wed Dec 10 17:45:39 CET 2014


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-session.

commit 2fb1b8f8313d6246dc7f79b35bd5a2fab6c41282
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Mon Dec 8 15:33:07 2014 +0300

    Gracefully handle the sessions dir being readonly (Bug #11307)
    
    If the user has their ~/.cache/sessions directory set as read-only
    xfsm would crash on logout. This patch has xfsm check before it
    writes to that folder location.
---
 xfce4-session/xfsm-logout-dialog.c |    8 ++++++++
 xfce4-session/xfsm-manager.c       |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/xfce4-session/xfsm-logout-dialog.c b/xfce4-session/xfsm-logout-dialog.c
index 5374551..c86a155 100644
--- a/xfce4-session/xfsm-logout-dialog.c
+++ b/xfce4-session/xfsm-logout-dialog.c
@@ -588,6 +588,14 @@ xfsm_logout_dialog_screenshot_save (GdkPixbuf   *screenshot,
       g_free (display_name);
       g_free (path);
 
+      if (!filename)
+        {
+          g_warning ("Unable to save screenshot, "
+                     "error calling xfce_resource_save_location with %s, "
+                     "check your permissions", path);
+          return;
+        }
+
       if (!gdk_pixbuf_save (scaled, filename, "png", &error, NULL))
         {
           g_warning ("Failed to save session screenshot: %s", error->message);
diff --git a/xfce4-session/xfsm-manager.c b/xfce4-session/xfsm-manager.c
index dc2960e..8b62607 100644
--- a/xfce4-session/xfsm-manager.c
+++ b/xfce4-session/xfsm-manager.c
@@ -741,7 +741,7 @@ xfsm_manager_load_settings (XfsmManager   *manager,
             }
 
           /* FIXME: migrate this into the splash screen somehow so the
-           * window doesn't look ugly (right now now WM is running, so it
+           * window doesn't look ugly (right now no WM is running, so it
            * won't have window decorations). */
           xfce_message_dialog (NULL, _("Session Manager Error"),
                                GTK_STOCK_DIALOG_ERROR,
@@ -1652,6 +1652,8 @@ xfsm_manager_store_session (XfsmManager *manager)
   GdkDisplay    *display;
   WnckScreen    *screen;
   XfceRc        *rc;
+  GFile         *session_file;
+  GFileInfo     *info;
   GList         *lp;
   gchar          prefix[64];
   gchar         *backup;
@@ -1659,6 +1661,7 @@ xfsm_manager_store_session (XfsmManager *manager)
   gint           count = 0;
   gint           n, m;
 
+  /* open file for writing, creates it if it doesn't exist */
   rc = xfce_rc_simple_open (manager->session_file, FALSE);
   if (G_UNLIKELY (rc == NULL))
     {
@@ -1670,6 +1673,32 @@ xfsm_manager_store_session (XfsmManager *manager)
       return;
     }
 
+  session_file = g_file_new_for_path (manager->session_file);
+
+  /* query the file, we need to make sure we can write to it */
+  info = g_file_query_info (session_file,
+                            G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
+                            G_FILE_QUERY_INFO_NONE,
+                            NULL,
+                            NULL);
+
+  /* if we're unable to query the file attributes or write to the file,
+   * log the failure and return */
+  if (!info || !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
+    {
+      fprintf (stderr,
+               "xfce4-session: Unable to save changes to the session file %s"
+               "Please check your installation.\n", manager->session_file);
+
+      if (info)
+        g_object_unref (info);
+
+      xfce_rc_close (rc);
+      g_object_unref (session_file);
+
+      return;
+    }
+
   /* backup the old session file first */
   if (g_file_test (manager->session_file, G_FILE_TEST_IS_REGULAR))
     {
@@ -1743,6 +1772,8 @@ xfsm_manager_store_session (XfsmManager *manager)
 
   xfce_rc_close (rc);
 
+  g_object_unref (session_file);
+
   g_free (manager->checkpoint_session_name);
   manager->checkpoint_session_name = NULL;
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list