]> granicus.if.org Git - sudo/commitdiff
Better prefix determination now that we can't rely on len==0 to
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 15 Jun 2010 14:32:05 +0000 (10:32 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 15 Jun 2010 14:32:05 +0000 (10:32 -0400)
tell the beginning on an entry.

--HG--
branch : 1.7

ldap.c
parse.c

diff --git a/ldap.c b/ldap.c
index e99b75395c09735e0452b07076f7bc8a019ace92..7aa4f6851ecab0701ef8fdfb7edc68b4d1be9efa 100644 (file)
--- a/ldap.c
+++ b/ldap.c
@@ -1198,7 +1198,10 @@ sudo_ldap_display_defaults(nss, pw, lbuf)
        if (rc == LDAP_SUCCESS && (entry = ldap_first_entry(ld, result))) {
            bv = ldap_get_values_len(ld, entry, "sudoOption");
            if (bv != NULL) {
-               prefix = "    ";
+               if (lbuf->len == 0 || isspace((unsigned char)lbuf->buf[lbuf->len - 1]))
+                   prefix = "    ";
+               else
+                   prefix = ", ";
                for (p = bv; *p != NULL; p++) {
                    lbuf_append(lbuf, prefix, (*p)->bv_val, NULL);
                    prefix = ", ";
diff --git a/parse.c b/parse.c
index 63dedd479b34a5d551c40af8fa1eb009c835ffa4..48a25d89b36d4256cb3d7f0e35189bb8d8a87fb5 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -454,13 +454,17 @@ sudo_file_display_defaults(nss, pw, lbuf)
     struct lbuf *lbuf;
 {
     struct defaults *d;
-    char *prefix = NULL;
+    char *prefix;
     int nfound = 0;
 
     if (nss->handle == NULL)
        return(-1);
 
-    prefix = "    ";
+    if (lbuf->len == 0 || isspace((unsigned char)lbuf->buf[lbuf->len - 1]))
+       prefix = "    ";
+    else
+       prefix = ", ";
+
     tq_foreach_fwd(&defaults, d) {
        switch (d->type) {
            case DEFAULTS_HOST: