2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 22:35:10 +00:00

Don't pollute the namespace with lbuf struct and functions

This commit is contained in:
Todd C. Miller
2014-06-26 15:51:15 -06:00
parent 6bdee0488c
commit 7bafa63c15
17 changed files with 278 additions and 275 deletions

View File

@@ -42,7 +42,7 @@
#include <ctype.h>
#include "sudoers.h"
#include "lbuf.h"
#include "sudo_lbuf.h"
extern struct sudo_nss sudo_nss_file;
#ifdef HAVE_LDAP
@@ -270,7 +270,7 @@ void
display_privs(struct sudo_nss_list *snl, struct passwd *pw)
{
struct sudo_nss *nss;
struct lbuf defs, privs;
struct sudo_lbuf defs, privs;
struct stat sb;
int cols, count, olen;
debug_decl(display_privs, SUDO_DEBUG_NSS)
@@ -278,36 +278,36 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
cols = sudo_user.cols;
if (fstat(STDOUT_FILENO, &sb) == 0 && S_ISFIFO(sb.st_mode))
cols = 0;
lbuf_init(&defs, output, 4, NULL, cols);
lbuf_init(&privs, output, 8, NULL, cols);
sudo_lbuf_init(&defs, output, 4, NULL, cols);
sudo_lbuf_init(&privs, output, 8, NULL, cols);
/* Display defaults from all sources. */
lbuf_append(&defs, _("Matching Defaults entries for %s on %s:\n"),
sudo_lbuf_append(&defs, _("Matching Defaults entries for %s on %s:\n"),
pw->pw_name, user_srunhost);
count = 0;
TAILQ_FOREACH(nss, snl, entries) {
count += nss->display_defaults(nss, pw, &defs);
}
if (count)
lbuf_append(&defs, "\n\n");
sudo_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 %s:\n"),
sudo_lbuf_append(&defs, _("Runas and Command-specific defaults for %s:\n"),
pw->pw_name);
count = 0;
TAILQ_FOREACH(nss, snl, entries) {
count += nss->display_bound_defaults(nss, pw, &defs);
}
if (count)
lbuf_append(&defs, "\n\n");
sudo_lbuf_append(&defs, "\n\n");
else
defs.len = olen;
/* Display privileges from all sources. */
lbuf_append(&privs,
sudo_lbuf_append(&privs,
_("User %s may run the following commands on %s:\n"),
pw->pw_name, user_srunhost);
count = 0;
@@ -317,14 +317,14 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
if (count == 0) {
defs.len = 0;
privs.len = 0;
lbuf_append(&privs, _("User %s is not allowed to run sudo on %s.\n"),
sudo_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);
sudo_lbuf_print(&defs);
sudo_lbuf_print(&privs);
lbuf_destroy(&defs);
lbuf_destroy(&privs);
sudo_lbuf_destroy(&defs);
sudo_lbuf_destroy(&privs);
debug_return;
}