2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

Add test for syntax error when defining an alias using a reserved word.

This commit is contained in:
Todd C. Miller 2020-09-25 15:09:36 -06:00
parent e826705b62
commit 7a36d70fc1
3 changed files with 47 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <<EOF 2>&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