diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2017-09-26 13:15:11 +0200 |
---|---|---|
committer | Marco Cecchetti <mrcekets@gmail.com> | 2017-09-26 17:40:31 +0200 |
commit | ee6e64528d0707c2e4612aa233cbf1fa3415fec8 (patch) | |
tree | 5c1fbc0219d34ce06f449163dd2c5119b06023f2 /common | |
parent | Adapt bundled include to core include (diff) | |
download | online-ee6e64528d0707c2e4612aa233cbf1fa3415fec8.tar.gz online-ee6e64528d0707c2e4612aa233cbf1fa3415fec8.zip |
wsd: support for FSIZE and NOFILE system limits
The routine for handling the configuration for the max file size
limit, was wrongly using NOFILE. Now we handle both limits correctly.
Change-Id: Ie8b63617286f66af6d4eb1b35b9e4f4b28f3c2a6
Reviewed-on: https://gerrit.libreoffice.org/42803
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/42811
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
Tested-by: Marco Cecchetti <mrcekets@gmail.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/Seccomp.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/common/Seccomp.cpp b/common/Seccomp.cpp index cf3793e73b..169f295969 100644 --- a/common/Seccomp.cpp +++ b/common/Seccomp.cpp @@ -273,11 +273,28 @@ bool handleSetrlimitCommand(const std::vector<std::string>& tokens) lim = RLIM_INFINITY; rlimit rlim = { lim, lim }; + if (setrlimit(RLIMIT_FSIZE, &rlim) != 0) + LOG_SYS("Failed to set RLIMIT_NOFILE to " << lim << " bytes."); + + if (getrlimit(RLIMIT_FSIZE, &rlim) == 0) + LOG_INF("RLIMIT_FSIZE is " << rlim.rlim_max << " bytes after setting it to " << lim << " bytes."); + else + LOG_SYS("Failed to get RLIMIT_FSIZE."); + + return true; + } + else if (tokens[1] == "limit_num_open_files") + { + rlim_t lim = std::stoi(tokens[2]); + if (lim <= 0) + lim = RLIM_INFINITY; + + rlimit rlim = { lim, lim }; if (setrlimit(RLIMIT_NOFILE, &rlim) != 0) LOG_SYS("Failed to set RLIMIT_NOFILE to " << lim << " bytes."); if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) - LOG_INF("RLIMIT_NOFILE is " << rlim.rlim_max << " bytes after setting it to " << lim << " bytes."); + LOG_INF("RLIMIT_NOFILE is " << rlim.rlim_max << " files after setting it to " << lim << " files."); else LOG_SYS("Failed to get RLIMIT_NOFILE."); |