aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2015-09-27 04:03:11 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2015-09-27 04:03:11 +0000
commitef4cd02bfa7d60a60b27402a9d1d1fc532c5ac23 (patch)
tree97a97a83293082d336d5f9203e244792297a7c8e /etc
parentc4dabdf78a60941b9cef0b1233b15a5d61000982 (diff)
downloadsrc-ef4cd02bfa7d60a60b27402a9d1d1fc532c5ac23.tar.gz
src-ef4cd02bfa7d60a60b27402a9d1d1fc532c5ac23.zip
Enforce consistent limits of daemons run from rc.subr:
* Allow the user to configure the login class to use in rc.conf by using {daemon}_login_class, which; * Use the daemon class by default; * .. and then use 'limits' to set the login class so it works both via init at startup (which runs this in 'daemon' class) and via whichever root environment (eg command line, other daemons, etc.) Reviewed by: dteske Differential Revision: https://reviews.freebsd.org/D3630
Notes
Notes: svn path=/head/; revision=288291
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.subr7
1 files changed, 6 insertions, 1 deletions
diff --git a/etc/rc.subr b/etc/rc.subr
index c23c8fd3e32e..cd933c685b4d 100644
--- a/etc/rc.subr
+++ b/etc/rc.subr
@@ -768,6 +768,8 @@ check_startmsgs()
#
# ${name}_prepend n Command added before ${command}.
#
+# ${name}_login_class n Login class to use, else "daemon".
+#
# ${rc_arg}_cmd n If set, use this as the method when invoked;
# Otherwise, use default command (see below)
#
@@ -942,7 +944,7 @@ run_rc_command()
_nice=\$${name}_nice _user=\$${name}_user \
_group=\$${name}_group _groups=\$${name}_groups \
_fib=\$${name}_fib _env=\$${name}_env \
- _prepend=\$${name}_prepend
+ _prepend=\$${name}_prepend _login_class=\${${name}_login_class:-daemon}
if [ -n "$_user" ]; then # unset $_user if running as that user
if [ "$_user" = "$(eval $IDCMD)" ]; then
@@ -1050,6 +1052,9 @@ $command $rc_flags $command_args"
fi
fi
+ # Prepend default limits
+ _doit="limits -C $_login_class $_doit"
+
# run the full command
#
if ! _run_rc_doit "$_doit"; then