Imported Upstream version 1.8.2
[debian/sudo] / plugins / sudoers / sudo_nss.c
index 2f77d894741354ad924d693b31df78832494bab1..de0d5a6bb4ce59673cbbc76abbf694dcf4797369 100644 (file)
@@ -204,31 +204,6 @@ sudo_read_nss(void)
 
 #endif /* HAVE_LDAP && _PATH_NSSWITCH_CONF */
 
-/* Reset user_groups based on passwd entry. */
-static void
-reset_groups(struct passwd *pw)
-{
-#if defined(HAVE_INITGROUPS) && defined(HAVE_GETGROUPS)
-    if (pw != sudo_user.pw) {
-# ifdef HAVE_SETAUTHDB
-       aix_setauthdb(pw->pw_name);
-# endif
-       if (initgroups(pw->pw_name, pw->pw_gid) == -1)
-           log_error(USE_ERRNO|MSG_ONLY, "can't reset group vector");
-       efree(user_groups);
-       user_groups = NULL;
-       if ((user_ngroups = getgroups(0, NULL)) > 0) {
-           user_groups = emalloc2(user_ngroups, sizeof(GETGROUPS_T));
-           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
-}
-
 static int
 output(const char *buf)
 {
@@ -256,40 +231,38 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
     struct lbuf defs, privs;
     int count, olen;
 
-    /* Reset group vector so group matching works correctly. */
-    reset_groups(pw);
-
     lbuf_init(&defs, output, 4, NULL, sudo_user.cols);
     lbuf_init(&privs, output, 4, NULL, sudo_user.cols);
 
     /* Display defaults from all sources. */
-    lbuf_append(&defs, "Matching Defaults entries for ", pw->pw_name,
-       " on this host:\n", NULL);
+    lbuf_append(&defs, _("Matching Defaults entries for %s on this host:\n"),
+       pw->pw_name);
     count = 0;
     tq_foreach_fwd(snl, nss) {
        count += nss->display_defaults(nss, pw, &defs);
     }
     if (count)
-       lbuf_append(&defs, "\n\n", NULL);
+       lbuf_append(&defs, "\n\n");
     else
        defs.len = 0;
 
     /* Display Runas and Cmnd-specific defaults from all sources. */
     olen = defs.len;
-    lbuf_append(&defs, "Runas and Command-specific defaults for ", pw->pw_name,
-       ":\n", NULL);
+    lbuf_append(&defs, _("Runas and Command-specific defaults for %s:\n"),
+       pw->pw_name);
     count = 0;
     tq_foreach_fwd(snl, nss) {
        count += nss->display_bound_defaults(nss, pw, &defs);
     }
     if (count)
-       lbuf_append(&defs, "\n\n", NULL);
+       lbuf_append(&defs, "\n\n");
     else
        defs.len = olen;
 
     /* Display privileges from all sources. */
-    lbuf_append(&privs, "User ", pw->pw_name,
-       " may run the following commands on this host:\n", NULL);
+    lbuf_append(&privs,
+       _("User %s may run the following commands on this host:\n"),
+       pw->pw_name);
     count = 0;
     tq_foreach_fwd(snl, nss) {
        count += nss->display_privs(nss, pw, &privs);
@@ -298,7 +271,7 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
        lbuf_print(&defs);
        lbuf_print(&privs);
     } else {
-       printf("User %s is not allowed to run sudo on %s.\n", pw->pw_name,
+       printf(_("User %s is not allowed to run sudo on %s.\n"), pw->pw_name,
            user_shost);
     }
 
@@ -316,9 +289,6 @@ display_cmnd(struct sudo_nss_list *snl, struct passwd *pw)
 {
     struct sudo_nss *nss;
 
-    /* Reset group vector so group matching works correctly. */
-    reset_groups(pw);
-
     tq_foreach_fwd(snl, nss) {
        if (nss->display_cmnd(nss, pw) == 0)
            return TRUE;