Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/su Change to home directory only after setting the f...



details:   https://anonhg.NetBSD.org/src/rev/023f6f901c4b
branches:  trunk
changeset: 787715:023f6f901c4b
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Jun 29 05:08:35 2013 +0000

description:
Change to home directory only after setting the full user context
to avoid issues with NFS or other user-mapped mounts that don't
give root the privilege to chdir there.

diffstat:

 usr.bin/su/su_pam.c |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (41 lines):

diff -r 8b2b95a29468 -r 023f6f901c4b usr.bin/su/su_pam.c
--- a/usr.bin/su/su_pam.c       Sat Jun 29 04:52:55 2013 +0000
+++ b/usr.bin/su/su_pam.c       Sat Jun 29 05:08:35 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: su_pam.c,v 1.18 2013/06/20 20:54:02 christos Exp $     */
+/*     $NetBSD: su_pam.c,v 1.19 2013/06/29 05:08:35 mlelstv Exp $      */
 
 /*
  * Copyright (c) 1988 The Regents of the University of California.
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)su.c       8.3 (Berkeley) 4/2/94";*/
 #else
-__RCSID("$NetBSD: su_pam.c,v 1.18 2013/06/20 20:54:02 christos Exp $");
+__RCSID("$NetBSD: su_pam.c,v 1.19 2013/06/29 05:08:35 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -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:



Home | Main Index | Thread Index | Old Index