This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
linux-grsec.install
125 lines (97 loc) · 2.79 KB
/
linux-grsec.install
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# arg 1: the new package version
# arg 2: the old package version
KERNEL_NAME=-grsec
KERNEL_VERSION=
_add_tpe_group() {
if getent group tpe-trusted >/dev/null; then
groupmod -g 200 -n tpe tpe-trusted
fi
if ! getent group tpe >/dev/null; then
groupadd -g 200 -r tpe
fi
}
_add_audit_group() {
if ! getent group audit >/dev/null; then
groupadd -g 201 -r audit
fi
}
_add_socket_deny_groups() {
if getent group socket-deny-all >/dev/null; then
groupmod -g 202 socket-deny-all
else
groupadd -g 202 -r socket-deny-all
fi
if getent group socket-deny-client >/dev/null; then
groupmod -g 203 socket-deny-client
else
groupadd -g 203 -r socket-deny-client
fi
if getent group socket-deny-server >/dev/null; then
groupmod -g 204 socket-deny-server
else
groupadd -g 204 -r socket-deny-server
fi
}
_add_groups() {
_add_tpe_group
_add_socket_deny_groups
}
_remove_groups() {
for group in tpe socket-deny-server socket-deny-client socket-deny-all; do
if getent group $group >/dev/null; then
groupdel $group
fi
done
}
_help() {
cat <<EOF
Configuration of grsecurity features via sysctl is possible in
"/etc/sysctl.d/05-grsecurity.conf".
For group tpe, Trusted Path Execution is disabled. For group proc, the access
to /proc is not restricted. Think carefully before adding a normal user to
these groups.
To prevent certain socket access to users, there are three groups:
socket-deny-server, socket-deny-client and socket-deny-all.
There is an extensive wikibook on grsecurity and some documentation in the Arch
Linux Wiki:
https://en.wikibooks.org/wiki/Grsecurity
https://wiki.archlinux.org/index.php/Grsecurity
EOF
}
_warn_proc_trusted() {
cat <<EOF
WARNING: The proc-trusted group (for non-restricted access to /proc) was
deleted and is replaced by the proc group, now.
EOF
}
post_install() {
# updating module dependencies
echo ">>> Updating module dependencies. Please wait ..."
depmod ${KERNEL_VERSION}
echo ">>> Generating initial ramdisk, using mkinitcpio. Please wait..."
mkinitcpio -p linux${KERNEL_NAME}
_add_groups
_help
}
post_upgrade() {
if findmnt --fstab -uno SOURCE /boot &>/dev/null && ! mountpoint -q /boot; then
echo "WARNING: /boot appears to be a separate partition but is not mounted."
fi
# updating module dependencies
echo ">>> Updating module dependencies. Please wait ..."
depmod ${KERNEL_VERSION}
echo ">>> Generating initial ramdisk, using mkinitcpio. Please wait..."
mkinitcpio -p linux${KERNEL_NAME}
_add_groups
if getent group proc-trusted >/dev/null; then
groupdel $group
_warn_proc_trusted
fi
_help
}
post_remove() {
# also remove the compat symlinks
rm -f boot/initramfs-linux${KERNEL_NAME}.img
rm -f boot/initramfs-linux${KERNEL_NAME}-fallback.img
_remove_groups
}