{{tag>Ressource Process Sécurité Linux}} # ulimit Voir aussi : * prlimit Depuis Redhat 6 nous avons : ''/etc/security/limits.d/90-nproc.conf'' ~~~ # Default limit for number of user's processes to prevent # accidental fork bombs. # See rhbz #432903 for reasoning. * soft nproc 1024 root soft nproc unlimited www-data soft nproc unlimited ~~~ Options ulimit : * -H : Hard * -S : Soft * -a : All * -u : Nombre maximal de processus utilisateurs ~~~bash ulimit -a -H ulimit -a -S ~~~ ~~~bash help ulimit ~~~ Voir ~~~bash :(){ :|:& };: ~~~ En cas de dépassement : comment le sait-on ? >> Grsecurity propose un audit des dépassements des "ulimit" Message d'erreur ? Pourquoi ne pas utiliser les cgroups ? ## Core dump Désactiver les cores dumps (Redhat) ''/etc/profile'' ~~~bash # No core files by default ulimit -S -c 0 > /dev/null 2>&1 ~~~ Activer les cores dumps (Redhat) ~~~bash su - ulimit -c unlimited ~~~ ## Notes ~~~bash /bin/bash -c ulimit -S -c 0 >/dev/null 2>&1 ; /usr/local/bin/plop ~~~ ### Temps réel However, for systems with a Linux kernel 2.6.13 or newer, it is possible to allow processes without root privileges to set the real-time scheduling policy. When the Linux PAM module is installed (which is normally the case) you can control the maximum real-time priority for non-privileged processes on a per user or group basis via the /etc/security/limits.conf file. For example, adding the line ~~~ * - rtprio 99 ~~~ ## Outils Appliquez les modifications directement à un processus en cours d'exécution avec **prlimit** ## Python ~~~python import resource print(resource.getrlimit(resource.RLIMIT_NOFILE)[1]) ~~~