GNOME Bugzilla – Bug 106117
Trailing slashes should not be used when creating directories
Last modified: 2004-12-22 21:47:04 UTC
When libgnome tries to create the directories specified in the GNOME_DOT_GNOME and GNOME_DOT_GNOME_PRIVATE macros, it passes a trailing slash to the mkdir(2) function. This trailing slash causes problems in some OSes, specially in NetBSD, which are unable to create a directory if a trailing slash is passed. libgnome must be fixed in a way that this trailing slash is not passed to the mkdir(2) function. Note that this may be fixed in NetBSD itself (which will be difficult). Fixing it in libgnome is the best solution as it will benefit other operating systems and work in older (unmaintained) versions of NetBSD.
Havoc, are there issues with removing the trailing slashes from the two defines in gnome-init.h?
Yes, it could break code using those macros ("GNOME_DOT_GNOME"session" is currently a valid filename)
Created attachment 16609 [details] [review] This is the patch currently used in pkgsrc (using a function to create directories).
It may be interesting to implement the funcion proposed in bug #106160 (glib) in order to fix this one.
note that this function should be declared 'static' or the symbol will be exported and I don't think we want that.
Is this ok with Jeff's suggested change?
It seems ok to me (declaring the function static). I didn't do so because it's beeing used in two source files. But solving this is simple: either duplicate it (ugly) or write it alone in its own source file and later '#include' that from multiple places...
Created attachment 24382 [details] [review] Patch that makes the compatibility mkdir function static.
Ok. So the glib suggestion was closed as WONTFIX and a comment that calling mkdir(2) with trailing slashes was bad behaviour. Is libgnome still doing this and can we fix it in a sane way?
Looks to me like the code in libgnome_userdir_setup already chops off the trailing slash before calling mkdir. Closing this as fixed.
No wait, it only does that if it's been overriden through the GNOME22_USER_DIR environment variable.
Created attachment 27295 [details] [review] Fix which I'm going to commit I did something similar, about to commit it in a second.
OK, I've committed it.