From: Todd C. Miller Date: Mon, 4 Jun 2012 13:19:56 +0000 (-0400) Subject: If there are no privs to print, write the message to the lbuf instead X-Git-Tag: SUDO_1_7_10~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e694c29c4e0943ab19cd5a1bdafd5290d831c21;p=sudo If there are no privs to print, write the message to the lbuf instead of printing it directly. --HG-- branch : 1.7 --- diff --git a/sudo_nss.c b/sudo_nss.c index 9ee73b079..36cdf6503 100644 --- a/sudo_nss.c +++ b/sudo_nss.c @@ -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);