Zum Inhalt springen

limits.conf

Aus Foxwiki

limits.conf - configuration file for the pam_limits module

Beschreibung

The pam_limits.so module applies ulimit limits, nice priority and number of simultaneous login sessions limit to user login sessions.

/etc/security/limits.conf

This description of the configuration file syntax applies to the /etc/security/limits.conf file

/etc/security/limits.d

and *.conf files in the /etc/security/limits.d directory.

Installation

Aufruf

Die Syntax der Zeilen lautet wie folgt:

<domain> <type> <item> <value>

Die oben aufgeführten Felder sollten wie folgt ausgefüllt werden:

<domain>

username
groupname mit @group-Syntax. Dies sollte nicht mit Netzgruppen verwechselt werden.
Platzhalter * für Standardeintrag.
Platzhalter % nur für maxlogins-Begrenzung, kann auch mit der Syntax %group verwendet werden. Wenn der Platzhalter % allein verwendet wird, entspricht dies der Verwendung von * mit maxsyslogins-Begrenzung. Wenn nach % eine Gruppe angegeben wird, begrenzt dies die Gesamtzahl der Anmeldungen aller Benutzer, die Mitglieder der Gruppe sind.
uid-Bereich angegeben als <min_uid>:<max_uid>. Wenn min_uid weggelassen wird, ist die Übereinstimmung exakt für max_uid. Wenn max_uid weggelassen wird, stimmen alle uids überein, die größer oder gleich min_uid sind.
gid-Bereich angegeben als @<min_gid>:<max_gid>. Wenn min_gid weggelassen wird, ist die Übereinstimmung exakt für max_gid. Wenn max_gid weggelassen wird, stimmen alle GIDs überein, die größer oder gleich min_gid sind. Für die exakte Übereinstimmung werden alle Gruppen einschließlich der zusätzlichen Gruppen des Benutzers überprüft. Für die Bereichsübereinstimmung wird nur die primäre Gruppe des Benutzers überprüft.
gid angegeben als %:<gid>, gilt nur für die Begrenzung maxlogins. Begrenzt die Gesamtzahl der Anmeldungen aller Benutzer, die Mitglieder der Gruppe mit der angegebenen GID sind.
HINWEIS
Gruppen- und Platzhalterbeschränkungen gelten nicht für den Root-Benutzer. Um eine Beschränkung für den Root-Benutzer festzulegen, muss dieses Feld den literalen Benutzernamen root enthalten.

<type>

| hard || zur Durchsetzung harter Ressourcenbeschränkungen. Diese Beschränkungen werden vom Superuser festgelegt und vom Kernel durchgesetzt. Der Benutzer kann seinen Bedarf an Systemressourcen nicht über diese Werte hinaus erhöhen. |- | soft || zur Durchsetzung weicher Ressourcenbeschränkungen. Diese Beschränkungen können vom Benutzer innerhalb des zulässigen Bereichs durch bereits vorhandene harte Beschränkungen nach oben oder unten verschoben werden. Die mit diesem Token angegebenen Werte können als Standardwerte für die normale Systemnutzung betrachtet werden. |- | - || zur gemeinsamen Durchsetzung von weichen und harten Ressourcenbeschränkungen. |}

Beachten
Wenn Sie den Typ „-“ angeben, aber die Felder „item“ und „value“ nicht ausfüllen, wird das Modul niemals Beschränkungen für den angegebenen Benutzer/die angegebene Gruppe usw. durchsetzen.

<item>

core begrenzt die Größe der Core-Datei (KB)
data maximale Datengröße (KB)
fsize maximale Dateigröße (KB)
memlock maximaler Adressraum im Arbeitsspeicher (KB)
nofile maximale Anzahl offener Dateideskriptoren
rss maximale Resident Set Size (KB) (wird in Linux 2.4.30 und höher ignoriert)
stack maximale Stackgröße (KB)
cpu maximale CPU-Zeit (Minuten)
nproc maximale Anzahl von Prozessen
as Adressraumgrenze (KB)
maxlogins maximale Anzahl von Anmeldungen für diesen Benutzer (diese Grenze gilt nicht für Benutzer mit uid=0)
maxsyslogins maximale Anzahl aller Anmeldungen im System; Benutzer dürfen sich nicht anmelden, wenn die Gesamtzahl aller Benutzeranmeldungen größer als die angegebene Zahl ist (diese Begrenzung gilt nicht für Benutzer mit uid=0)
nonewprivs Wert 0 oder 1; bei Einstellung auf 1 wird das Erlangen neuer Privilegien durch Aufruf von prctl(PR_SET_NO_NEW_PRIVS) deaktiviert
priority Priorität, mit der der Benutzerprozess ausgeführt wird (negative Werte erhöhen die Prozesspriorität)
locks maximale Anzahl gesperrter Dateien (Linux 2.4 und höher)
sigpending maximale Anzahl ausstehender Signale (Linux 2.6 und höher)
msgqueue maximaler Speicherverbrauch durch POSIX-Nachrichtenwarteschlangen (Bytes) (Linux 2.6 und höher)
nice maximal zulässige Nice-Priorität (Linux 2.6.12 und höher) Werte: [-20,19]
rtprio maximal zulässige Echtzeitpriorität für nicht privilegierte Prozesse (Linux 2.6.12 und höher)
chroot das Verzeichnis, in das der Benutzer chrootet werden soll
  • Alle Elemente unterstützen die Werte -1, unbegrenzt oder unendlich, die keine Begrenzung anzeigen, mit Ausnahme von priority, nice und nonewprivs. Wenn nofile auf einen dieser Werte gesetzt werden soll, wird es stattdessen auf den Inhalt von /proc/sys/fs/nr_open gesetzt (siehe setrlimit(3)).
  • Wenn eine harte oder weiche Grenze für eine Ressource auf einen gültigen Wert gesetzt wird, der jedoch außerhalb des vom lokalen System unterstützten Bereichs liegt, kann das System die neue Grenze ablehnen oder es kann zu unerwartetem Verhalten kommen. Wenn der erforderliche Kontrollwert verwendet wird, lehnt das Modul die Anmeldung ab, wenn keine Grenze gesetzt werden konnte.
  • Im Allgemeinen haben individuelle Limits Vorrang vor Gruppenlimits. Wenn Sie also keine Limits für die Admin-Gruppe festlegen, aber eines der Mitglieder dieser Gruppe eine Limit-Zeile hat, werden die Limits des Benutzers entsprechend dieser Zeile festgelegt.
  • Beachten Sie außerdem, dass alle Limiteinstellungen pro Anmeldung festgelegt werden. Sie sind weder global noch dauerhaft, sondern bestehen nur für die Dauer der Sitzung. Eine Ausnahme bildet die Option „maxlogin“, die systemweit gilt. Es gibt jedoch einen Wettlauf: Gleichzeitige Anmeldungen werden nicht immer als solche erkannt, sondern nur als eine einzige gezählt.
  • In der Limit-Konfigurationsdatei leitet das Zeichen „#“ einen Kommentar ein – danach wird der Rest der Zeile ignoriert.
  • Das Modul „pam_limits“ meldet Konfigurationsprobleme in seiner Konfigurationsdatei und Fehler über syslog(3).

Anwendung

Dies sind einige Beispielzeilen, die in /etc/security/limits.conf angegeben werden könnten.

*               soft    core            0
root            hard    core            100000
*               hard    nofile          512
@student        hard    nproc           20
@faculty        soft    nproc           20
@faculty        hard    nproc           50
ftp             hard    nproc           0
@student        -       maxlogins       4
@student        -       nonewprivs      1
:123            hard    cpu             5000
@500:           soft    cpu             10000
600:700         hard    locks           10

Konfiguration

Dateien

Datei Beschreibung


Anhang

Siehe auch



Dokumentation

Links

Projekt

Weblinks



TMP

Aufruf

The syntax of the lines is as follows:

<domain> <type> <item> <value>

The fields listed above should be filled as follows:

<domain>

username
groupname with @group syntax. This should not be confused with netgroups.
wildcard * for default entry.
wildcard % for maxlogins limit only, can also be used with %group syntax. If the % wildcard is used alone it is identical to using * with maxsyslogins limit. With a group specified after % it limits the total number of logins of all users that are member of the group.
uid range specified as <min_uid>:<max_uid>. If min_uid is omitted, the match is exact for the max_uid. If max_uid is omitted, all uids greater than or equal min_uid match.
gid range specified as @<min_gid>:<max_gid>. If min_gid is omitted, the match is exact for the max_gid. If max_gid is omitted, all gids greater than or equal min_gid match. For the exact match all groups including the user's supplementary groups are examined. For the range matches only the user's primary group is examined.
gid specified as %:<gid> applicable to maxlogins limit only. It limits the total number of logins of all users that are member of the group with the specified gid.

NOTE: group and wildcard limits are not applied to the root user. To set a limit for the root user, this field must contain the literal username root.

<type>

hard for enforcing hard resource limits. These limits are set by the superuser and enforced by the Kernel. The user cannot raise his requirement

of system resources above such values.

soft for enforcing soft resource limits. These limits are ones that the user can move up or down within the permitted range by any pre-existing

hard limits. The values specified with this token can be thought of as default values, for normal system usage.

- for enforcing both soft and hard resource limits together.

Note, if you specify a type of '-' but neglect to supply the item and value fields then the module will never enforce any limits on the specified user/group und weitere .

<item>

core limits the core file size (KB)
data maximum data size (KB)
fsize maximum filesize (KB)
memlock maximum locked-in-memory address space (KB)
nofile maximum number of open file descriptors
rss maximum resident set size (KB) (Ignored in Linux 2.4.30 and higher)
stack maximum stack size (KB)
cpu maximum CPU time (minutes)
nproc maximum number of processes
as address space limit (KB)
maxlogins maximum number of logins for this user (this limit does not apply to user with uid=0)
maxsyslogins maximum number of all logins on system; user is not allowed to log-in if total number of all user logins is greater than specified number (this limit does not apply to user with uid=0)
nonewprivs value of 0 or 1; if set to 1 disables acquiring new privileges by invoking prctl(PR_SET_NO_NEW_PRIVS)
priority the priority to run user process with (negative values boost process priority)
locks maximum locked files (Linux 2.4 and higher)
sigpending maximum number of pending signals (Linux 2.6 and higher)
msgqueue maximum memory used by POSIX message queues (bytes) (Linux 2.6 and higher)
nice maximum nice priority allowed to raise to (Linux 2.6.12 and higher) values: [-20,19]
rtprio maximum realtime priority allowed for non-privileged processes (Linux 2.6.12 and higher)
chroot the directory to chroot the user to
  • All items support the values -1, unlimited or infinity indicating no limit, except for priority, nice, and nonewprivs. If nofile is to be set to one of these values, it will be set to the contents of /proc/sys/fs/nr_open instead (see setrlimit(3)).
  • If a hard limit or soft limit of a resource is set to a valid value, but outside of the supported range of the local system, the system may reject the new limit or unexpected behavior may occur. If the control value required is used, the module will reject the login if a limit could not be set.
  • In general, individual limits have priority over group limits, so if you impose no limits for admin group, but one of the members in this group have a limits line, the user will have its limits set according to this line.
  • Also, please note that all limit settings are set per login. They are not global, nor are they permanent; existing only for the duration of the session. One exception is the maxlogin option, this one is system wide. But there is a race, concurrent logins at the same time will not always be detect as such but only counted as one.
  • In the limits configuration file, the '#' character introduces a comment - after which the rest of the line is ignored.
  • The pam_limits module does report configuration problems found in its configuration file and errors via syslog(3).