diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2012-02-17 12:14:39 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-02-17 14:27:32 -0500 |
commit | 457927f4210a0c41289521d55617b6d6bb6a46e0 (patch) | |
tree | 39a29f3e1c86d74602eaece4bf146bf3672925dc /src/responder/common | |
parent | 1a63155b0797c2b1963424e5c0f5d3a62f8cc7cc (diff) | |
download | sssd-457927f4210a0c41289521d55617b6d6bb6a46e0.tar.gz sssd-457927f4210a0c41289521d55617b6d6bb6a46e0.tar.xz sssd-457927f4210a0c41289521d55617b6d6bb6a46e0.zip |
RESPONDERS: Make the fd_limit setting configurable
This code will now attempt first to see if it has privilege to set
the value as specified, and if not it will fall back to the
previous behavior. So on systems with the CAP_SYS_RESOURCE
capability granted to SSSD, it will be able to ignore the
limits.conf hard limit.
https://fedorahosted.org/sssd/ticket/1197
Diffstat (limited to 'src/responder/common')
-rw-r--r-- | src/responder/common/responder_common.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 94a9fdb63..a9b5d56b0 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -654,7 +654,24 @@ void responder_set_fd_limit(rlim_t fd_limit) struct rlimit current_limit, new_limit; int limret; - /* First determine the maximum hard limit */ + /* First, let's see if we have permission to just set + * the value as-is. + */ + new_limit.rlim_cur = fd_limit; + new_limit.rlim_max = fd_limit; + limret = setrlimit(RLIMIT_NOFILE, &new_limit); + if (limret == 0) { + DEBUG(SSSDBG_CONF_SETTINGS, + ("Maximum file descriptors set to [%d]\n", + new_limit.rlim_cur)); + return; + } + + /* We couldn't set the soft and hard limits to this + * value. Let's see how high we CAN set it. + */ + + /* Determine the maximum hard limit */ limret = getrlimit(RLIMIT_NOFILE, ¤t_limit); if (limret == 0) { DEBUG(SSSDBG_TRACE_INTERNAL, |