[gnome-initial-setup] copy-worker: Exit if the skeleton directory isn't ours



commit 8706a28bc433928bfbad3f5ea126637866753548
Author: Rui Matos <tiagomatos gmail com>
Date:   Sun Jun 2 18:57:52 2013 +0200

    copy-worker: Exit if the skeleton directory isn't ours
    
    If the skeleton directory isn't ours we shouldn't be copying anything
    from it. Depending on its permissions we might even be unable to copy
    and then we'd still go on and added our gnome-initial-setup-done flag
    file erroneously.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701100

 .../gnome-initial-setup-copy-worker.c              |   23 +++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/gnome-initial-setup/gnome-initial-setup-copy-worker.c 
b/gnome-initial-setup/gnome-initial-setup-copy-worker.c
index 92fc461..b6c10a1 100644
--- a/gnome-initial-setup/gnome-initial-setup-copy-worker.c
+++ b/gnome-initial-setup/gnome-initial-setup-copy-worker.c
@@ -21,6 +21,26 @@ get_gnome_initial_setup_home_dir (void)
     return NULL;
 }
 
+static gboolean
+file_is_ours (GFile *file)
+{
+  GFileInfo *info;
+  uid_t uid;
+
+  info = g_file_query_info (file,
+                            G_FILE_ATTRIBUTE_UNIX_UID,
+                            G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                            NULL,
+                            NULL);
+  if (!info)
+    return FALSE;
+
+  uid = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_UID);
+  g_object_unref (info);
+
+  return uid == geteuid ();
+}
+
 static void
 move_file_from_tmpfs (GFile       *src_base,
                       GFile       *dest_base,
@@ -63,7 +83,8 @@ main (int    argc,
 
   src = g_file_new_for_path (initial_setup_homedir);
 
-  if (!g_file_query_exists (src, NULL))
+  if (!g_file_query_exists (src, NULL) ||
+      !file_is_ours (src))
     exit (EXIT_SUCCESS);
 
   dest = g_file_new_for_path (g_get_home_dir ());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]