Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
Well apparently, HOME wasn't set to what you've expected. How exactly do you launch the app? Btw, are you sure inkscape is the right tool for the job? What do you need to modify in an SVG file? –  alex Jun 13 '11 at 20:10
1  
@alex: I'm sure HOME is being set correctly. Other apps respect it. bash respects it when I cd ~. What would you recommend for converting SVG 1.2 files to SVG 1.1, PDF, PNG, PostScript etc? Batick doesn't work. Must support <textFlow>s –  Josh Jun 13 '11 at 20:17
    
Did you try ImageMagick? I don't know for the different svg-formats, but it converts (convert) multiple graphic formats, and afaik PDF as well. –  user unknown Jun 13 '11 at 20:25
    
Not sure about SVG 1.2 to 1.1, but the rest seems to be the job for Cairo (cairographics.org) You may need to cross-breed cairo and librsvg, however, to render the SVG file on a cairo surface (and the latter can be anything like PDF, PNG, PostScript, etc.) –  alex Jun 13 '11 at 20:25
    
@alex: I will check out Cairo, thanks! Inkscape's PDF support actually has some issues with Illustrator compatibility, so if Cairo can fix that, I can drop the SVG 1.2->1.1, which is the only part of Inkscape requiring an X server, which is what causes the issue I have here! –  Josh Jun 13 '11 at 20:36

2 Answers 2

up vote 11 down vote accepted

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).

share|improve this answer
    
That answers my question, thanks! I guess I need to run the command as a user who has their homedir set to /tmp or something. –  Josh Jun 13 '11 at 20:57
3  
I'm sure g_get_home_dir uses nsswitch rather than simply checking /etc/passwd. (Same thing on personal computers, though.) –  grawity Jun 13 '11 at 21:53

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.

share|improve this answer
    
Thanks Gilles! That's helpful. –  Josh Jun 13 '11 at 22:08
    
Can you include a link for more information, regarding your claim that it should be considered a bug for an application to use nsswitch//etc/passwd to determine the location of its owner's home directory (besides of the exceptions you enumerated)? It seems to me that you're right, but it's hard to think of all possible situations, so a source with more information, or "official" recommendations from something like the Open Group or GNU Project, might enhance your answer. –  Eliah Kagan Sep 2 '12 at 20:31
    
@EliahKagan See for example POSIX: “Home directory: The directory specified by the HOME environment variable.” The HOME variable is guaranteed to be set at login time (but the user may override it). –  Gilles Sep 2 '12 at 21:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.