summaryrefslogtreecommitdiffstats
path: root/plugins/sudoers/regress/testsudoers/test25.sh
blob: a3c395c7baafd24d1a4511634699294ce5e1925c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
#
# Test user-specified cwd handling
#

: ${TESTSUDOERS=testsudoers}

exec 2>&1
cd /

retval=0

# Sudo used to allow the user to set the cwd to the current value.
# Now, a cwd must be explicitly set in sudoers to use the -D option.
printf "A simple sudoers rule should not allow the user to set the cwd:\n"
$TESTSUDOERS -D / root /bin/ls <<'EOF'
root ALL = /bin/ls
EOF
if [ $? -eq 0 ]; then
    retval=1
fi

printf "\nUser cannot override the sudoers cwd:\n"
$TESTSUDOERS -D / root /bin/ls <<'EOF'
root ALL = CWD=/some/where/else /bin/ls
EOF
if [ $? -eq 0 ]; then
    retval=1
fi

printf "\nUser can set cwd if sudoers rule sets cwd to '*':\n"
$TESTSUDOERS -D /usr root /bin/ls <<'EOF'
root ALL = CWD=* /bin/ls
EOF
if [ $? -ne 0 ]; then
    retval=$?
fi

printf "\nUser can set cwd runcwd Defaults is '*':\n"
$TESTSUDOERS -D /usr root /bin/ls <<'EOF'
Defaults runcwd = "*"
root ALL = /bin/ls
EOF
if [ $? -ne 0 ]; then
    retval=$?
fi

exit $retval