Merge pull request #105 from cedwards/template_support_limits

Initial support for LIMITS in template automation
This commit is contained in:
Christer Edwards
2020-01-26 09:56:48 -07:00
committed by GitHub
24 changed files with 77 additions and 43 deletions
+25 -20
View File
@@ -2,29 +2,34 @@
## Lead ## Lead
Christer Edwards [christer.edwards@gmail.com] Christer Edwards [christer.edwards@gmail.com]
## Contributors ## Contributors (code)
Barry McCormick Barry McCormick
Jose Rivera Brian Downs
Giacomo Olgeni Dave Cottlehuber
Jan-Piet Mens Giacomo Olgeni
JP Mens
Jose Rivera
Lars E.
Sven R.
### Special thanks ### Special thanks
Software doesn't happen in a vacuum. Thank you to the following people who may Software doesn't happen in a vacuum. Thank you to the following people who may
not be found in the commit history. not be found in the commit history but have influenced Bastille's development
in some way.
Barry McCormick Carlos Meza
Carlos Meza Casandra Woodcox
Casandra Woodcox Clint Savage
Clint Savage G. Clifford Williams
G. Clifford Williams Jack Thomasson
Jack Thomasson Jun C Park
Jun C Park Justin Desilets
Justin Desilets Larry Raab
Larry Raab Nate Taylor
Nate Taylor Peter Czanik
Ryan Simpkins Ryan Simpkins
Tim Gelter Tim Gelter
Trevor Sharpe Trevor Sharpe
+1 -1
View File
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement ## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at conduct@bastillebsd.org. All reported by contacting the project team lead at christer.edwards@gmail.com. All
complaints will be reviewed and investigated and will result in a response that complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident. obligated to maintain confidentiality with regard to the reporter of an incident.
+1 -1
View File
@@ -1,6 +1,6 @@
BSD 3-Clause License BSD 3-Clause License
Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# Ressource limits added by Sven R github.com/hackacad # Ressource limits added by Sven R github.com/hackacad
# #
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+30 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@@ -92,6 +92,35 @@ for _jail in ${JAILS}; do
fi fi
fi fi
## LIMITS (RCTL)
if [ -s "${bastille_template}/LIMITS" ]; then
echo -e "${COLOR_GREEN}[${_jail}]:LIMITS -- START${COLOR_RESET}"
RACCT_ENABLE=$(sysctl -n kern.racct.enable)
if [ "${RACCT_ENABLE}" != '1' ]; then
echo "Racct not enabled. Append 'kern.racct.enable=1' to /boot/loader.conf and reboot"
continue
fi
while read _limits; do
## define the key and value
_limit_key=$(echo "${_limits}" | awk '{print $1}')
_limit_value=$(echo "${_limits}" | awk '{print $2}')
_rctl_rule="jail:${_jail}:${_limit_key}:deny=${_limit_value}/jail"
## if entry doesn't exist, add; else show existing entry
if [ ! "$(grep -qs "${_rctl_rule}" "${bastille_jailsdir}/${_jail}/rctl.conf")" ]; then
echo "${_rctl_rule}" >> "${bastille_jailsdir}/${_jail}/rctl.conf"
echo "${_limits}"
else
echo "${_limits}"
fi
## apply limits to system
rctl -a "${_rctl_rule}" || exit 1
done < "${bastille_template}/LIMITS"
echo -e "${COLOR_GREEN}[${_jail}]:LIMITS -- END${COLOR_RESET}"
echo
fi
## INCLUDE ## INCLUDE
if [ -s "${bastille_template}/INCLUDE" ]; then if [ -s "${bastille_template}/INCLUDE" ]; then
echo -e "${COLOR_GREEN}[${_jail}]:INCLUDE -- START${COLOR_RESET}" echo -e "${COLOR_GREEN}[${_jail}]:INCLUDE -- START${COLOR_RESET}"
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2018-2019, Christer Edwards <christer.edwards@gmail.com> # Copyright (c) 2018-2020, Christer Edwards <christer.edwards@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without