blob: 1cff12e9ac2b5adca086aaa9c98a32eb4b5bb881 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#!/bin/sh -efu
#
# Copyright (c) 2020-2023 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later
usage()
{
cat >&2 <<EOF
Usage: $0 [<input>]
Generate secontext files from <input> list.
EOF
exit 1
}
if [ $# -eq 0 ]; then
input="${0%/*}/gen_tests.in"
else
input="$1"
shift
fi
dir="$(dirname "$input")"
[ $# -eq 0 ] || usage
{
cat <<EOF
# Generated by $0 from $input; do not edit.
secontext_EXECUTABLES = \\
EOF
sed -E -n 's/^([^#[:space:]]+--secontext(_full)?(_mismatch)?)[[:space:]].*/ \1 \\/p' < "$input"
cat <<EOF
#
EOF
sed -E -n 's/-/_/g; s/^([^#[:space:]]+__secontext(_full)?(_mismatch)?)[[:space:]].*/\1_LDADD = \$(LDADD) \$(libselinux_LDADD)/p' < "$input"
} > "$dir/secontext.am"
sed -E -n 's/^([^#[:space:]]+--secontext)[[:space:]].*/\1/p' < "$input" |
while read -r name; do {
cat <<-EOF > "$dir/$name.c"
/*
* Copyright (c) 2021 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "tests.h"
#ifdef HAVE_SELINUX_RUNTIME
# define TEST_SECONTEXT
# include "${name%--secontext}.c"
#else
SKIP_MAIN_UNDEFINED("HAVE_SELINUX_RUNTIME")
#endif
EOF
} < /dev/null; done
sed -E -n 's/^([^#[:space:]]+--secontext_full)[[:space:]].*/\1/p' < "$input" |
while read -r name; do {
cat <<-EOF > "$dir/$name.c"
#define PRINT_SECONTEXT_FULL
#include "${name%_full}.c"
EOF
} < /dev/null; done
sed -E -n 's/^([^#[:space:]]+--secontext(_full)?_mismatch)[[:space:]].*/\1/p' < "$input" |
while read -r name; do {
cat <<-EOF > "$dir/$name.c"
#define PRINT_SECONTEXT_MISMATCH
#include "${name%_mismatch}.c"
EOF
} < /dev/null; done
|