From c9b70940cf82cf7a547458966e5c47dd9c9cd679 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 3 Mar 2018 07:42:10 -0700 Subject: [PATCH] When formatting as sudoers, flush the lbuf after each userspec. --- plugins/sudoers/cvtsudoers.c | 2 +- plugins/sudoers/fmtsudoers.c | 3 ++- plugins/sudoers/parse.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/sudoers/cvtsudoers.c b/plugins/sudoers/cvtsudoers.c index 7e0f82c79..2f44df15d 100644 --- a/plugins/sudoers/cvtsudoers.c +++ b/plugins/sudoers/cvtsudoers.c @@ -583,7 +583,7 @@ convert_sudoers_sudoers(const char *output_file, struct cvtsudoers_config *conf) } /* Print User_Specs */ - if (!sudoers_format_userspecs(&lbuf, &userspecs, conf->expand_aliases)) + if (!sudoers_format_userspecs(&lbuf, &userspecs, conf->expand_aliases, true)) goto done; if (lbuf.len > 1) { sudo_lbuf_print(&lbuf); diff --git a/plugins/sudoers/fmtsudoers.c b/plugins/sudoers/fmtsudoers.c index 01da53567..edbcdc64a 100644 --- a/plugins/sudoers/fmtsudoers.c +++ b/plugins/sudoers/fmtsudoers.c @@ -285,7 +285,7 @@ sudoers_format_userspec(struct sudo_lbuf *lbuf, struct userspec *us, */ bool sudoers_format_userspecs(struct sudo_lbuf *lbuf, struct userspec_list *usl, - bool expand_aliases) + bool expand_aliases, bool flush) { struct userspec *us; debug_decl(sudoers_format_userspecs, SUDOERS_DEBUG_UTIL) @@ -293,6 +293,7 @@ sudoers_format_userspecs(struct sudo_lbuf *lbuf, struct userspec_list *usl, TAILQ_FOREACH(us, usl, entries) { if (!sudoers_format_userspec(lbuf, us, expand_aliases)) break; + sudo_lbuf_print(lbuf); } debug_return_bool(!sudo_lbuf_error(lbuf)); diff --git a/plugins/sudoers/parse.h b/plugins/sudoers/parse.h index e903adba5..6a459de26 100644 --- a/plugins/sudoers/parse.h +++ b/plugins/sudoers/parse.h @@ -315,6 +315,6 @@ bool sudoers_format_default(struct sudo_lbuf *lbuf, struct defaults *d); bool sudoers_format_member(struct sudo_lbuf *lbuf, struct member *m, const char *separator, int alias_type); bool sudoers_format_privilege(struct sudo_lbuf *lbuf, struct privilege *priv, bool expand_aliases); bool sudoers_format_userspec(struct sudo_lbuf *lbuf, struct userspec *us, bool expand_aliases); -bool sudoers_format_userspecs(struct sudo_lbuf *lbuf, struct userspec_list *usl, bool expand_aliases); +bool sudoers_format_userspecs(struct sudo_lbuf *lbuf, struct userspec_list *usl, bool expand_aliases, bool flush); #endif /* SUDOERS_PARSE_H */ -- 2.40.0