Pass path to testsudoers, visudo or cvtsudoers in the environment.

Falls back on the unqualified command if the environment variable
is not set.
This commit is contained in:
Todd C. Miller
2020-10-10 07:07:37 -06:00
parent 807857a2ca
commit b0a6e1c1e7
59 changed files with 194 additions and 77 deletions

View File

@@ -574,7 +574,8 @@ check: $(TEST_PROGS) visudo testsudoers cvtsudoers
out="regress/$$dir/$${base}.out"; \
err="regress/$$dir/$${base}.err"; \
status=0; \
TESTDIR=$(srcdir)/regress/$$dir \
TESTSUDOERS=./testsudoers VISUDO=./visudo \
CVTSUDOERS=./cvtsudoers TESTDIR=$(srcdir)/regress/$$dir \
$(SHELL) $$t >$$out 2>$$err || status=$$?; \
if cmp $$out $(srcdir)/$$out.ok >/dev/null; then \
if test $$status -ne 0; then \

View File

@@ -3,6 +3,8 @@
# Test user and host filters
#
./cvtsudoers -c "" -f sudoers -m user=millert,host=hercules $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -m user=millert,host=hercules $TESTDIR/sudoers
exit 0

View File

@@ -3,6 +3,8 @@
# Test command defaults filtering
#
./cvtsudoers -c "" -f sudoers -s aliases,privileges -d command $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -s aliases,privileges -d command $TESTDIR/sudoers
exit 0

View File

@@ -3,4 +3,6 @@
# Test that Aliases are removed when filtering by defaults type
#
./cvtsudoers -c "" -f sudoers -d command $TESTDIR/sudoers.defs
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -d command $TESTDIR/sudoers.defs

View File

@@ -3,4 +3,6 @@
# Test that Aliases are removed when filtering by defaults type
#
./cvtsudoers -c "" -f sudoers -d user $TESTDIR/sudoers.defs
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -d user $TESTDIR/sudoers.defs

View File

@@ -3,4 +3,6 @@
# Test that Aliases are removed when filtering by defaults type
#
./cvtsudoers -c "" -f sudoers -d host $TESTDIR/sudoers.defs
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -d host $TESTDIR/sudoers.defs

View File

@@ -3,4 +3,6 @@
# Test that Aliases are removed when filtering by defaults type
#
./cvtsudoers -c "" -f sudoers -d runas $TESTDIR/sudoers.defs
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -d runas $TESTDIR/sudoers.defs

View File

@@ -3,6 +3,8 @@
# Test filters and pruning
#
./cvtsudoers -c "" -f sudoers -p -m user=user1 <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -p -m user=user1 <<EOF
user1, user2, user3, %group1 host1, host2, host3 = ALL
EOF

View File

@@ -3,6 +3,8 @@
# Test filters and pruning
#
./cvtsudoers -c "" -f sudoers -p -m user=user2,host=host2 <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -p -m user=user2,host=host2 <<EOF
user1, user2, user3, %group1 host1, host2, host3 = ALL
EOF

View File

@@ -3,6 +3,8 @@
# Test filters and pruning
#
./cvtsudoers -c "" -f sudoers -p -m group=group1,host=host1 <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -p -m group=group1,host=host1 <<EOF
user1, user2, user3, %group1 host1, host2, host3 = ALL
EOF

View File

@@ -3,6 +3,8 @@
# Test filters and pruning
#
./cvtsudoers -c "" -f sudoers -p -m group=group1,host=somehost <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -p -m group=group1,host=somehost <<EOF
user1, user2, user3, %group1 ALL = ALL
EOF

View File

@@ -3,4 +3,6 @@
# Test filters and pruning; alias contents don't get pruned
#
./cvtsudoers -c "" -f sudoers -p -m user=FULLTIMERS,host=SERVERS $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -p -m user=FULLTIMERS,host=SERVERS $TESTDIR/sudoers

View File

@@ -3,6 +3,8 @@
# Test user and host filters, expanding aliases
#
./cvtsudoers -c "" -f sudoers -e -m user=millert,host=hercules $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -e -m user=millert,host=hercules $TESTDIR/sudoers
exit 0

View File

@@ -3,7 +3,9 @@
# Test cvtsudoers.conf
#
./cvtsudoers -c $TESTDIR/test20.conf <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c $TESTDIR/test20.conf <<EOF
Defaults:SOMEUSERS authenticate, timestamp_timeout=0
User_Alias SOMEUSERS = user1, user2, user3

View File

@@ -3,7 +3,9 @@
# Test cvtsudoers.conf
#
./cvtsudoers -c $TESTDIR/test21.conf <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c $TESTDIR/test21.conf <<EOF
Defaults authenticate, timestamp_timeout=0
User_Alias FULLTIMERS = user1, user2, user3

View File

@@ -3,7 +3,9 @@
# Test LDAP base filtering.
#
./cvtsudoers -c "" -i ldif -b "ou=SUDOers,dc=sudo,dc=ws" -I 10 -O 10 <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -i ldif -b "ou=SUDOers,dc=sudo,dc=ws" -I 10 -O 10 <<EOF
dn: dc=sudo,dc=ws
objectClass: dcObject
objectClass: organization

View File

@@ -3,5 +3,7 @@
# Test round-tripping of sudoers -> LDIF -> sudoers
#
./cvtsudoers -c "" -b "ou=SUDOers,dc=sudo,dc=ws" $TESTDIR/test23.out.ok | \
./cvtsudoers -c "" -i LDIF -f sudoers | grep -v '^#'
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -b "ou=SUDOers,dc=sudo,dc=ws" $TESTDIR/test23.out.ok | \
$CVTSUDOERS -c "" -i LDIF -f sudoers | grep -v '^#'

View File

@@ -3,5 +3,7 @@
# Test round-tripping of LDIF -> sudoers -> LDIF
#
./cvtsudoers -c "" -i LDIF -f sudoers $TESTDIR/test24.out.ok | \
./cvtsudoers -c "" -b "ou=SUDOers,dc=sudo,dc=ws"
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -i LDIF -f sudoers $TESTDIR/test24.out.ok | \
$CVTSUDOERS -c "" -b "ou=SUDOers,dc=sudo,dc=ws"

View File

@@ -3,7 +3,9 @@
# Test LDIF base64 attribute parsing
#
./cvtsudoers -c "" -i ldif -b "ou=SUDOers,dc=sudo,dc=ws" -I 10 -O 10 <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -i ldif -b "ou=SUDOers,dc=sudo,dc=ws" -I 10 -O 10 <<EOF
# defaults, SUDOers, sudo.ws
dn:: Y249ZGVmYXVsdHMsb3U9U1VET2VycyxkYz1zdWRvLGRjPXdz
objectClass: top

View File

@@ -3,7 +3,9 @@
# Test LDIF invalid base64 attribute parsing
#
./cvtsudoers -c "" -i ldif -b "ou=SUDOers,dc=sudo,dc=ws" -I 10 -O 10 <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -i ldif -b "ou=SUDOers,dc=sudo,dc=ws" -I 10 -O 10 <<EOF
# defaults, SUDOers, sudo.ws
dn:: Y249ZGVmYXVsdHMsb3U9U1VET2VycyxkYz1zdWRvLGRjPXdz
objectClass: top

View File

@@ -3,7 +3,9 @@
# Test base64 encoding of non-safe strings
#
./cvtsudoers -c "" -b "ou=SUDOers©,dc=sudo,dc=ws" <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -b "ou=SUDOers©,dc=sudo,dc=ws" <<EOF
Defaults badpass_message="Bad password¡"
root ALL = ALL

View File

@@ -3,7 +3,9 @@
# Test LDAP sudoOrder when converting to sudoers.
#
./cvtsudoers -c "" -i ldif -f sudoers <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -i ldif -f sudoers <<EOF
dn: dc=sudo,dc=ws
objectClass: dcObject
objectClass: organization

View File

@@ -3,7 +3,9 @@
# Test LDAP sudoOrder when converting to sudoers.
#
./cvtsudoers -c "" -i ldif -f sudoers <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -i ldif -f sudoers <<EOF
dn: dc=sudo,dc=ws
objectClass: dcObject
objectClass: organization

View File

@@ -3,6 +3,8 @@
# Test group and host filters
#
./cvtsudoers -c "" -f sudoers -m group=wheel,host=blackhole $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -m group=wheel,host=blackhole $TESTDIR/sudoers
exit 0

View File

@@ -4,7 +4,9 @@
# See https://bugzilla.sudo.ws/show_bug.cgi?id=853
#
./cvtsudoers -c "" -e -f json <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -e -f json <<EOF
Cmnd_Alias CMDA=/path/to/cmda
Cmnd_Alias CMDB=/path/to/cmdb
Cmnd_Alias CMDC=/path/to/cmdc

View File

@@ -3,7 +3,9 @@
# Test cvtsudoers.conf with padding
#
./cvtsudoers -c $TESTDIR/test31.conf <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c $TESTDIR/test31.conf <<EOF
Defaults authenticate, timestamp_timeout=0
User_Alias FULLTIMERS = user1, user2, user3

View File

@@ -3,7 +3,9 @@
# Test cvtsudoers.conf with invalid padding
#
./cvtsudoers -c "" -b "ou=SUDOers,dc=my-domain,dc=com" -O 1000 -P 1 <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -b "ou=SUDOers,dc=my-domain,dc=com" -O 1000 -P 1 <<EOF
user0 ALL = (ALL:ALL) ALL
user1 ALL = (ALL:ALL) ALL
user2 ALL = (ALL:ALL) ALL

View File

@@ -3,7 +3,9 @@
# Test LDAP negated sudoRunAsUser and sudoRunAsGroup converted to sudoers.
#
./cvtsudoers -c "" -i ldif -f sudoers <<EOF
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -i ldif -f sudoers <<EOF
dn: dc=sudo,dc=ws
objectClass: dcObject
objectClass: organization

View File

@@ -3,6 +3,8 @@
# Test group and host filters, expanding aliases
#
./cvtsudoers -c "" -f sudoers -e -m group=wheel,host=blackhole $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -e -m group=wheel,host=blackhole $TESTDIR/sudoers
exit 0

View File

@@ -3,6 +3,8 @@
# Test defaults type filtering
#
./cvtsudoers -c "" -f sudoers -s aliases,privileges -d all $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -s aliases,privileges -d all $TESTDIR/sudoers
exit 0

View File

@@ -3,6 +3,8 @@
# Test global defaults filtering
#
./cvtsudoers -c "" -f sudoers -s aliases,privileges -d global $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -s aliases,privileges -d global $TESTDIR/sudoers
exit 0

View File

@@ -3,6 +3,8 @@
# Test user defaults filtering
#
./cvtsudoers -c "" -f sudoers -s aliases,privileges -d user $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -s aliases,privileges -d user $TESTDIR/sudoers
exit 0

View File

@@ -3,6 +3,8 @@
# Test runas defaults filtering
#
./cvtsudoers -c "" -f sudoers -s aliases,privileges -d runas $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -s aliases,privileges -d runas $TESTDIR/sudoers
exit 0

View File

@@ -3,6 +3,8 @@
# Test host defaults filtering
#
./cvtsudoers -c "" -f sudoers -s aliases,privileges -d host $TESTDIR/sudoers
: ${CVTSUDOERS=cvtsudoers}
$CVTSUDOERS -c "" -f sudoers -s aliases,privileges -d host $TESTDIR/sudoers
exit 0

View File

@@ -5,8 +5,10 @@
# This is RedHat bug Bug 667103.
#
: ${TESTSUDOERS=testsudoers}
exec 2>&1
./testsudoers -g bin -P ${TESTDIR}/group root id <<EOF
$TESTSUDOERS -g bin -P ${TESTDIR}/group root id <<EOF
root ALL = ALL
EOF

View File

@@ -3,6 +3,8 @@
# Test @include of a file with embedded white space
#
: ${TESTSUDOERS=testsudoers}
# Create test file
TESTDIR="`pwd`/regress/testsudoers"
cat >"$TESTDIR/test 10.inc" <<EOF
@@ -15,28 +17,28 @@ exec 2>&1
echo "Testing @include of a path with escaped white space"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<-EOF
@include $TESTDIR/test\ 10.inc
EOF
echo ""
echo "Testing @include of a double-quoted path with white space"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<-EOF
@include "$TESTDIR/test 10.inc"
EOF
echo ""
echo "Testing #include of a path with escaped white space"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<-EOF
#include $TESTDIR/test\ 10.inc
EOF
echo ""
echo "Testing #include of a double-quoted path with white space"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<-EOF
#include "$TESTDIR/test 10.inc"
EOF

View File

@@ -4,6 +4,8 @@
# The standard error output is dup'd to the standard output.
#
: ${TESTSUDOERS=testsudoers}
# Avoid warnings about memory leaks when there is a syntax error
ASAN_OPTIONS=detect_leaks=0; export ASAN_OPTIONS
@@ -12,14 +14,14 @@ MYGID=`\ls -ln $TESTDIR/test2.inc | awk '{print $4}'`
echo "Testing @include with garbage after the path name"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<EOF 2>&1 | sed 's/\(syntax error\), .*/\1/'
$TESTSUDOERS -U $MYUID -G $MYGID root id <<EOF 2>&1 | sed 's/\(syntax error\), .*/\1/'
@include sudoers.local womp womp
EOF
echo ""
echo "Testing #include with garbage after the path name"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<EOF 2>&1 | sed 's/\(syntax error\), .*/\1/'
$TESTSUDOERS -U $MYUID -G $MYGID root id <<EOF 2>&1 | sed 's/\(syntax error\), .*/\1/'
#include sudoers.local womp womp
EOF

View File

@@ -4,12 +4,14 @@
# The standard error output is dup'd to the standard output.
#
: ${TESTSUDOERS=testsudoers}
# 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 <<EOF 2>&1 | sed 's/\(syntax error\), .*/\1/'
$TESTSUDOERS -d <<EOF 2>&1 | sed 's/\(syntax error\), .*/\1/'
User_Alias A1 = u1 u2 : A2 = u3, u4
millert ALL = /fail : foo

View File

@@ -4,12 +4,14 @@
# The standard error output is dup'd to the standard output.
#
: ${TESTSUDOERS=testsudoers}
# 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
$TESTSUDOERS -d <<EOF 2>&1
Cmnd_Alias ALL=ALL
Cmnd_Alias CHROOT=foo
User_Alias TIMEOUT=foo

View File

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

View File

@@ -3,6 +3,8 @@
# Test @include of a file with a missing newline
#
: ${TESTSUDOERS=testsudoers}
# Create test file
TESTDIR="`pwd`/regress/testsudoers"
printf "root ALL = ALL" >"$TESTDIR/test15.inc"
@@ -13,7 +15,7 @@ exec 2>&1
echo "Testing @include of a file with a missing newline"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<-EOF
@include $TESTDIR/test15.inc
ALL ALL = /usr/bin/id
EOF

View File

@@ -3,20 +3,22 @@
# Test @include facility
#
: ${TESTSUDOERS=testsudoers}
MYUID=`\ls -ln $TESTDIR/test2.inc | awk '{print $3}'`
MYGID=`\ls -ln $TESTDIR/test2.inc | awk '{print $4}'`
exec 2>&1
echo "Testing @include"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<EOF
@include $TESTDIR/test2.inc
EOF
echo ""
echo "Testing #include"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<EOF
#include $TESTDIR/test2.inc
EOF

View File

@@ -3,6 +3,8 @@
# Test @includedir facility
#
: ${TESTSUDOERS=testsudoers}
TESTDIR="`pwd`/regress/testsudoers"
# make sure include file is owned by current user
rm -rf "$TESTDIR/test3.d"
@@ -17,28 +19,28 @@ exec 2>&1
echo "Testing @includedir of an unquoted path"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<-EOF
@includedir $TESTDIR/test3.d
EOF
echo ""
echo "Testing @includedir of a double-quoted path"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<-EOF
@includedir "$TESTDIR/test3.d"
EOF
echo ""
echo "Testing #includedir of an unquoted path"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<-EOF
#includedir $TESTDIR/test3.d
EOF
echo ""
echo "Testing #includedir of a double-quoted path"
echo ""
./testsudoers -U $MYUID -G $MYGID root id <<-EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<-EOF
#includedir "$TESTDIR/test3.d"
EOF

View File

@@ -3,11 +3,13 @@
# Test sudoers owner check
#
: ${TESTSUDOERS=testsudoers}
# Avoid warnings about memory leaks when there is a syntax error
ASAN_OPTIONS=detect_leaks=0; export ASAN_OPTIONS
exec 2>&1
./testsudoers -U 1 root id <<EOF
$TESTSUDOERS -U 1 root id <<EOF
@include $TESTDIR/test2.inc
EOF

View File

@@ -3,12 +3,14 @@
# Test sudoers file mode check
#
: ${TESTSUDOERS=testsudoers}
# Avoid warnings about memory leaks when there is a syntax error
ASAN_OPTIONS=detect_leaks=0; export ASAN_OPTIONS
# Create test file
TESTFILE=`pwd`/regress/testsudoers/test5.inc
cat >$TESTFILE <<EOF
TESTFILE="`pwd`/regress/testsudoers/test5.inc"
cat >"$TESTFILE" <<EOF
root ALL = ALL
EOF
@@ -18,13 +20,13 @@ exec 2>&1
# Test world writable
chmod 666 $TESTFILE
./testsudoers -U $MYUID -G $MYGID root id <<EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<EOF
@include $TESTFILE
EOF
# Test group writable
chmod 664 $TESTFILE
./testsudoers -U $MYUID -G -2 root id <<EOF
$TESTSUDOERS -U $MYUID -G -2 root id <<EOF
@include $TESTFILE
EOF

View File

@@ -3,8 +3,10 @@
# Verify sudoers matching by uid.
#
: ${TESTSUDOERS=testsudoers}
exec 2>&1
./testsudoers root id <<EOF
$TESTSUDOERS root id <<EOF
#0 ALL = ALL
EOF

View File

@@ -3,8 +3,10 @@
# Verify sudoers matching by gid.
#
: ${TESTSUDOERS=testsudoers}
exec 2>&1
./testsudoers root id <<EOF
$TESTSUDOERS root id <<EOF
%#0 ALL = ALL
EOF

View File

@@ -4,6 +4,8 @@
# Same as test2.sh but missing the final newline.
#
: ${TESTSUDOERS=testsudoers}
MYUID=`\ls -ln $TESTDIR/test2.inc | awk '{print $3}'`
MYGID=`\ls -ln $TESTDIR/test2.inc | awk '{print $4}'`
exec 2>&1
@@ -11,12 +13,12 @@ exec 2>&1
echo "Testing @include without a newline"
echo ""
printf "@include $TESTDIR/test2.inc" | \
./testsudoers -U $MYUID -G $MYGID root id
$TESTSUDOERS -U $MYUID -G $MYGID root id
echo ""
echo "Testing #include without a newline"
echo ""
printf "#include $TESTDIR/test2.inc" | \
./testsudoers -U $MYUID -G $MYGID root id
$TESTSUDOERS -U $MYUID -G $MYGID root id
exit 0

View File

@@ -3,10 +3,12 @@
# Test #include facility
#
: ${TESTSUDOERS=testsudoers}
MYUID=`\ls -ln $TESTDIR/test2.inc | awk '{print $3}'`
MYGID=`\ls -ln $TESTDIR/test2.inc | awk '{print $4}'`
exec 2>&1
./testsudoers -U $MYUID -G $MYGID root id <<EOF
$TESTSUDOERS -U $MYUID -G $MYGID root id <<EOF
#include $TESTDIR/test2.inc
EOF

View File

@@ -4,7 +4,9 @@
# Visudo in strict mode reports "parse error" even if there is no error
#
./visudo -csf - <<EOF
: ${VISUDO=visudo}
$VISUDO -csf - <<EOF
User_Alias FOO = nobody
FOO ALL=(ALL) NOPASSWD: ALL
EOF

View File

@@ -3,7 +3,9 @@
# Test parsing of NOTBEFORE/NOTAFTER using local time zone
#
./visudo -cf - <<-EOF
: ${VISUDO=visudo}
$VISUDO -cf - <<-EOF
user1 ALL = NOTBEFORE=20151201235900 /usr/bin/id
user2 ALL = NOTBEFORE=20151201235900.2 /usr/bin/id
user3 ALL = NOTBEFORE=20151201235900\,2 /usr/bin/id

View File

@@ -5,7 +5,9 @@
# The names of the aliases (or rather their lexical order) is important.
#
./visudo -csf - <<EOF
: ${VISUDO=visudo}
$VISUDO -csf - <<EOF
User_Alias YYY = FOO
User_Alias XXX = nobody
User_Alias FOO = XXX, YYY

View File

@@ -4,7 +4,9 @@
# Excerises a bug in the redblack tree code.
#
./visudo -cf - <<EOF
: ${VISUDO=visudo}
$VISUDO -cf - <<EOF
User_Alias A=a
User_Alias B=a
User_Alias C=a

View File

@@ -4,7 +4,9 @@
# Prior to sudo 1.8.7 this resulted in a false positive.
#
./visudo -csf - <<EOF
: ${VISUDO=visudo}
$VISUDO -csf - <<EOF
Host_Alias H1 = host1
Host_Alias H2 = H1, host2
Host_Alias H3 = H1, H2

View File

@@ -3,6 +3,8 @@
# Test comment on the last line with no newline
#
printf "# one comment\n#two comments" | ./visudo -csf -
: ${VISUDO=visudo}
printf "# one comment\n#two comments" | $VISUDO -csf -
exit 0

View File

@@ -3,7 +3,9 @@
# Verify parsing of Defaults syntax
#
./visudo -csf - <<EOF
: ${VISUDO=visudo}
$VISUDO -csf - <<EOF
Defaults syslog=auth
Defaults>root !set_logname
Defaults:FULLTIMERS !lecture

View File

@@ -3,13 +3,15 @@
# Test sudoers_locale early Defaults
#
: ${VISUDO=visudo}
LANG=C; export LANG
LC_NUMERIC=fr_FR.UTF-8; export LC_NUMERIC
# First check that visudo supports non-C locales
# Note that older versions of sudo did not set the locale
# until sudoers was read so this check will fail on them.
./visudo -csf - >/dev/null 2>&1 <<-EOF
$VISUDO -csf - >/dev/null 2>&1 <<-EOF
Defaults sudoers_locale = fr_FR.UTF-8
Defaults passwd_timeout = "2,5"
EOF
@@ -17,7 +19,7 @@ LC_NUMERIC=fr_FR.UTF-8; export LC_NUMERIC
# Now make sure we can set passwd_timeout to a floating point value
# using a non-C locale.
if [ $? -eq 0 ]; then
./visudo -csf - <<-EOF
$VISUDO -csf - <<-EOF
Defaults passwd_timeout = "2,5"
Defaults sudoers_locale = fr_FR.UTF-8
EOF

View File

@@ -3,13 +3,15 @@
# Test sudoers_locale early Defaults
#
: ${VISUDO=visudo}
LANG=C; export LANG
LC_NUMERIC=fr_FR.UTF-8; export LC_NUMERIC
# First check that visudo supports non-C locales
# Note that older versions of sudo did not set the locale
# until sudoers was read so this check will fail on them.
./visudo -csf - >/dev/null 2>&1 <<-EOF
$VISUDO -csf - >/dev/null 2>&1 <<-EOF
Defaults sudoers_locale = fr_FR.UTF-8
Defaults passwd_timeout = "2,5"
EOF
@@ -17,7 +19,7 @@ LC_NUMERIC=fr_FR.UTF-8; export LC_NUMERIC
# Now make sure we can set passwd_timeout to a floating point value
# using a non-C locale.
if [ $? -eq 0 ]; then
./visudo -csf - <<-EOF
$VISUDO -csf - <<-EOF
Defaults passwd_timeout = "2.5"
Defaults sudoers_locale = fr_FR.UTF-8
EOF

View File

@@ -4,7 +4,9 @@
# Bugzilla #766
#
./visudo -cf - <<-EOF
: ${VISUDO=visudo}
$VISUDO -cf - <<-EOF
Defaults@127.0.0.1 !authenticate
Defaults@10.0.0.0/8 !always_set_home
EOF