2 # SPDX-License-Identifier: GPL-2.0
4 if [ `id -u` -ne 0 ]; then
5 echo "$0: must be root to install the selinux policy"
11 echo "Could not find setfiles"
12 echo "Do you have policycoreutils installed?"
16 CP
=`which checkpolicy`
18 echo "Could not find checkpolicy"
19 echo "Do you have checkpolicy installed?"
22 VERS
=`$CP -V | awk '{print $1}'`
24 ENABLED
=`which selinuxenabled`
26 echo "Could not find selinuxenabled"
27 echo "Do you have libselinux-utils installed?"
31 if selinuxenabled
; then
32 echo "SELinux is already enabled"
33 echo "This prevents safely relabeling all files."
34 echo "Boot with selinux=0 on the kernel command-line."
39 .
/mdp
-m policy.conf file_contexts
40 $CP -U allow
-M -o policy.
$VERS policy.conf
42 mkdir
-p /etc
/selinux
/dummy
/policy
43 mkdir
-p /etc
/selinux
/dummy
/contexts
/files
45 echo "__default__:user_u:s0" > /etc
/selinux
/dummy
/seusers
46 echo "base_r:base_t:s0" > /etc
/selinux
/dummy
/contexts
/failsafe_context
47 echo "base_r:base_t:s0 base_r:base_t:s0" > /etc
/selinux
/dummy
/default_contexts
48 cat > /etc
/selinux
/dummy
/contexts
/x_contexts
<<EOF
49 client * user_u:base_r:base_t:s0
50 property * user_u:object_r:base_t:s0
51 extension * user_u:object_r:base_t:s0
52 selection * user_u:object_r:base_t:s0
53 event * user_u:object_r:base_t:s0
55 touch /etc
/selinux
/dummy
/contexts
/virtual_domain_context
56 touch /etc
/selinux
/dummy
/contexts
/virtual_image_context
58 cp file_contexts
/etc
/selinux
/dummy
/contexts
/files
59 cp dbus_contexts
/etc
/selinux
/dummy
/contexts
60 cp policy.
$VERS /etc
/selinux
/dummy
/policy
61 FC_FILE
=/etc
/selinux
/dummy
/contexts
/files
/file_contexts
63 if [ ! -d /etc
/selinux
]; then
66 if [ -f /etc
/selinux
/config
]; then
67 echo "/etc/selinux/config exists, moving to /etc/selinux/config.bak."
68 mv /etc
/selinux
/config
/etc
/selinux
/config.bak
70 echo "Creating new /etc/selinux/config for dummy policy."
71 cat > /etc
/selinux
/config
<< EOF
76 cd /etc
/selinux
/dummy
/contexts
/files
77 $SF -F file_contexts
/
79 mounts
=`cat /proc/$$/mounts | \
80 grep -E "ext[234]|jfs|xfs|reiserfs|jffs2|gfs2|btrfs|f2fs|ocfs2" | \
82 $SF -F file_contexts
$mounts
84 echo "-F" > /.autorelabel