]> granicus.if.org Git - sudo/commitdiff
When printing a member name, quote sudoers special characters unless
authorTodd C. Miller <Todd.Miller@sudo.ws>
Fri, 2 Feb 2018 21:29:17 +0000 (14:29 -0700)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Fri, 2 Feb 2018 21:29:17 +0000 (14:29 -0700)
it is a UID/GID, in which case we print the '#' unquoted.

plugins/sudoers/parse.c

index e1bbbea86f46b08008169294e0ccd45eeb9bc335..084d2f36d204eeebcf827170f144d00dfc5e922d 100644 (file)
@@ -883,7 +883,14 @@ print_member_int(struct sudo_lbuf *lbuf, char *name, int type, int negated,
            }
            /* FALLTHROUGH */
        default:
-           sudo_lbuf_append(lbuf, "%s%s", negated ? "!" : "", name);
+           /* Do not quote UID/GID, all others get quoted. */
+           if (name[0] == '#' &&
+               name[strspn(name + 1, "0123456789") + 1] == '\0') {
+               sudo_lbuf_append(lbuf, "%s%s", negated ? "!" : "", name);
+           } else {
+               sudo_lbuf_append_quoted(lbuf, SUDOERS_QUOTED, "%s%s",
+                   negated ? "!" : "", name);
+           }
            break;
     }
     debug_return;