diff --git a/ChangeLog b/ChangeLog
index e5bcc07a6441249ecc5649a2e7723c437ae465db..c70403d99a503bfa6ee6118e31a90d4ac21c6d18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -62,6 +62,11 @@ CVS code
 	  (David Benbennick).
   colortoint, parse_colors()
 	- Don't add strings with invalid fg colors at all.
+  do_rcfile()
+	- Revert (somewhat) previous behavior of looking at 
+	  $HOME, and only run getpw* if it is NULL.  Most *nix programs
+	  seem to only care about $HOME, and at the user-level 
+	  getpw* may not be reliable (and its slower).
 - search.c:
   do_gotoline()
 	- Only goto_abort() if we *didnt* abort the command, making
diff --git a/rcfile.c b/rcfile.c
index 03f5dfeede70eb572158258b498d516aec106272..829a1efb2c6d7a6a76607f8228b69026345f447b 100644
--- a/rcfile.c
+++ b/rcfile.c
@@ -635,20 +635,27 @@ void do_rcfile(void)
     }
 #endif
 
-    /* Determine home directory using getpwent(), don't rely on $HOME */
-    do {
-	userage = getpwent();
-    } while (userage != NULL && userage->pw_uid != euid);
-    endpwent();
-
     lineno = 0;
 
-    if (userage == NULL) {
-	rcfile_error(_("I can't find my home directory!  Wah!"));
-	SET(NO_RCFILE);
+    /* Rely on $HOME, fall back on getpwuid() */
+    if (getenv("HOME") != NULL) {
+	nanorc = nrealloc(nanorc, strlen(getenv("HOME")) + 10);
+	sprintf(nanorc, "%s/.nanorc", getenv("HOME"));
     } else {
-	nanorc = nrealloc(nanorc, strlen(userage->pw_dir) + 9);
-	sprintf(nanorc, "%s/.nanorc", userage->pw_dir);
+	userage = getpwuid(euid);
+	endpwent();
+
+	if (userage == NULL) {
+	    rcfile_error(_("I can't find my home directory!  Wah!"));
+	    SET(NO_RCFILE);
+	} else {
+	    nanorc = nrealloc(nanorc, strlen(userage->pw_dir) + 9);
+	    sprintf(nanorc, "%s/.nanorc", userage->pw_dir);
+
+	}
+    }
+
+    if (!ISSET(NO_RCFILE)) {
 
 #if defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING)
     /* If we've already read $SYSCONFDIR/nanorc (if it's there), we're