|
6 | 6 | load helpers
|
7 | 7 | load helpers.network
|
8 | 8 |
|
| 9 | +# The existence of this file allows preexec hooks to run. |
| 10 | +preexec_hook_ok_file=/etc/containers/podman_preexec_hooks.txt |
| 11 | + |
9 | 12 | function setup() {
|
10 | 13 | basic_setup
|
11 | 14 | }
|
12 | 15 |
|
13 | 16 | function teardown() {
|
| 17 | + if [[ -n "$preexec_hook_ok_file" ]]; then |
| 18 | + sudo -n rm -f $preexec_hook_ok_file || true |
| 19 | + fi |
| 20 | + |
14 | 21 | basic_teardown
|
15 | 22 | }
|
16 | 23 |
|
17 | 24 | @test "podman preexec hook" {
|
| 25 | + # This file does not exist on any CI system nor any developer system |
| 26 | + # nor actually anywhere in the universe except a small small set of |
| 27 | + # places with very specific requirements. If we find this file on |
| 28 | + # our test system, it could be a leftover from prior testing, or |
| 29 | + # basically just something very weird. So, fail loudly if we see it. |
| 30 | + # No podman developer ever wants this file to exist. |
| 31 | + if [[ -e $preexec_hook_ok_file ]]; then |
| 32 | + # Unset the variable, so we don't delete it in teardown |
| 33 | + msg="File already exists (it should not): $preexec_hook_ok_file" |
| 34 | + preexec_hook_ok_file= |
| 35 | + |
| 36 | + die "$msg" |
| 37 | + fi |
| 38 | + |
| 39 | + # Good. File does not exist. Now see if we can TEMPORARILY create it. |
| 40 | + sudo -n touch $preexec_hook_ok_file || skip "test requires sudo" |
| 41 | + |
18 | 42 | preexec_hook_dir=$PODMAN_TMPDIR/auth
|
19 | 43 | mkdir -p $preexec_hook_dir
|
20 | 44 | preexec_hook_script=$preexec_hook_dir/pull_check.sh
|
|
29 | 53 | chmod +x $preexec_hook_script
|
30 | 54 |
|
31 | 55 | PODMAN_PREEXEC_HOOKS_DIR=$preexec_hook_dir run_podman 42 pull foobar
|
32 |
| - PODMAN_PREEXEC_HOOKS_DIR=$preexec_hook_dir run_podman 43 pull barfoo |
| 56 | + PODMAN_PREEXEC_HOOKS_DIR=$preexec_hook_dir run_podman 43 version |
| 57 | + |
| 58 | + sudo -n rm -f $preexec_hook_ok_file || true |
| 59 | + |
| 60 | + # no hooks-ok file, everything should now work again (HOOKS_DIR is ignored) |
| 61 | + PODMAN_PREEXEC_HOOKS_DIR=$preexec_hook_dir run_podman version |
33 | 62 | }
|
0 commit comments