git: 8ea77f39ec17 - stable/13 - bsdinstall: replace multiple ifs with case
Ed Maste
emaste at FreeBSD.org
Fri Mar 5 17:52:11 UTC 2021
The branch stable/13 has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=8ea77f39ec170d1a8b1cc2bf514dfefe69cf86aa
commit 8ea77f39ec170d1a8b1cc2bf514dfefe69cf86aa
Author: Ed Maste <emaste at FreeBSD.org>
AuthorDate: 2021-01-29 19:00:29 +0000
Commit: Ed Maste <emaste at FreeBSD.org>
CommitDate: 2021-03-05 17:51:04 +0000
bsdinstall: replace multiple ifs with case
Reduce copy-paste and use a more typical construct.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28417
(cherry picked from commit fbc57e2df95b582f7d3287ed3919337bfec5711a)
---
usr.sbin/bsdinstall/scripts/hardening | 46 ++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/usr.sbin/bsdinstall/scripts/hardening b/usr.sbin/bsdinstall/scripts/hardening
index 9fea1b6aed5d..58ea0a112e26 100755
--- a/usr.sbin/bsdinstall/scripts/hardening
+++ b/usr.sbin/bsdinstall/scripts/hardening
@@ -52,38 +52,40 @@ FEATURES=$( dialog --backtitle "FreeBSD Installer" \
exec 3>&-
for feature in $FEATURES; do
- if [ "$feature" = "hide_uids" ]; then
+ case "$feature" in
+ hide_uids)
echo security.bsd.see_other_uids=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening
- fi
- if [ "$feature" = "hide_gids" ]; then
+ ;;
+ hide_gids)
echo security.bsd.see_other_gids=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening
- fi
- if [ "$feature" = "hide_jail" ]; then
+ ;;
+ hide_jail)
echo security.bsd.see_jail_proc=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening
- fi
- if [ "$feature" = "read_msgbuf" ]; then
+ ;;
+ read_msgbuf)
echo security.bsd.unprivileged_read_msgbuf=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening
- fi
- if [ "$feature" = "proc_debug" ]; then
+ ;;
+ proc_debug)
echo security.bsd.unprivileged_proc_debug=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening
- fi
- if [ "$feature" = "random_pid" ]; then
+ ;;
+ random_pid)
echo kern.randompid=1 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening
- fi
- if [ "$feature" = "clear_tmp" ]; then
+ ;;
+ clear_tmp)
echo 'clear_tmp_enable="YES"' >> $BSDINSTALL_TMPETC/rc.conf.hardening
- fi
- if [ "$feature" = "disable_syslogd" ]; then
+ ;;
+ disable_syslogd)
echo 'syslogd_flags="-ss"' >> $BSDINSTALL_TMPETC/rc.conf.hardening
- fi
- if [ "$feature" = "disable_sendmail" ]; then
+ ;;
+ disable_sendmail)
echo 'sendmail_enable="NONE"' >> $BSDINSTALL_TMPETC/rc.conf.hardening
- fi
- if [ "$feature" = "secure_console" ]; then
+ ;;
+ secure_console)
sed "s/unknown off secure/unknown off insecure/g" $BSDINSTALL_CHROOT/etc/ttys > $BSDINSTALL_TMPETC/ttys.hardening
- fi
- if [ "$feature" = "disable_ddtrace" ]; then
+ ;;
+ disable_ddtrace)
echo 'security.bsd.allow_destructive_dtrace=0' >> $BSDINSTALL_TMPBOOT/loader.conf.hardening
- fi
+ ;;
+ esac
done
More information about the dev-commits-src-branches
mailing list