diff options
author | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2014-02-20 12:04:30 +0100 |
---|---|---|
committer | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2014-02-20 12:04:30 +0100 |
commit | 4e6dcf3e37e9aba48ab80f4db3606bcdb46d3032 (patch) | |
tree | 9bcd952af9b4e8279d25c42329cfe0566aa0d3e4 | |
parent | 3339bbbf9ee58d4562ed008ce45c5af7fbe222c9 (diff) | |
download | ratpoison-4e6dcf3e37e9aba48ab80f4db3606bcdb46d3032.zip |
If HOME is not set in the env., fallback to the passwd entry.
* No attempt to detect pwd.h / getpwuid, not sure if needed.
-rw-r--r-- | src/main.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -35,6 +35,7 @@ #include <string.h> #include <sys/wait.h> #include <ctype.h> +#include <pwd.h> #include "ratpoison.h" @@ -423,8 +424,15 @@ read_startup_files (char *alt_rcfile) homedir = getenv ("HOME"); if (!homedir) { - PRINT_ERROR (("ratpoison: $HOME not set!?\n")); + struct passwd *pw; + + pw = getpwuid (getuid ()); + if (pw) + homedir = pw->pw_dir; } + + if (!homedir) + PRINT_ERROR (("ratpoison: no home directory!?\n")); else { char *filename; |