Debian Codegraph @

tests/ts/su/environ

raw symbols SCIP
1 #!/bin/bash
2 #
3 # Copyright (C) 2024 Karel Zak <[email protected]>
4 #
5 # This file is part of util-linux.
6 TS_TOPDIR="${0%/*}/../.."
7 TS_DESC="environ"
8
9 . "$TS_TOPDIR"/functions.sh
10 ts_init "$*"
11
12 ts_skip_nonroot
13 ts_check_test_command "$TS_CMD_SU"
14
15 export ZUU=zuux
16 export FOO=abc
17 export BAR=baar
18
19 # All should be available
20 $TS_CMD_SU --command 'echo foo:$FOO bar:$BAR zuu:$ZUU' >> $TS_OUTPUT 2>> $TS_ERRLOG
21
22 # All should be removed
23 $TS_CMD_SU --login --command 'echo foo:$FOO bar:$BAR zuu:$ZUU' >> $TS_OUTPUT 2>> $TS_ERRLOG
24
25 # Only specified options should be available
26 $TS_CMD_SU --whitelist-environment FOO --login --command 'echo foo:$FOO bar:$BAR zuu:$ZUU' >> $TS_OUTPUT 2>> $TS_ERRLOG
27
28 # Only specified options should be available
29 $TS_CMD_SU --whitelist-environment FOO,BAR --login --command 'echo foo:$FOO bar:$BAR zuu:$ZUU' >> $TS_OUTPUT 2>> $TS_ERRLOG
30
31 # We do not have control over PAM setup, and the goal of this test is to check
32 # the environment, not the overall functionality of su(1). Therefore, if su(1)
33 # fails due to authentication, the test should be skipped.
34 #
35 grep -q 'Authentication failure' $TS_ERRLOG
36 [ $? -eq 0 ] && ts_skip "authentication failure"
37
38 ts_finalize