Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/bsdinstall/scripts/hardening
Show All 24 Lines | |||||
# SUCH DAMAGE. | # SUCH DAMAGE. | ||||
# | # | ||||
# $FreeBSD$ | # $FreeBSD$ | ||||
: ${DIALOG_OK=0} | : ${DIALOG_OK=0} | ||||
echo -n > $BSDINSTALL_TMPETC/rc.conf.hardening | echo -n > $BSDINSTALL_TMPETC/rc.conf.hardening | ||||
echo -n > $BSDINSTALL_TMPETC/sysctl.conf.hardening | echo -n > $BSDINSTALL_TMPETC/sysctl.conf.hardening | ||||
echo -n > $BSDINSTALL_TMPBOOT/loader.conf.hardening | |||||
exec 3>&1 | exec 3>&1 | ||||
FEATURES=$( dialog --backtitle "FreeBSD Installer" \ | FEATURES=$( dialog --backtitle "FreeBSD Installer" \ | ||||
--title "System Hardening" --nocancel --separate-output \ | --title "System Hardening" --nocancel --separate-output \ | ||||
--checklist "Choose system security hardening options:" \ | --checklist "Choose system security hardening options:" \ | ||||
0 0 0 \ | 0 0 0 \ | ||||
"0 hide_uids" "Hide processes running as other users" ${hide_uids:-off} \ | "0 hide_uids" "Hide processes running as other users" ${hide_uids:-off} \ | ||||
"1 hide_gids" "Hide processes running as other groups" ${hide_gids:-off} \ | "1 hide_gids" "Hide processes running as other groups" ${hide_gids:-off} \ | ||||
"2 hide_jail" "Hide processes running in jails" ${hide_jail:-off} \ | "2 hide_jail" "Hide processes running in jails" ${hide_jail:-off} \ | ||||
"3 read_msgbuf" "Disable reading kernel message buffer for unprivileged users" ${read_msgbuf:-off} \ | "3 read_msgbuf" "Disable reading kernel message buffer for unprivileged users" ${read_msgbuf:-off} \ | ||||
"4 proc_debug" "Disable process debugging facilities for unprivileged users" ${proc_debug:-off} \ | "4 proc_debug" "Disable process debugging facilities for unprivileged users" ${proc_debug:-off} \ | ||||
"5 random_pid" "Randomize the PID of newly created processes" ${random_pid:-off} \ | "5 random_pid" "Randomize the PID of newly created processes" ${random_pid:-off} \ | ||||
"6 clear_tmp" "Clean the /tmp filesystem on system startup" ${clear_tmp:-off} \ | "6 clear_tmp" "Clean the /tmp filesystem on system startup" ${clear_tmp:-off} \ | ||||
"7 disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-off} \ | "7 disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-off} \ | ||||
"8 disable_sendmail" "Disable Sendmail service" ${disable_sendmail:-off} \ | "8 disable_sendmail" "Disable Sendmail service" ${disable_sendmail:-off} \ | ||||
"9 secure_console" "Enable console password prompt" ${secure_console:-off} \ | "9 secure_console" "Enable console password prompt" ${secure_console:-off} \ | ||||
"10 disable_ddtrace" "Disallow DTrace destructive-mode" ${disable_ddtrace:-off} \ | |||||
2>&1 1>&3 ) | 2>&1 1>&3 ) | ||||
exec 3>&- | exec 3>&- | ||||
for feature in $FEATURES; do | for feature in $FEATURES; do | ||||
if [ "$feature" = "hide_uids" ]; then | if [ "$feature" = "hide_uids" ]; then | ||||
echo security.bsd.see_other_uids=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening | echo security.bsd.see_other_uids=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening | ||||
fi | fi | ||||
if [ "$feature" = "hide_gids" ]; then | if [ "$feature" = "hide_gids" ]; then | ||||
Show All 17 Lines | for feature in $FEATURES; do | ||||
if [ "$feature" = "disable_syslogd" ]; then | if [ "$feature" = "disable_syslogd" ]; then | ||||
echo 'syslogd_flags="-ss"' >> $BSDINSTALL_TMPETC/rc.conf.hardening | echo 'syslogd_flags="-ss"' >> $BSDINSTALL_TMPETC/rc.conf.hardening | ||||
fi | fi | ||||
if [ "$feature" = "disable_sendmail" ]; then | if [ "$feature" = "disable_sendmail" ]; then | ||||
echo 'sendmail_enable="NONE"' >> $BSDINSTALL_TMPETC/rc.conf.hardening | echo 'sendmail_enable="NONE"' >> $BSDINSTALL_TMPETC/rc.conf.hardening | ||||
fi | fi | ||||
if [ "$feature" = "secure_console" ]; then | if [ "$feature" = "secure_console" ]; then | ||||
sed "s/unknown off secure/unknown off insecure/g" $BSDINSTALL_CHROOT/etc/ttys > $BSDINSTALL_TMPETC/ttys.hardening | sed "s/unknown off secure/unknown off insecure/g" $BSDINSTALL_CHROOT/etc/ttys > $BSDINSTALL_TMPETC/ttys.hardening | ||||
fi | |||||
if [ "$feature" = "disable_ddtrace" ]; then | |||||
echo 'security.bsd.allow_destructive_dtrace=0' >> $BSDINSTALL_TMPBOOT/loader.conf.hardening | |||||
fi | fi | ||||
done | done | ||||