- printf("User %s may run the following commands on this host:\n",
- pw->pw_name);
- tq_foreach_fwd(snl, nss)
- (void) nss->display_privs(nss, pw, &lbuf);
- if (lbuf.len != 0)
- lbuf_print(&lbuf); /* print remainder, if any */
- lbuf_destroy(&lbuf);
+ lbuf_append(&privs, "User ", pw->pw_name,
+ " may run the following commands on this host:\n", NULL);
+ count = 0;
+ 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);
+ }
+
+ lbuf_destroy(&defs);
+ lbuf_destroy(&privs);