* 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);
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)
*/
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 */
}
}
{
#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;
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