-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.sh
executable file
·47 lines (37 loc) · 1.48 KB
/
export.sh
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
#!/bin/bash
# SPDX-FileCopyrightText: 2021 Markus Linnala <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
# Directory can be made running somehing like this:
# export DESTDIR="$(pwd)"/tmp/install
# printf "export DESTDIR=%q\n" "$DESTDIR"
# mkdir -p "$DESTDIR"/var/lib/selinux/targeted
## make DISTRO=redhat UBAC=n DIRECT_INITRC=n MONOLITHIC=n MLS_CATS=1024 MCS_CATS=1024 UNK_PERMS=allow NAME=targeted TYPE=mcs DESTDIR="$DESTDIR" 'SEMODULE=/usr/sbin/semodule -v -p '"$DESTDIR"' -X 100 ' conf
# make -j$(nproc) DISTRO=redhat UBAC=n DIRECT_INITRC=n MONOLITHIC=n MLS_CATS=1024 MCS_CATS=1024 UNK_PERMS=allow NAME=targeted TYPE=mcs DESTDIR="$DESTDIR" 'SEMODULE=/usr/sbin/semodule -v -p '"$DESTDIR"' -X 100 ' load
# make DESTDIR="$DESTDIR" 'SEMODULE=/usr/sbin/semodule -v -p '"$DESTDIR"' -X 100 ' NAME=devel install-headers
# cp /usr/share/selinux/devel/Makefile "$DESTDIR"/usr/share/selinux/devel/Makefile
# sed -ri 's,(SHAREDIR :=).*,\1 '"$DESTDIR"/usr/share/selinux',' "$DESTDIR"/usr/share/selinux/devel/Makefile
set -epu -o pipefail
if [ ! "${DESTDIR:-}" ]; then
(( $# ))
DESTDIR="$(readlink -f -- "$1")"
shift
fi
SEMODULE=(semodule -p "$DESTDIR")
mkdir -p export/tmp
pushd export/tmp
args=()
for a in $("${SEMODULE[@]}" -l); do
args+=(--cil --extract="$a")
done
"${SEMODULE[@]}" "${args[@]}"
for a in *.cil; do
[ -f "$a" ] || continue
if [ -f "$a" ] && cmp -s "$a" ../"$a"; then
:
else
mv -- "$a" ../"$a"
fi
done
popd
rm -rf -- export/tmp