Isn’t $HOME supposed to be the location of the user’s home directory?

I’m having trouble with a web application I’m writing: The web application, which runs as user nobody, needs to launch an inkscape process to manipulate some SVG files. Because this runs as user nobody, there is no home directory. What I am doing is creating a temporary directory under /tmp and trying to set that as the home directory via export HOME=/tmp/someUniqueId. I then set a few things in that “temporary” home directory, like a symlink .fonts to the folder for the font files to use.

I know this works for finding the ~/.fonts directory. But when I launch Inkscape, all I get is a message that Inkscape could not create the .inkscape directory:

Cannot create directory /.inkscape

Doesn’t $HOME set the location of my home directory? Why is Inkscape still trying to access / as my home directory?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Inkscape, being a GTK application, uses the GLib g_get_home_dir function to find the user’s home directory. As documented in that link, g_get_home_dir does not consult $HOME, but rather /etc/passwd. You’d have to patch Inkscape to check $HOME first (as shown in that link).

Method 2

Yes, the home directory of the current user should be whatever the environment variable HOME indicates. There is, of course, a global system setting: the entry in /etc/passwd, or more generally the home field in the user database. Applications are supposed to use that setting only to look up a user other than the current user, or if there are security applications (e.g. a setuid program). Otherwise $HOME should take precedence. If it doesn’t, it’s a bug in the application.

cjm’s answer shows that Inkscape and other Gnome applications are buggy in this regard.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x