From a51d194a73e57aff1c0d8cd35cbc77b660374b72 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 2 Sep 2020 12:40:39 -0600 Subject: [PATCH] Add test of multiple syntax errors. Where possible, the portion of the line before the error should be still be interpreted. --- MANIFEST | 2 ++ .../sudoers/regress/testsudoers/test12.out.ok | 15 +++++++++++++++ plugins/sudoers/regress/testsudoers/test12.sh | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 plugins/sudoers/regress/testsudoers/test12.out.ok create mode 100755 plugins/sudoers/regress/testsudoers/test12.sh diff --git a/MANIFEST b/MANIFEST index 9a32a6e9b..4bea0a5f4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -827,6 +827,8 @@ plugins/sudoers/regress/testsudoers/test10.out.ok plugins/sudoers/regress/testsudoers/test10.sh plugins/sudoers/regress/testsudoers/test11.out.ok plugins/sudoers/regress/testsudoers/test11.sh +plugins/sudoers/regress/testsudoers/test12.out.ok +plugins/sudoers/regress/testsudoers/test12.sh plugins/sudoers/regress/testsudoers/test2.inc plugins/sudoers/regress/testsudoers/test2.out.ok plugins/sudoers/regress/testsudoers/test2.sh diff --git a/plugins/sudoers/regress/testsudoers/test12.out.ok b/plugins/sudoers/regress/testsudoers/test12.out.ok new file mode 100644 index 000000000..5dd75fb19 --- /dev/null +++ b/plugins/sudoers/regress/testsudoers/test12.out.ok @@ -0,0 +1,15 @@ +Testing sudoers with multiple syntax errors + +sudoers:1: syntax error +User_Alias A1 = u1 u2 : A2 = u3, u4 + ^~ +sudoers:3: syntax error +millert ALL = /fail : foo + ^ +sudoers:5: syntax error +root ALL = ALL bar + ^~~ + +User_Alias A1 = u1 + +millert ALL = /fail diff --git a/plugins/sudoers/regress/testsudoers/test12.sh b/plugins/sudoers/regress/testsudoers/test12.sh new file mode 100755 index 000000000..0a1510c5c --- /dev/null +++ b/plugins/sudoers/regress/testsudoers/test12.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# +# Test sudoers file with multiple syntax errors +# The standard error output is dup'd to the standard output. +# + +# Avoid warnings about memory leaks when there is a syntax error +ASAN_OPTIONS=detect_leaks=0; export ASAN_OPTIONS + +echo "Testing sudoers with multiple syntax errors" +echo "" +./testsudoers -d <&1 | sed 's/\(syntax error\), .*/\1/' +User_Alias A1 = u1 u2 : A2 = u3, u4 + +millert ALL = /fail : foo + +root ALL = ALL bar +EOF