Re: GConf, local lock and TMPDIR
- From: Frederic Crozat <fcrozat mandrakesoft com>
- To: gconf-list gnome org
- Subject: Re: GConf, local lock and TMPDIR
- Date: Wed, 15 Oct 2003 17:09:24 +0200
Le mer 15/10/2003 à 06:38, Malcolm Tredinnick a écrit :
> On Wed, 2003-10-15 at 14:18, Havoc Pennington wrote:
> > On Tue, 2003-10-14 at 12:10, Frederic Crozat wrote:
> > > This problem is supposed to be fixed in 2.4 using local lock workaround.
> > > Unfortunately, gconf is using g_get_tmp_dir to get temporary directory..
> > > This is a problem when user set TMPDIR variable to $HOME/tmp (this is by
> > > default on Mdk system)..
> >
> > Forcing /tmp isn't really right, since people may legitimately relocate
> > to TMPDIR. I'd suggest that either people use GCONF_GLOBAL_LOCKS=1, or
> > on Mandrake you hardcode /var/tmp or something in gconf maybe?
> >
> > Dunno, we ultimately need to find a non-hack solution.
>
> How about something as simple as adding another environment variable to
> the list? If $GCONF_TMPDIR is set, that gets used, otherwise use
> $TMPDIR. Then Mandrake can set $GCONF_TMPDIR and the rest of us will
> have it work just out of the box.
I like that a lot..
Here is the patch (for GConf2, I also did a similar patch for GConf
1.0.x)
Havoc, any comment on it ?
BTW, it seems gconf FAQ webpage is not up to date regarding locking in
2.4 ..
--
Frederic Crozat <fcrozat mandrakesoft com>
Mandrakesoft
--- GConf/gconf/gconf-internals.c 11 Aug 2003 17:04:01 -0000 1.120
+++ GConf/gconf/gconf-internals.c 15 Oct 2003 12:13:48 -0000
@@ -2785,10 +2785,17 @@
{
char *s;
char *subdir;
+ char *tmpdir;
subdir = g_strconcat ("gconfd-", g_get_user_name (), NULL);
- s = g_build_filename (g_get_tmp_dir (), subdir, NULL);
+ if (g_getenv ("GCONF_TMPDIR")) {
+ tmpdir = g_getenv ("GCONF_TMPDIR");
+ } else {
+ tmpdir = g_get_tmp_dir ();
+ }
+
+ s = g_build_filename (tmpdir, subdir, NULL);
g_free (subdir);
Index: gconf/gconf-sanity-check.c
===================================================================
RCS file: /cvs/gnome/gconf/gconf/gconf-sanity-check.c,v
retrieving revision 1.6
diff -u -r1.6 gconf-sanity-check.c
--- GConf/gconf/gconf-sanity-check.c 27 Mar 2003 11:16:18 -0000 1.6
+++ GConf/gconf/gconf-sanity-check.c 15 Oct 2003 12:13:48 -0000
@@ -132,9 +132,23 @@
GError *err;
err = NULL;
- fd = g_file_open_tmp ("gconf-test-locking-file-XXXXXX",
- &testfile,
- &err);
+ if (g_getenv ("GCONF_TMPDIR")) {
+ testfile = g_build_filename(g_getenv ("GCONF_TMPDIR"), "gconf-test-locking-file-XXXXXX");
+ fd = g_mkstemp (testfile);
+ if (fd == -1)
+ {
+ g_set_error (&err,
+ G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ "Failed to create file '%s': %s",
+ testfile, g_strerror (errno));
+ }
+ }
+ else {
+ fd = g_file_open_tmp ("gconf-test-locking-file-XXXXXX",
+ &testfile,
+ &err);
+ }
if (err != NULL)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]