Package: gnome-vfs / 1:2.24.4-6

24_home_dir_fakeroot.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
Index: gnome-vfs-2.24.4/libgnomevfs/gnome-vfs-application-registry.c
===================================================================
--- gnome-vfs-2.24.4.orig/libgnomevfs/gnome-vfs-application-registry.c	2010-11-25 15:46:59.763441002 +1100
+++ gnome-vfs-2.24.4/libgnomevfs/gnome-vfs-application-registry.c	2010-11-25 15:47:10.953441002 +1100
@@ -965,7 +965,7 @@
 						       NULL);
 	gnome_registry_dir.system_dir = TRUE;
 	
-	user_registry_dir.dirname = g_build_filename (g_get_home_dir(),
+	user_registry_dir.dirname = g_build_filename (gnome_vfs_get_home_dir(),
 						      ".gnome",
 						      "application-info",
 						      NULL);
Index: gnome-vfs-2.24.4/libgnomevfs/gnome-vfs-init.c
===================================================================
--- gnome-vfs-2.24.4.orig/libgnomevfs/gnome-vfs-init.c	2010-11-25 15:46:59.793441002 +1100
+++ gnome-vfs-2.24.4/libgnomevfs/gnome-vfs-init.c	2010-11-25 15:47:34.113441001 +1100
@@ -57,37 +57,6 @@
 
 static GPrivate * private_is_primary_thread;
 
-static gboolean
-ensure_dot_gnome_exists (void)
-{
-	gboolean retval = TRUE;
-	gboolean create_dirs;
-	gchar *dirname;
-
-	/* If the user does not have a writable HOME directory, then
-	   avoid creating the directory. */
-	create_dirs = (g_access (g_get_home_dir(), W_OK) == 0);
-
-        if (create_dirs != TRUE)
-		return TRUE;
-
-	dirname = g_build_filename (g_get_home_dir (), ".gnome2", NULL);
-
-	if (!g_file_test (dirname, G_FILE_TEST_EXISTS)) {
-		if (g_mkdir (dirname, S_IRWXU) != 0) {
-			g_warning ("Unable to create ~/.gnome2 directory: %s",
-				   g_strerror (errno));
-			retval = FALSE;
-		}
-	} else if (!g_file_test (dirname, G_FILE_TEST_IS_DIR)) {
-		g_warning ("Error: ~/.gnome2 must be a directory.");
-		retval = FALSE;
-	}
-
-	g_free (dirname);
-	return retval;
-}
-
 static void
 gnome_vfs_thread_init (void)
 {
@@ -118,7 +87,8 @@
 	char *bogus_argv[2] = { "dummy", NULL };
 	*/
 	
-	if (!ensure_dot_gnome_exists ()) {
+	/* The first call also checks that ~/.gnome2 is writable. */
+	if (!gnome_vfs_get_home_dir ()) {
 		return FALSE;
 	}
 
Index: gnome-vfs-2.24.4/libgnomevfs/gnome-vfs-private-utils.c
===================================================================
--- gnome-vfs-2.24.4.orig/libgnomevfs/gnome-vfs-private-utils.c	2010-11-25 15:46:59.783441002 +1100
+++ gnome-vfs-2.24.4/libgnomevfs/gnome-vfs-private-utils.c	2010-11-25 15:47:42.053441001 +1100
@@ -1085,3 +1085,62 @@
 }
 #endif
 
+static gboolean
+ensure_dot_gnome_exists (gchar *home_dir)
+{
+	gboolean retval = TRUE;
+	gboolean create_dirs;
+	gchar *dirname;
+
+	/* If the user does not have a writable HOME directory, then
+	   avoid creating the directory. */
+	create_dirs = (g_access (home_dir, W_OK) == 0);
+
+        if (create_dirs != TRUE)
+		return TRUE;
+
+	dirname = g_build_filename (home_dir, ".gnome2", NULL);
+
+	if (!g_file_test (dirname, G_FILE_TEST_EXISTS)) {
+		if (g_mkdir (dirname, S_IRWXU) != 0) {
+			g_warning ("Unable to create ~/.gnome2 directory: %s",
+				   g_strerror (errno));
+			retval = FALSE;
+		}
+	} else if (!g_file_test (dirname, G_FILE_TEST_IS_DIR)) {
+		g_warning ("Error: ~/.gnome2 must be a directory.");
+		retval = FALSE;
+	}
+
+	g_free (dirname);
+	return retval;
+}
+
+/**
+ * gnome_vfs_get_home_dir:
+ *
+ * If ~/.gnome2 is writable, return the home directory
+ * Otherwise, return the contents of the HOME environment variable
+ *
+ * Return value: home directory if successful, NULL otherwise.
+ * Do not free the value returned.
+ */
+const gchar *
+gnome_vfs_get_home_dir (void)
+{
+	static gchar *home = NULL;
+
+	if (home == NULL) {
+		gchar *tmp = g_get_home_dir ();
+		if (ensure_dot_gnome_exists (tmp)) {
+			home = g_strdup (tmp);
+		} else {
+			gchar *tmp2 = g_getenv ("HOME");
+			if (!g_str_equal (tmp, tmp2) && ensure_dot_gnome_exists (tmp2)) {
+				home = g_strdup (tmp2);
+			}
+		}
+	}
+
+	return home;
+}
Index: gnome-vfs-2.24.4/libgnomevfs/gnome-vfs-private-utils.h
===================================================================
--- gnome-vfs-2.24.4.orig/libgnomevfs/gnome-vfs-private-utils.h	2010-11-25 15:46:59.773441002 +1100
+++ gnome-vfs-2.24.4/libgnomevfs/gnome-vfs-private-utils.h	2010-11-25 15:47:10.953441002 +1100
@@ -124,6 +124,8 @@
 
 #endif
 
+const gchar   *gnome_vfs_get_home_dir                     (void);
+
 G_END_DECLS
 
 #endif /* _GNOME_VFS_PRIVATE_UTILS_H */
Index: gnome-vfs-2.24.4/modules/file-method.c
===================================================================
--- gnome-vfs-2.24.4.orig/modules/file-method.c	2010-11-25 15:46:59.803441002 +1100
+++ gnome-vfs-2.24.4/modules/file-method.c	2010-11-25 15:47:10.953441002 +1100
@@ -1537,7 +1537,7 @@
 	GList *p;
 	char *buffer, *escaped_path, *escaped_mount_point;
 
-	cache_file_parent = append_to_path (g_get_home_dir (), TRASH_ENTRY_CACHE_PARENT);
+	cache_file_parent = append_to_path (gnome_vfs_get_home_dir (), TRASH_ENTRY_CACHE_PARENT);
 	cache_file_path = append_to_path (cache_file_parent, TRASH_ENTRY_CACHE_NAME);
 
 	if (mkdir_recursive (cache_file_parent, 0777) != 0) {
@@ -1676,7 +1676,7 @@
 	cached_trash_directories = NULL;
 
 	/* read in the entries from disk */
-	cache_file_path = g_build_filename (g_get_home_dir (),
+	cache_file_path = g_build_filename (gnome_vfs_get_home_dir (),
 					    TRASH_ENTRY_CACHE_PARENT,
 					    TRASH_ENTRY_CACHE_NAME,
 					    NULL);
@@ -1948,7 +1948,7 @@
 		return GNOME_VFS_ERROR_INVALID_URI;
 
 	/* We will need the URI and the stat structure for the home directory. */
-	home_directory = g_get_home_dir ();
+	home_directory = gnome_vfs_get_home_dir ();
 
 	if (gnome_vfs_context_check_cancellation (context)) {
 		g_free (full_name_near);