From 8ca8f240018934c823c98cd023364c1ac3644cef Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 26 Dec 2009 17:25:49 +0000 Subject: [PATCH] Print a newline between Runas and Command-specific defaults in sudo -l. --- lbuf.c | 8 ++++++-- parse.c | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lbuf.c b/lbuf.c index 874d4eaef..88f66e056 100644 --- a/lbuf.c +++ b/lbuf.c @@ -245,10 +245,14 @@ lbuf_print(lbuf) cp = lbuf->buf; have = cols; while (cp != NULL && *cp != '\0') { - char *ep = NULL; + char *ep; int need = lbuf->len - (int)(cp - lbuf->buf); - if (need > have) { + ep = memrchr(cp, '\n', need > have ? have : need); + if (ep) { + need = ep - cp; + ep++; /* skip over newline */ + } else if (need > have) { have -= contlen; /* subtract for continuation char */ if ((ep = memrchr(cp, ' ', have)) == NULL) ep = memchr(cp + have, ' ', need - have); diff --git a/parse.c b/parse.c index d4739b0db..fea04dc2d 100644 --- a/parse.c +++ b/parse.c @@ -560,6 +560,8 @@ display_bound_defaults(dtype, lbuf) nfound++; if (binding != tq_first(&d->binding)) { binding = tq_first(&d->binding); + if (nfound != 1) + lbuf_append(lbuf, "\n", NULL); lbuf_append(lbuf, " Defaults", dsep, NULL); for (m = binding; m != NULL; m = m->next) { if (m != binding)