RLIMITs: add support for generating limits.d files

This commit implements generating /etc/security/limits.d/20-pw-defaults.conf and
/etc/security/limits.d/25-pw-rlimits.conf files. The numbering is arbitrary and
may very well warrant being in the reverse order, however `man 5 limits.conf`
does not appear to specify the parsing order or even say exactly how multiples
matches will resolve, so the value can be adjusted later, if required.

The actual limit values, the match rule and even whether each file is to be
installed can be changed via the build system before compilation. Likewise
the files can be modified or (re)moved during distro package building phase.

The 20-pw-defaults.conf should only be installed on legacy systems lacking both
a modern kernel and up to date systemd, because all it does is set the current
Linux default. Accordingly its not installed by default.

Signed-off-by: Niklāvs Koļesņikovs <89q1r14hd@relay.firefox.com>
This commit is contained in:
Niklāvs Koļesņikovs 2023-02-07 00:26:03 +02:00
parent d082ec0809
commit 5e0bfa0beb
No known key found for this signature in database
GPG key ID: 8A45FF71F7C7210A
5 changed files with 85 additions and 0 deletions

View file

@ -285,3 +285,36 @@ option('compress-offload',
description: 'Enable ALSA Compress-Offload support',
type: 'feature',
value: 'disabled')
option('pam-defaults-install',
description: 'Install limits.d file modifying defaults for all PAM users. Only for old kernels/systemd!',
type: 'boolean',
value: 'false')
option('pam-memlock-default',
description : 'The default memlock value for any PAM user in kilobytes. Multiples of 64 recommended.',
type : 'integer',
min: 640,
value: 8192)
option('rlimits-install',
description: 'Install PAM limits.d file. Voids all following rlimits-* options, if false',
type: 'boolean',
value: 'true')
option('rlimits-match',
description : 'PAM match rule for the generated limits.d file. @<name> denotes matching a group.',
type : 'string',
value: '@pipewire')
option('rlimits-rtprio',
description : 'RR and FIFO scheduler priority permitted for realtime threads of the matching user(s)',
type : 'integer',
min: 11,
max: 99,
value: 95)
option('rlimits-memlock',
description : 'kB of memory each process of the user matched by the rule can lock. Can be unlimited .',
type : 'string',
value: '4194304')
option('rlimits-nice',
description : 'Not niceness permitted for non-realtime threads of the matching user(s)',
type : 'integer',
min: -20,
max: -1,
value: -19)