Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Sep 2015 04:03:11 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r288291 - head/etc
Message-ID:  <201509270403.t8R43B5Z062241@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Sun Sep 27 04:03:11 2015
New Revision: 288291
URL: https://svnweb.freebsd.org/changeset/base/288291

Log:
  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

Modified:
  head/etc/rc.subr

Modified: head/etc/rc.subr
==============================================================================
--- head/etc/rc.subr	Sun Sep 27 03:46:55 2015	(r288290)
+++ head/etc/rc.subr	Sun Sep 27 04:03:11 2015	(r288291)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509270403.t8R43B5Z062241>