Add tests for entries without a newline.

This commit is contained in:
Todd C. Miller
2020-09-27 10:31:14 -06:00
parent 9bb91cb64b
commit 32db528689
5 changed files with 84 additions and 0 deletions

View File

@@ -831,6 +831,10 @@ 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/test14.out.ok
plugins/sudoers/regress/testsudoers/test14.sh
plugins/sudoers/regress/testsudoers/test15.out.ok
plugins/sudoers/regress/testsudoers/test15.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,18 @@
Testing user privilege without a newline
Parses OK
millert ALL = ALL
Testing alias without a newline
Parses OK
Cmnd_Alias FOO = /bin/bar
Testing Defaults without a newline
Parses OK
Defaults log_output

View File

@@ -0,0 +1,23 @@
#!/bin/sh
#
# Test entries with no trailing newline.
#
exec 2>&1
echo ""
echo "Testing user privilege without a newline"
echo ""
printf "millert ALL = ALL" | ./testsudoers -d
echo ""
echo "Testing alias without a newline"
echo ""
printf "Cmnd_Alias FOO=/bin/bar" | ./testsudoers -d
echo ""
echo "Testing Defaults without a newline"
echo ""
printf "Defaults log_output" | ./testsudoers -d
exit 0

View File

@@ -0,0 +1,17 @@
Testing @include of a file with a missing newline
Parses OK
Entries for user root:
ALL = /usr/bin/id
host matched
runas matched
cmnd unmatched
ALL = ALL
host matched
runas matched
cmnd allowed
Command allowed

View File

@@ -0,0 +1,22 @@
#!/bin/sh
#
# Test @include of a file with a missing newline
#
# Create test file
TESTDIR="`pwd`/regress/testsudoers"
printf "root ALL = ALL" >"$TESTDIR/test15.inc"
MYUID=`\ls -lnd "$TESTDIR/test15.inc" | awk '{print $3}'`
MYGID=`\ls -lnd "$TESTDIR/test15.inc" | awk '{print $4}'`
exec 2>&1
echo "Testing @include of a file with a missing newline"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
@include $TESTDIR/test15.inc
ALL ALL = /usr/bin/id
EOF
rm -f "$TESTDIR/test15.inc"
exit 0