]> granicus.if.org Git - sudo/commitdiff
Bracket initgroups with calls to aix_setauthdb() and aix_restoreauthdb()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 Jun 2010 22:56:44 +0000 (18:56 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 Jun 2010 22:56:44 +0000 (18:56 -0400)
--HG--
branch : 1.7

pwutil.c
set_perms.c
sudo_nss.c

index fae59652c4fd5a418598ab00e5810f2eb2ecd34c..a20a849f7b3bc772294eab96b2ba899491851cab 100644 (file)
--- a/pwutil.c
+++ b/pwutil.c
@@ -228,7 +228,7 @@ sudo_getpwnam(name)
      * Cache passwd db entry if it exists or a negative response if not.
      */
 #ifdef HAVE_SETAUTHDB
-    aix_setauthdb(name);
+    aix_setauthdb((char *) name);
 #endif
     if ((pw = getpwnam(name)) != NULL) {
        pw = sudo_pwdup(pw);
index cb08385614e815a8ac3933e61b7d6196dd314b97..41dd9a44ed42fc31d721b143a68d56d193f91124 100644 (file)
@@ -490,9 +490,9 @@ static void
 runas_setgroups()
 {
     static int ngroups = -1;
-#ifdef HAVE_GETGROUPS
+# ifdef HAVE_GETGROUPS
     static GETGROUPS_T *groups;
-#endif
+# endif
     struct passwd *pw;
 
     if (def_preserve_groups)
@@ -503,18 +503,24 @@ runas_setgroups()
      */
     if (ngroups == -1) {
        pw = runas_pw ? runas_pw : sudo_user.pw;
+# ifdef HAVE_SETAUTHDB
+       aix_setauthdb(pw->pw_name);
+# endif
        if (initgroups(pw->pw_name, pw->pw_gid) < 0)
            log_error(USE_ERRNO|MSG_ONLY, "can't set runas group vector");
-#ifdef HAVE_GETGROUPS
+# ifdef HAVE_GETGROUPS
        if ((ngroups = getgroups(0, NULL)) > 0) {
            groups = emalloc2(ngroups, sizeof(GETGROUPS_T));
            if (getgroups(ngroups, groups) < 0)
                log_error(USE_ERRNO|MSG_ONLY, "can't get runas group vector");
        }
+#  ifdef HAVE_SETAUTHDB
+       aix_restoreauthdb();
+#  endif
     } else {
        if (setgroups(ngroups, groups) < 0)
            log_error(USE_ERRNO|MSG_ONLY, "can't set runas group vector");
-#endif /* HAVE_GETGROUPS */
+# endif /* HAVE_GETGROUPS */
     }
 }
 
index 2ba6b704e334e905591787a44b523a68e236aa9e..ae8b9623fa3ecc28a8e461fc927adb9d67bf9818 100644 (file)
@@ -212,6 +212,9 @@ reset_groups(pw)
 {
 #if defined(HAVE_INITGROUPS) && defined(HAVE_GETGROUPS)
     if (pw != sudo_user.pw) {
+# ifdef HAVE_SETAUTHDB
+        aix_setauthdb(pw->pw_name);
+# endif
        (void) initgroups(pw->pw_name, pw->pw_gid);
        efree(user_groups);
        user_groups = NULL;
@@ -220,8 +223,11 @@ reset_groups(pw)
            if (getgroups(user_ngroups, user_groups) < 0)
                log_error(USE_ERRNO|MSG_ONLY, "can't get group vector");
        }
+# ifdef HAVE_SETAUTHDB
+        aix_restoreauthdb();
+# endif
     }
-#endif
+#endif /* HAVE_INITGROUPS && HAVE_GETGROUPS */
 }
 
 static int