1 Index: backends/xml-backend.c
2 ===================================================================
3 RCS file: /cvs/gnome/gconf/backends/xml-backend.c,v
4 retrieving revision 1.81
5 diff -u -p -u -r1.81 xml-backend.c
6 --- GConf-1.2.1/backends/xml-backend.c 21 Mar 2002 23:55:06 -0000 1.81
7 +++ GConf-1.2.1/backends/xml-backend.c 21 Aug 2002 12:47:17 -0000
8 @@ -206,6 +206,8 @@ static void destroy_source (GC
10 static void clear_cache (GConfSource* source);
12 +static void blow_away_locks (const char *address);
14 static GConfBackendVTable xml_vtable = {
17 @@ -224,7 +226,8 @@ static GConfBackendVTable xml_vtable = {
27 @@ -267,13 +270,48 @@ writable (GConfSource* source,
32 +get_dir_from_address (const char *address,
38 + root_dir = gconf_address_resource (address);
40 + if (root_dir == NULL)
42 + gconf_set_error (err, GCONF_ERROR_BAD_ADDRESS,
43 + _("Couldn't find the XML root directory in the address `%s'"),
48 + /* Chop trailing '/' to canonicalize */
49 + len = strlen (root_dir);
51 + if (root_dir[len-1] == '/')
52 + root_dir[len-1] = '\0';
58 +get_lock_dir_from_root_dir (const char *root_dir)
62 + lockdir = gconf_concat_dir_and_key (root_dir, "%gconf-xml-backend.lock");
68 resolve_address (const gchar* address, GError** err)
75 GConfLock* lock = NULL;
76 guint dir_mode = 0700;
77 @@ -281,20 +319,10 @@ resolve_address (const gchar* address, G
78 gchar** address_flags;
80 gboolean force_readonly;
82 - root_dir = gconf_address_resource(address);
84 + root_dir = get_dir_from_address (address, err);
87 - gconf_set_error(err, GCONF_ERROR_BAD_ADDRESS, _("Couldn't find the XML root directory in the address `%s'"), address);
91 - /* Chop trailing '/' to canonicalize */
92 - len = strlen(root_dir);
94 - if (root_dir[len-1] == '/')
95 - root_dir[len-1] = '\0';
98 if (mkdir(root_dir, dir_mode) < 0)
100 @@ -374,7 +402,7 @@ resolve_address (const gchar* address, G
104 - lockdir = gconf_concat_dir_and_key(root_dir, "%gconf-xml-backend.lock");
105 + lockdir = get_lock_dir_from_root_dir (root_dir);
107 lock = gconf_get_lock(lockdir, err);
109 @@ -712,6 +740,58 @@ clear_cache (GConfSource* source)
111 /* clean all entries older than 0 seconds */
112 cache_clean(xs->cache, 0);
116 +blow_away_locks (const char *address)
121 + struct dirent *dent;
123 + root_dir = get_dir_from_address (address, NULL);
124 + if (root_dir == NULL)
127 + lock_dir = get_lock_dir_from_root_dir (root_dir);
129 + dp = opendir (lock_dir);
133 + g_printerr (_("Could not open lock directory for %s to remove locks: %s\n"),
134 + address, g_strerror (errno));
138 + while ((dent = readdir (dp)) != NULL)
142 + /* ignore ., .. (and any ..foo as an intentional who-cares bug) */
143 + if (dent->d_name[0] == '.' &&
144 + (dent->d_name[1] == '\0' || dent->d_name[1] == '.'))
147 + path = g_build_filename (lock_dir, dent->d_name, NULL);
149 + if (unlink (path) < 0)
151 + g_printerr (_("Could not remove file %s: %s\n"),
152 + path, g_strerror (errno));
168 Index: gconf/gconf-backend.c
169 ===================================================================
170 RCS file: /cvs/gnome/gconf/gconf/gconf-backend.c,v
171 retrieving revision 1.21
172 diff -u -p -u -r1.21 gconf-backend.c
173 --- GConf-1.2.1/gconf/gconf-backend.c 4 Dec 2001 22:17:09 -0000 1.21
174 +++ GConf-1.2.1/gconf/gconf-backend.c 21 Aug 2002 12:47:17 -0000
175 @@ -353,5 +353,15 @@ gconf_backend_resolve_address (GConfBack
180 +gconf_blow_away_locks (const gchar* address)
182 + GConfBackend* backend;
184 + backend = gconf_get_backend (address, NULL);
186 + if (backend != NULL)
188 + (*backend->vtable->blow_away_locks) (address);
191 Index: gconf/gconf-backend.h
192 ===================================================================
193 RCS file: /cvs/gnome/gconf/gconf/gconf-backend.h,v
194 retrieving revision 1.29
195 diff -u -p -u -r1.29 gconf-backend.h
196 --- GConf-1.2.1/gconf/gconf-backend.h 13 Jul 2001 22:07:37 -0000 1.29
197 +++ GConf-1.2.1/gconf/gconf-backend.h 21 Aug 2002 12:47:17 -0000
198 @@ -127,6 +127,9 @@ struct _GConfBackendVTable {
200 /* This is basically used by the test suite */
201 void (* clear_cache) (GConfSource* source);
203 + /* used by gconf-sanity-check */
204 + void (* blow_away_locks) (const char *address);
207 struct _GConfBackend {
208 @@ -161,6 +164,8 @@ void gconf_backend_unref(GConfB
209 GConfSource* gconf_backend_resolve_address (GConfBackend* backend,
210 const gchar* address,
213 +void gconf_blow_away_locks (const gchar* address);
217 Index: gconf/gconf-internals.c
218 ===================================================================
219 RCS file: /cvs/gnome/gconf/gconf/gconf-internals.c,v
220 retrieving revision 1.114
221 diff -u -p -u -r1.114 gconf-internals.c
222 --- GConf-1.2.1/gconf/gconf-internals.c 4 Aug 2002 17:44:16 -0000 1.114
223 +++ GConf-1.2.1/gconf/gconf-internals.c 21 Aug 2002 12:47:18 -0000
224 @@ -2701,6 +2701,24 @@ gconf_get_current_lock_holder (const gc
229 +gconf_daemon_blow_away_locks (void)
231 + char *lock_directory;
234 + lock_directory = gconf_get_lock_dir ();
236 + iorfile = g_strconcat (lock_directory, "/ior", NULL);
238 + if (unlink (iorfile) < 0)
239 + g_printerr (_("Failed to unlink lock file %s: %s\n"),
240 + iorfile, g_strerror (errno));
243 + g_free (lock_directory);
246 static CORBA_ORB gconf_orb = CORBA_OBJECT_NIL;
249 Index: gconf/gconf-internals.h
250 ===================================================================
251 RCS file: /cvs/gnome/gconf/gconf/gconf-internals.h,v
252 retrieving revision 1.74
253 diff -u -p -u -r1.74 gconf-internals.h
254 --- GConf-1.2.1/gconf/gconf-internals.h 3 Jun 2002 02:36:26 -0000 1.74
255 +++ GConf-1.2.1/gconf/gconf-internals.h 21 Aug 2002 12:47:18 -0000
256 @@ -190,6 +190,8 @@ GConfLock* gconf_get_lock_or_current_hol
257 ConfigServer gconf_get_current_lock_holder (const gchar *lock_directory,
258 GString *failure_log);
260 +void gconf_daemon_blow_away_locks (void);
262 GError* gconf_error_new (GConfError en,
263 const gchar* format, ...) G_GNUC_PRINTF (2, 3);
265 Index: gconf/gconf-sanity-check.c
266 ===================================================================
267 RCS file: /cvs/gnome/gconf/gconf/gconf-sanity-check.c,v
268 retrieving revision 1.4
269 diff -u -p -u -r1.4 gconf-sanity-check.c
270 --- GConf-1.2.1/gconf/gconf-sanity-check.c 21 Mar 2002 23:55:09 -0000 1.4
271 +++ GConf-1.2.1/gconf/gconf-sanity-check.c 21 Aug 2002 12:47:18 -0000
272 @@ -53,8 +53,9 @@ struct poptOption options[] = {
273 static gboolean ensure_gtk (void);
274 static void show_fatal_error_dialog (const char *format,
275 ...) G_GNUC_PRINTF (1, 2);
276 +static gboolean offer_delete_locks (void);
277 static gboolean check_file_locking (void);
278 -static gboolean check_gconf (void);
279 +static gboolean check_gconf (gboolean display_errors);
282 main (int argc, char** argv)
283 @@ -83,8 +84,14 @@ main (int argc, char** argv)
284 if (!check_file_locking ())
287 - if (!check_gconf ())
289 + if (!check_gconf (FALSE))
291 + if (!offer_delete_locks ())
294 + if (!check_gconf (TRUE))
300 @@ -164,7 +171,7 @@ check_file_locking (void)
305 +check_gconf (gboolean display_errors)
309 @@ -192,11 +199,12 @@ check_gconf (void)
311 if (addresses == NULL)
313 - show_fatal_error_dialog (_("Please contact your system administrator to resolve the following problem:\n"
314 - "No configuration sources in the configuration file \"%s\"; this means that preferences and other settings can't be saved. %s%s"),
316 - error ? _("Error reading the file: ") : "",
317 - error ? error->message : "");
318 + if (display_errors)
319 + show_fatal_error_dialog (_("Please contact your system administrator to resolve the following problem:\n"
320 + "No configuration sources in the configuration file \"%s\"; this means that preferences and other settings can't be saved. %s%s"),
322 + error ? _("Error reading the file: ") : "",
323 + error ? error->message : "");
326 g_error_free (error);
327 @@ -217,9 +225,10 @@ check_gconf (void)
331 - show_fatal_error_dialog (_("Please contact your system administrator to resolve the following problem:\n"
332 - "Could not resolve the address \"%s\" in the configuration file \"%s\": %s"),
333 - address, conffile, error->message);
334 + if (display_errors)
335 + show_fatal_error_dialog (_("Please contact your system administrator to resolve the following problem:\n"
336 + "Could not resolve the address \"%s\" in the configuration file \"%s\": %s"),
337 + address, conffile, error->message);
338 g_error_free (error);
341 @@ -269,6 +278,97 @@ show_fatal_error_dialog (const char *for
342 gtk_dialog_run (GTK_DIALOG (d));
344 gtk_widget_destroy (d);
348 +offer_delete_locks (void)
350 + gboolean delete_locks;
351 + const char *question;
353 + delete_locks = FALSE;
354 + question = _("Your preferences files are currently in use. "
355 + "(If you are logged in to this same account from "
356 + "another computer, the other login session is probably using "
357 + "your preferences files.) "
358 + "You can choose to continue, but be aware that other login "
359 + "sessions may become temporarily confused. "
360 + "If you are not logged in elsewhere, it should be harmless to "
368 + d = gtk_message_dialog_new (NULL, 0,
373 + gtk_dialog_add_buttons (GTK_DIALOG (d),
375 + GTK_RESPONSE_REJECT,
377 + GTK_RESPONSE_ACCEPT,
380 + response = gtk_dialog_run (GTK_DIALOG (d));
382 + gtk_widget_destroy (d);
384 + if (response == GTK_RESPONSE_ACCEPT)
385 + delete_locks = TRUE;
389 + g_print (_("%s Continue (y/n)?"), question);
390 + switch (getchar ())
394 + delete_locks = TRUE;
405 + conffile = g_strconcat (GCONF_CONFDIR, "/path", NULL);
407 + addresses = gconf_load_source_path (conffile, NULL);
411 + if (addresses == NULL)
412 + g_printerr ("Failed to load addresses to delete locks\n");
415 + while (tmp != NULL)
417 + const char *address;
419 + address = tmp->data;
421 + gconf_blow_away_locks (address);
423 + g_free (tmp->data);
428 + g_slist_free (addresses);
430 + gconf_daemon_blow_away_locks ();
438 /* this is because setting up gtk is kind of slow, no point doing it