2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-30 05:48:18 +00:00

Avoid printing empty "Runas and Command-specific defaults for user"

line.
This commit is contained in:
Todd C. Miller 2011-02-14 11:29:20 -05:00
parent 151af93022
commit c3d795ff95

View File

@ -254,7 +254,7 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
{ {
struct sudo_nss *nss; struct sudo_nss *nss;
struct lbuf defs, privs; struct lbuf defs, privs;
int count; int count, olen;
/* Reset group vector so group matching works correctly. */ /* Reset group vector so group matching works correctly. */
reset_groups(pw); reset_groups(pw);
@ -275,6 +275,7 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
defs.len = 0; defs.len = 0;
/* Display Runas and Cmnd-specific defaults from all sources. */ /* Display Runas and Cmnd-specific defaults from all sources. */
olen = defs.len;
lbuf_append(&defs, "Runas and Command-specific defaults for ", pw->pw_name, lbuf_append(&defs, "Runas and Command-specific defaults for ", pw->pw_name,
":\n", NULL); ":\n", NULL);
count = 0; count = 0;
@ -283,6 +284,8 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
} }
if (count) if (count)
lbuf_append(&defs, "\n\n", NULL); lbuf_append(&defs, "\n\n", NULL);
else
defs.len = olen;
/* Display privileges from all sources. */ /* Display privileges from all sources. */
lbuf_append(&privs, "User ", pw->pw_name, lbuf_append(&privs, "User ", pw->pw_name,