Giter VIP home page Giter VIP logo

librlimit's Introduction

librlimit

librlimit: rlimit sandbox for any process

DESCRIPTION

librlimit sets up rlimit process restrictions for dynamically linked executables. The restrictions are enforced after the executable has loaded any shared libraries.

The shell ulimit or daemontools softlimit apply to the process lifetime from fork() to exec(). The process typically needs to perform operations such as reading libraries that require requesting file descriptors:

  • fork a subprocess
  • load shared libraries
  • nsswitch: read configuration files

For example:

  • ulimit
$ (ulimit -n 0; ls)
ls: error while loading shared libraries: libselinux.so.1: cannot open shared object file: Error 24
  • softlimit
$ softlimit -o 0 ls
ls: error while loading shared libraries: libselinux.so.1: cannot open shared object file: Error 24
  • librlimit
LD_PRELOAD=librlimit.so RLIMIT_NOFILE=0 ls
ls: cannot open directory '.': Too many open files

EXAMPLES

$ LD_PRELOAD=librlimit.so RLIMIT_FSIZE=0 yes > test
File size limit exceeded (core dumped)

$ LD_PRELOAD=librlimit.so RLIMIT_NPROC=0 sh -c "sleep 60 & sleep 60 & sleep 60 & sleep 60"
sh: 0: Cannot fork

$ LD_PRELOAD=librlimit.so RLIMIT_NOFILE=0 cat
abc
     1  abc

ENVIRONMENT VARIABLES

LIBRLIMIT_OPT : set options for the library behaviour (default: 1)

  0: no options enabled
  1: exit with status 111 if setting rlimit fails
  2: enable debug
  3: exit on failure and debug enabled

Supported resources are platform dependent. See setrlimit(3).

RLIMIT_AS : maximum size of process' virtual memory (address space)

RLIMIT_CORE : maximum size of a core file

RLIMIT_CPU : limit in seconds on CPU time

RLIMIT_DATA : maximum size of the process' data segment

RLIMIT_FSIZE : maximum file size in bytes

RLIMIT_LOCKS : limits the number of flock(2) locks and fcntl(2) leases

RLIMIT_MEMLOCK : maximum number of bytes available to be locked into memory

RLIMIT_MSGQUEUE : maximum of bytes allocated for POSIX message queues

RLIMIT_NICE : limits priority of process

RLIMIT_NOFILE : maximum number of file descriptors

RLIMIT_NPROC : maximum number of processes

RLIMIT_RSS : maximum number of bytes for a process resident set size

RLIMIT_RTPRIO : maximum real-time priority of process

RLIMIT_RTTIME : limit in microseconds for real-time scheduled CPU time

RLIMIT_SIGPENDING : maximum number of queued signals

RLIMIT_STACK : maximum size of process stack

RLIMIT_SBSIZE : maximum size of all socket buffers (FreeBSD)

RLIMIT_VMEM : virtual process size (incl. mmap) (equivalent to RLIMIT_AS) (FreeBSD)

RLIMIT_NPTS : pseudo-terminals (FreeBSD)

RLIMIT_SWAP : swap used (FreeBSD)

RLIMIT_KQUEUES : kqueues allocated (FreeBSD)

RLIMIT_UMTXP : process-shared umtx (FreeBSD)

librlimit's People

Contributors

msantos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

johnsonjh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.