Skip to content

Commit cf40adb

Browse files
Merge pull request #17118 from giuseppe/rename-auth-scripts-to-preexec-hooks
rootless: rename auth-scripts to preexec-hooks
2 parents 7093d1f + a581d2a commit cf40adb

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

pkg/rootless/rootless_linux.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <sys/select.h>
2121
#include <stdio.h>
2222

23-
#define ETC_AUTH_SCRIPTS "/etc/containers/auth-scripts"
23+
#define ETC_PREEXEC_HOOKS "/etc/containers/pre-exec-hooks"
2424
#define LIBEXECPODMAN "/usr/libexec/podman"
2525

2626
#ifndef TEMP_FAILURE_RETRY
@@ -164,23 +164,23 @@ exec_binary (const char *path, char **argv, int argc)
164164
}
165165
if (WIFEXITED(status) && WEXITSTATUS (status))
166166
{
167-
fprintf (stderr, "external auth script %s failed\n", path);
167+
fprintf (stderr, "external preexec hook %s failed\n", path);
168168
exit (WEXITSTATUS(status));
169169
}
170170
if (WIFSIGNALED (status))
171171
{
172-
fprintf (stderr, "external auth script %s failed\n", path);
172+
fprintf (stderr, "external preexec hook %s failed\n", path);
173173
exit (127+WTERMSIG (status));
174174
}
175175
if (WIFSTOPPED (status))
176176
{
177-
fprintf (stderr, "external auth script %s failed\n", path);
177+
fprintf (stderr, "external preexec hook %s failed\n", path);
178178
exit (EXIT_FAILURE);
179179
}
180180
}
181181

182182
static void
183-
do_auth_scripts_dir (const char *dir, char **argv, int argc)
183+
do_preexec_hooks_dir (const char *dir, char **argv, int argc)
184184
{
185185
cleanup_free char *buffer = NULL;
186186
cleanup_dir DIR *d = NULL;
@@ -261,13 +261,13 @@ do_auth_scripts_dir (const char *dir, char **argv, int argc)
261261
}
262262

263263
static void
264-
do_auth_scripts (char **argv, int argc)
264+
do_preexec_hooks (char **argv, int argc)
265265
{
266-
char *auth_scripts = getenv ("PODMAN_AUTH_SCRIPTS_DIR");
267-
do_auth_scripts_dir (LIBEXECPODMAN "/auth-scripts", argv, argc);
268-
do_auth_scripts_dir (ETC_AUTH_SCRIPTS, argv, argc);
269-
if (auth_scripts && auth_scripts[0])
270-
do_auth_scripts_dir (auth_scripts, argv, argc);
266+
char *preexec_hooks = getenv ("PODMAN_PREEXEC_HOOKS_DIR");
267+
do_preexec_hooks_dir (LIBEXECPODMAN "/pre-exec-hooks", argv, argc);
268+
do_preexec_hooks_dir (ETC_PREEXEC_HOOKS, argv, argc);
269+
if (preexec_hooks && preexec_hooks[0])
270+
do_preexec_hooks_dir (preexec_hooks, argv, argc);
271271
}
272272

273273
static void
@@ -498,7 +498,7 @@ static void __attribute__((constructor)) init()
498498
}
499499

500500
if (geteuid () != 0 || getenv ("_CONTAINERS_USERNS_CONFIGURED") == NULL)
501-
do_auth_scripts(argv, argc);
501+
do_preexec_hooks(argv, argc);
502502

503503
listen_pid = getenv("LISTEN_PID");
504504
listen_fds = getenv("LISTEN_FDS");

test/system/950-auth-scripts.bats

Lines changed: 0 additions & 33 deletions
This file was deleted.

test/system/950-preexec-hooks.bats

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Tests for podman preexec hooks
4+
#
5+
6+
load helpers
7+
load helpers.network
8+
9+
function setup() {
10+
basic_setup
11+
}
12+
13+
function teardown() {
14+
basic_teardown
15+
}
16+
17+
@test "podman preexec hook" {
18+
preexec_hook_dir=$PODMAN_TMPDIR/auth
19+
mkdir -p $preexec_hook_dir
20+
preexec_hook_script=$preexec_hook_dir/pull_check.sh
21+
22+
cat > $preexec_hook_script <<EOF
23+
#!/bin/sh
24+
if echo \$@ | grep "pull foobar"; then
25+
exit 42
26+
fi
27+
exit 43
28+
EOF
29+
chmod +x $preexec_hook_script
30+
31+
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
33+
}

0 commit comments

Comments
 (0)