diff -u -r ratpoison/src/main.c ratpoison-getpwuid/src/main.c --- ratpoison/src/main.c Mon Jun 11 03:27:49 2001 +++ ratpoison-getpwuid/src/main.c Sat Jun 23 04:26:11 2001 @@ -33,6 +33,7 @@ #include #include #include +#include #include "ratpoison.h" @@ -135,7 +136,7 @@ char error_msg[100]; if (e->request_code == X_ChangeWindowAttributes && e->error_code == BadAccess) { - fprintf(stderr, "ratpoison: There can be only ONE.\n"); + fprintf(stderr, "ratpoison: There can be only ONE. (Another WM seems to be running)\n"); exit(EXIT_FAILURE); } @@ -257,19 +258,24 @@ static void read_startup_files () { - char *homedir; + struct passwd *passwd; FILE *fileptr; - /* first check $HOME/.ratpoisonrc and if that does not exist then try + /* first check ~/.ratpoisonrc and if that does not exist then try /etc/ratpoisonrc */ - homedir = getenv ("HOME"); - if (!homedir) + /* isn't this a better solution than checking $HOME? */ + + passwd = getpwuid(getuid()); + + if ((!passwd)||(!(passwd->pw_dir))) /* Can one be sure that !passwd gets checked before passwd->dir? segfaults here would be ugly */ { - PRINT_ERROR ("ratpoison: $HOME not set!?\n"); + PRINT_ERROR ("ratpoison: Could not understand where you're home is.\n"); } else { + char *homedir = passwd->pw_dir; + char *filename = (char*)xmalloc (strlen (homedir) + strlen ("/.ratpoisonrc") + 1); sprintf (filename, "%s/.ratpoisonrc", homedir);