summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-02-20 12:04:30 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-02-20 12:04:30 +0100
commit4e6dcf3e37e9aba48ab80f4db3606bcdb46d3032 (patch)
tree9bcd952af9b4e8279d25c42329cfe0566aa0d3e4
parent3339bbbf9ee58d4562ed008ce45c5af7fbe222c9 (diff)
downloadratpoison-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.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index e2cea15..e5456c6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;