]> granicus.if.org Git - sudo/commitdiff
If there are no privs to print, write the message to the lbuf instead
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 4 Jun 2012 13:19:56 +0000 (09:19 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 4 Jun 2012 13:19:56 +0000 (09:19 -0400)
of printing it directly.

--HG--
branch : 1.7

sudo_nss.c

index 9ee73b07982488204a18daf0c9a7c11e4f8dc6a5..36cdf6503ca7b1d49a5b3bfec9bfefc77b88142c 100644 (file)
@@ -288,13 +288,14 @@ display_privs(snl, pw)
     tq_foreach_fwd(snl, nss) {
        count += nss->display_privs(nss, pw, &privs);
     }
-    if (count) {
-       lbuf_print(&defs);
-       lbuf_print(&privs);
-    } else {
-       printf("User %s is not allowed to run sudo on %s.\n", pw->pw_name,
-           user_shost);
+    if (count == 0) {
+       defs.len = 0;
+       privs.len = 0;
+       lbuf_append(&privs, "User %s is not allowed to run sudo on %s.\n",
+           pw->pw_name, user_shost);
     }
+    lbuf_print(&defs);
+    lbuf_print(&privs);
 
     lbuf_destroy(&defs);
     lbuf_destroy(&privs);