From 7a36d70fc1bbc0652b9ebdd46940b5f75b20d342 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 25 Sep 2020 15:09:36 -0600 Subject: [PATCH] Add test for syntax error when defining an alias using a reserved word. --- MANIFEST | 2 ++ .../sudoers/regress/testsudoers/test13.out.ok | 22 ++++++++++++++++++ plugins/sudoers/regress/testsudoers/test13.sh | 23 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 plugins/sudoers/regress/testsudoers/test13.out.ok create mode 100755 plugins/sudoers/regress/testsudoers/test13.sh diff --git a/MANIFEST b/MANIFEST index 2cfcd80da..408bd622d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -829,6 +829,8 @@ 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/test13.out.ok +plugins/sudoers/regress/testsudoers/test13.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/test13.out.ok b/plugins/sudoers/regress/testsudoers/test13.out.ok new file mode 100644 index 000000000..fbc86ecaf --- /dev/null +++ b/plugins/sudoers/regress/testsudoers/test13.out.ok @@ -0,0 +1,22 @@ +Testing alias definitions using reserved words + +sudoers:1: syntax error, reserved word used as an alias name +Cmnd_Alias ALL=ALL + ^~~ +sudoers:2: syntax error, reserved word used as an alias name +Cmnd_Alias CHROOT=foo + ^~~~~~ +sudoers:3: syntax error, reserved word used as an alias name +User_Alias TIMEOUT=foo + ^~~~~~~ +sudoers:4: syntax error, reserved word used as an alias name +Runas_Alias CWD=bar + ^~~ +sudoers:5: syntax error, reserved word used as an alias name +Host_Alias NOTBEFORE=baz + ^~~~~~~~~ +sudoers:6: syntax error, reserved word used as an alias name +Host_Alias NOTAFTER=biff + ^~~~~~~~ + +root ALL = ALL diff --git a/plugins/sudoers/regress/testsudoers/test13.sh b/plugins/sudoers/regress/testsudoers/test13.sh new file mode 100755 index 000000000..f318d9e2c --- /dev/null +++ b/plugins/sudoers/regress/testsudoers/test13.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Test sudoers file with reserved words as alias names. +# 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 alias definitions using reserved words" +echo "" +./testsudoers -d <&1 +Cmnd_Alias ALL=ALL +Cmnd_Alias CHROOT=foo +User_Alias TIMEOUT=foo +Runas_Alias CWD=bar +Host_Alias NOTBEFORE=baz +Host_Alias NOTAFTER=biff + +root ALL = ALL +EOF + +exit 0