Index: rcfile.c =================================================================== RCS file: /cvsroot/nano/nano/rcfile.c,v retrieving revision 1.37 diff -u -r1.37 rcfile.c --- rcfile.c 29 Mar 2002 19:41:57 -0000 1.37 +++ rcfile.c 29 Mar 2002 20:40:24 -0000 @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -447,6 +449,7 @@ char *unable = _("Unable to open ~/.nanorc file, %s"); struct stat fileinfo; FILE *rcstream; + struct passwd *userage; if (getenv("HOME") == NULL) return; @@ -463,10 +466,21 @@ fclose(rcstream); } - nanorc = charalloc(strlen(getenv("HOME")) + 10); - sprintf(nanorc, "%s/.nanorc", getenv("HOME")); - lineno = 0; + + /* Determine home directory using getpwent(), don't rely on $HOME */ + for (userage = getpwent(); userage != NULL + && userage->pw_uid != geteuid(); userage = getpwent()) + ; + + if (userage == NULL) { + rcfile_error(_("I can't find my home directory! Wah!")); + return; + } + + nanorc = charalloc(strlen(userage->pw_dir) + 10); + sprintf(nanorc, "%s/.nanorc", userage->pw_dir); + if (stat(nanorc, &fileinfo) == -1) { /* Abort if the file doesn't exist and there's some other kind