Linux Audio

Check our new training course

Loading...
v3.1
 1#!/bin/sh
 
 
 2if [ `id -u` -ne 0 ]; then
 3	echo "$0: must be root to install the selinux policy"
 4	exit 1
 5fi
 
 6SF=`which setfiles`
 7if [ $? -eq 1 ]; then
 8	if [ -f /sbin/setfiles ]; then
 9		SF="/usr/setfiles"
10	else
11		echo "no selinux tools installed: setfiles"
12		exit 1
13	fi
14fi
15
16cd mdp
17
18CP=`which checkpolicy`
 
 
 
 
 
19VERS=`$CP -V | awk '{print $1}'`
20
21./mdp policy.conf file_contexts
22$CP -o policy.$VERS policy.conf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
24mkdir -p /etc/selinux/dummy/policy
25mkdir -p /etc/selinux/dummy/contexts/files
26
 
 
 
 
 
 
 
 
 
 
 
 
 
27cp file_contexts /etc/selinux/dummy/contexts/files
28cp dbus_contexts /etc/selinux/dummy/contexts
29cp policy.$VERS /etc/selinux/dummy/policy
30FC_FILE=/etc/selinux/dummy/contexts/files/file_contexts
31
32if [ ! -d /etc/selinux ]; then
33	mkdir -p /etc/selinux
34fi
35if [ ! -f /etc/selinux/config ]; then
36	cat > /etc/selinux/config << EOF
37SELINUX=enforcing
 
 
 
 
38SELINUXTYPE=dummy
39EOF
40else
41	TYPE=`cat /etc/selinux/config | grep "^SELINUXTYPE" | tail -1 | awk -F= '{ print $2 '}`
42	if [ "eq$TYPE" != "eqdummy" ]; then
43		selinuxenabled
44		if [ $? -eq 0 ]; then
45			echo "SELinux already enabled with a non-dummy policy."
46			echo "Exiting.  Please install policy by hand if that"
47			echo "is what you REALLY want."
48			exit 1
49		fi
50		mv /etc/selinux/config /etc/selinux/config.mdpbak
51		grep -v "^SELINUXTYPE" /etc/selinux/config.mdpbak >> /etc/selinux/config
52		echo "SELINUXTYPE=dummy" >> /etc/selinux/config
53	fi
54fi
55
56cd /etc/selinux/dummy/contexts/files
57$SF file_contexts /
58
59mounts=`cat /proc/$$/mounts | egrep "ext2|ext3|xfs|jfs|ext4|ext4dev|gfs2" | awk '{ print $2 '}`
60$SF file_contexts $mounts
61
 
 
 
 
62
63dodev=`cat /proc/$$/mounts | grep "/dev "`
64if [ "eq$dodev" != "eq" ]; then
65	mount --move /dev /mnt
66	$SF file_contexts /dev
67	mount --move /mnt /dev
68fi
69
v6.8
 1#!/bin/sh
 2# SPDX-License-Identifier: GPL-2.0
 3set -e
 4if [ `id -u` -ne 0 ]; then
 5	echo "$0: must be root to install the selinux policy"
 6	exit 1
 7fi
 8
 9SF=`which setfiles`
10if [ $? -eq 1 ]; then
11	echo "Could not find setfiles"
12	echo "Do you have policycoreutils installed?"
13	exit 1
 
 
 
14fi
15
 
 
16CP=`which checkpolicy`
17if [ $? -eq 1 ]; then
18	echo "Could not find checkpolicy"
19	echo "Do you have checkpolicy installed?"
20	exit 1
21fi
22VERS=`$CP -V | awk '{print $1}'`
23
24ENABLED=`which selinuxenabled`
25if [ $? -eq 1 ]; then
26	echo "Could not find selinuxenabled"
27	echo "Do you have libselinux-utils installed?"
28	exit 1
29fi
30
31if 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."
35    exit 1
36fi
37
38cd mdp
39./mdp -m policy.conf file_contexts
40$CP -U allow -M -o policy.$VERS policy.conf
41
42mkdir -p /etc/selinux/dummy/policy
43mkdir -p /etc/selinux/dummy/contexts/files
44
45echo "__default__:user_u:s0" > /etc/selinux/dummy/seusers
46echo "base_r:base_t:s0" > /etc/selinux/dummy/contexts/failsafe_context
47echo "base_r:base_t:s0 base_r:base_t:s0" > /etc/selinux/dummy/default_contexts
48cat > /etc/selinux/dummy/contexts/x_contexts <<EOF
49client * user_u:base_r:base_t:s0
50property * user_u:object_r:base_t:s0
51extension * user_u:object_r:base_t:s0
52selection * user_u:object_r:base_t:s0
53event * user_u:object_r:base_t:s0
54EOF
55touch /etc/selinux/dummy/contexts/virtual_domain_context
56touch /etc/selinux/dummy/contexts/virtual_image_context
57
58cp file_contexts /etc/selinux/dummy/contexts/files
59cp dbus_contexts /etc/selinux/dummy/contexts
60cp policy.$VERS /etc/selinux/dummy/policy
61FC_FILE=/etc/selinux/dummy/contexts/files/file_contexts
62
63if [ ! -d /etc/selinux ]; then
64	mkdir -p /etc/selinux
65fi
66if [ -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
69fi
70echo "Creating new /etc/selinux/config for dummy policy."
71cat > /etc/selinux/config << EOF
72SELINUX=permissive
73SELINUXTYPE=dummy
74EOF
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
76cd /etc/selinux/dummy/contexts/files
77$SF -F file_contexts /
 
 
 
78
79mounts=`cat /proc/$$/mounts | \
80	grep -E "ext[234]|jfs|xfs|reiserfs|jffs2|gfs2|btrfs|f2fs|ocfs2" | \
81	awk '{ print $2 '}`
82$SF -F file_contexts $mounts
83
84echo "-F" > /.autorelabel