Index: su/su_pam.c
===================================================================
RCS file: /cvsroot/src/usr.bin/su/su_pam.c,v
retrieving revision 1.18
diff -u -r1.18 su_pam.c
--- su/su_pam.c	20 Jun 2013 20:54:02 -0000	1.18
+++ su/su_pam.c	29 Jun 2013 05:00:01 -0000
@@ -493,8 +493,6 @@
 				err(EXIT_FAILURE, "setting user context");
 			if (p)
 				(void)setenv("TERM", p, 1);
-			if (gohome && chdir(pwd->pw_dir) == -1)
-				errx(EXIT_FAILURE, "no directory");
 		}
 
 		if (asthem || pwd->pw_uid) {
@@ -552,6 +550,13 @@
 	if (setusercontext(lc, pwd, pwd->pw_uid, setwhat) == -1)
 		err(EXIT_FAILURE, "setusercontext");
 
+	if (!asme) {
+		if (asthem) {
+			if (gohome && chdir(pwd->pw_dir) == -1)
+				errx(EXIT_FAILURE, "no directory");
+		}
+	}
+
 	(void)execv(shell, np);
 	err(EXIT_FAILURE, "%s", shell);
 done:
