From owner-svn-doc-head@FreeBSD.ORG Wed Apr 30 16:17:17 2014 Return-Path: Delivered-To: svn-doc-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9D684185; Wed, 30 Apr 2014 16:17:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 88D1B14A6; Wed, 30 Apr 2014 16:17:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3UGHHwO018370; Wed, 30 Apr 2014 16:17:17 GMT (envelope-from dru@svn.freebsd.org) Received: (from dru@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3UGHHxD018369; Wed, 30 Apr 2014 16:17:17 GMT (envelope-from dru@svn.freebsd.org) Message-Id: <201404301617.s3UGHHxD018369@svn.freebsd.org> From: Dru Lavigne Date: Wed, 30 Apr 2014 16:17:17 +0000 (UTC) To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r44719 - head/en_US.ISO8859-1/books/handbook/security X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the doc tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Apr 2014 16:17:17 -0000 Author: dru Date: Wed Apr 30 16:17:17 2014 New Revision: 44719 URL: http://svnweb.freebsd.org/changeset/doc/44719 Log: Editorial review of Login Classes section. Sponsored by: iXsystems Modified: head/en_US.ISO8859-1/books/handbook/security/chapter.xml Modified: head/en_US.ISO8859-1/books/handbook/security/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/handbook/security/chapter.xml Wed Apr 30 14:45:09 2014 (r44718) +++ head/en_US.ISO8859-1/books/handbook/security/chapter.xml Wed Apr 30 16:17:17 2014 (r44719) @@ -3517,33 +3517,46 @@ UWWemqWuz3lAZuORQ9KX Resource limits - Traditionally, &os; used a resource limits database - controlled through a flat file, + &os; provides several methods for an administrator to + limit the amount of system resources an individual may use. + Disk quotas limit the amount of disk space available to + users. Quotas are discussed in + . + + + quotas + + + limiting users + quotas + + + disk quotas + + + Limits to other resources, such as CPU + and memory, can be set using either a flat + file or a command to configure a resource limits database. The + traditional method defines login classes by editing /etc/login.conf. While this method is still supported, any changes require a multi-step process of - editing this file in order to divide users into various group - labels known as classes, rebuilding the resource database using - cap_mkdb, making necessary changes to + editing this file, rebuilding the resource database, making necessary changes to /etc/master.passwd, and rebuilding the - password database using pwd_mkdb. This - could be time consuming, depending upon the number of users to + password database. This + can become time consuming, depending upon the number of users to configure. Beginning with &os; 9.0-RELEASE, rctl can be used to provide a more - fine-grained method of controlling resources limits for users. - This command supports much more than users as it can be used to - set resource constraints on processes, jails, and the original - login class. These advanced features provide administrators and - users with methods to control resources through the command line - and to set rules on system initialization using a configuration - file. + fine-grained method for controlling resource limits. + This command supports more than user limits as it can also be used to + set resource constraints on processes and jails. This section demonstrates both methods for controlling - resources. + resources, beginning with the traditional method. - Login Classes + Configuring Login Classes limiting users @@ -3552,55 +3565,24 @@ UWWemqWuz3lAZuORQ9KX accounts limiting - - &os; provides several methods for an administrator to - limit the amount of system resources an individual may use. - These limits are discussed in two sections: disk quotas and - other resource limits. - - - quotas - - - limiting users - quotas - - - disk quotas - - - Disk quotas limit the amount of disk space available to - users and provide a way to quickly check that usage without - calculating it every time. Quotas are discussed in - . - - The other resource limits include ways to limit the amount - of CPU, memory, and other resources a user may consume. These - are defined using login classes and are discussed here. - /etc/login.conf - Login classes are defined in - /etc/login.conf and are described in - detail in &man.login.conf.5;. Each user account is assigned - to a login class, default by default, and - each login class has a set of login capabilities associated + In the traditional method, login classes and the resource + limits to apply to a login class are defined in + /etc/login.conf. Each user account can be assigned + to a login class, where default is the default + login class. Each login class has a set of login capabilities associated with it. A login capability is a name=value pair, where name is a well-known identifier and value is an arbitrary string which is processed accordingly depending on - the name. Setting up login classes - and capabilities is rather straightforward and is also - described in &man.login.conf.5;. + the name. - &os; does not normally read the configuration in - /etc/login.conf directly, but instead - reads the /etc/login.conf.db database - which provides faster lookups. Whenever + Whenever /etc/login.conf is edited, the /etc/login.conf.db must be updated by executing the following command: @@ -3609,207 +3591,159 @@ UWWemqWuz3lAZuORQ9KX Resource limits differ from the default login capabilities - in two ways. First, for every limit, there is a soft - (current) and hard limit. A soft limit may be adjusted by the + in two ways. First, for every limit, there is a soft + and hard limit. A soft limit may be adjusted by the user or application, but may not be set higher than the hard limit. The hard limit may be lowered by the user, but can only be raised by the superuser. Second, most resource limits - apply per process to a specific user, not to the user as a - whole. These differences are mandated by the specific - handling of the limits, not by the implementation of the login - capability framework. - - Below are the most commonly used resource limits. The - rest of the limits, along with all the other login - capabilities, can be found in &man.login.conf.5;. - - - - coredumpsize + apply per process to a specific user. + + lists the most commonly + used resource limits. All of the available + resource limits and capabilities are described in + detail in &man.login.conf.5;. - - The limit on the size of a core file - - coredumpsize - - generated by a program is subordinate to other limits limiting users coredumpsize - on disk usage, such as filesize, or - disk quotas. This limit is often used as a less-severe - method of controlling disk space consumption. Since - users do not generate core files themselves, and often - do not delete them, setting this may save them from - running out of disk space should a large program - crash. - - - - - cputime - - - The maximum amount of CPU - cputime + limiting users + cputime limiting users - cputime + filesize - time a user's process may consume. Offending processes - will be killed by the kernel. - - - This is a limit on CPU time - consumed, not percentage of the CPU as displayed in - some fields by &man.top.1; and &man.ps.1;. - - - - - - filesize - - - The maximum size of a file - filesize + limiting users + maxproc limiting users - filesize + memorylocked - the user may own. Unlike - disk quotas, this limit is - enforced on individual files, not the set of all files a - user owns. - - - - - maxproc - - - The maximum number of processes - maxproc + limiting users + memoryuse limiting users - maxproc + openfiles - a user can run. This includes foreground and background - processes. This limit may not be larger than the system - limit specified by the kern.maxproc - &man.sysctl.8;. Setting this limit too small may hinder - a user's productivity as it is often useful to be logged - in multiple times or to execute pipelines. Some tasks, - such as compiling a large program, start lots of - processes. - - - - - memorylocked - - - The maximum amount of memory - memorylocked + limiting users + sbsize limiting users - memorylocked + stacksize + + + Login Class Resource Limits + + + + + Resource Limit + Description + + + + + + coredumpsize + The limit on the size of a core file + generated by a program is subordinate to other limits + on disk usage, such as filesize or + disk quotas. This limit is often used as a less severe + method of controlling disk space consumption. Since + users do not generate core files and often + do not delete them, this setting may save them from + running out of disk space should a large program + crash. + + + + cputime + The maximum amount of CPU + time a user's process may consume. Offending processes + will be killed by the kernel. This is a limit on + CPU time + consumed, not the percentage of the CPU as displayed in + some of the fields generated by top + and ps. + + + + filesize + The maximum size of a file + the user may own. Unlike disk quotas + (), this limit is + enforced on individual files, not the set of all files a + user owns. + + + + maxproc + The maximum number of foreground and background processes + a user can run. This limit may not be larger than the system + limit specified by kern.maxproc. + Setting this limit too small may hinder + a user's productivity as some tasks, + such as compiling a large program, start lots of + processes. + + + + memorylocked + The maximum amount of memory a process may request to be locked into main memory using &man.mlock.2;. Some system-critical programs, such as &man.amd.8;, lock into main memory so that if the system begins to swap, they do not contribute to - disk thrashing. - - - - - memoryuse + disk thrashing. + - - The maximum amount of memory - - memoryuse - - - limiting users - memoryuse - + + memoryuse + The maximum amount of memory a process may consume at any given time. It includes both core memory and swap usage. This is not a catch-all limit for restricting memory consumption, but - is a good start. - - - - - openfiles + is a good start. + - - The maximum number of files a process may have open - - openfiles - - - limiting users - openfiles - . - In &os;, files are used to represent sockets and IPC + + openfiles + The maximum number of files a process may have open. + In &os;, files are used to represent sockets and IPC channels, so be careful not to set this too low. The - system-wide limit for this is defined by the - kern.maxfiles &man.sysctl.8;. - - - - - sbsize - - - The limit on the amount of network memory, and - thus mbufs - - sbsize - - - limiting users - sbsize - , + system-wide limit for this is defined by + kern.maxfiles. + + + + sbsize + The limit on the amount of network memory a user may consume. This can be generally used to limit - network communications. - - + network communications. + - - stacksize - - - The maximum size of a process stack - - stacksize - - - limiting users - stacksize - . + + stacksize + The maximum size of a process stack. This alone is not sufficient to limit the amount of - memory a program may use so it should be used in - conjunction with other limits. - - - + memory a program may use, so it should be used in + conjunction with other limits. + + + +
There are a few other things to remember when setting - resource limits. Following are some general tips, - suggestions, and miscellaneous comments. + resource limits:
@@ -3819,8 +3753,8 @@ UWWemqWuz3lAZuORQ9KX - Although the /etc/login.conf that - comes with the system is a good source of reasonable + Although the default /etc/login.conf + is a good source of reasonable values for most limits, they may not be appropriate for every system. Setting a limit too high may open the system up to abuse, while setting it too low may put a @@ -3828,18 +3762,16 @@ UWWemqWuz3lAZuORQ9KX - Users of &xorg; should - probably be granted more resources than other users. - &xorg; by itself takes a lot of - resources, but it also encourages users to run more + &xorg; takes a lot of + resources and encourages users to run more programs simultaneously. Many limits apply to individual processes, not the user as a whole. For example, setting - openfiles to 50 means that each process - the user runs may open up to 50 files. The total amount + openfiles to 50 means that each process + the user runs may open up to 50 files. The total amount of files a user may open is the value of openfiles multiplied by the value of maxproc. This also applies to memory