2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

Pass in output function to lbuf_init() instead of writing to stdout.

A side effect is that the usage info can now go to stderr as it should.
This commit is contained in:
Todd C. Miller
2010-03-18 06:42:17 -04:00
parent 038ec569de
commit b4f4afdf69
8 changed files with 50 additions and 23 deletions

View File

@@ -224,10 +224,27 @@ reset_groups(pw)
#endif
}
static int
output(const char *buf)
{
struct sudo_conv_message msg;
struct sudo_conv_reply repl;
/* Call conversation function */
memset(&msg, 0, sizeof(msg));
msg.msg_type = SUDO_CONV_INFO_MSG;
msg.msg = buf;
memset(&repl, 0, sizeof(repl));
if (sudo_conv(1, &msg, &repl) == -1)
return 0;
return (int)strlen(buf);
}
/*
* Print out privileges for the specified user.
* We only get here if the user is allowed to run something on this host.
*/
/* XXX - conversation function or newlines in lbuf */
void
display_privs(snl, pw)
struct sudo_nss_list *snl;
@@ -240,7 +257,7 @@ display_privs(snl, pw)
/* Reset group vector so group matching works correctly. */
reset_groups(pw);
lbuf_init(&lbuf, NULL, 4, 0, sudo_user.cols);
lbuf_init(&lbuf, output, 4, NULL, sudo_user.cols);
/* Display defaults from all sources. */
count = 0;