diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2012-02-17 12:14:39 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-06-22 15:37:42 -0400 |
commit | dd60af1ca6f5887f12ff50532e2fde5f16c9d55b (patch) | |
tree | db6a93b5abc53dad733174eaf188ada0cbc010d2 /src/responder | |
parent | 41fbb0ef19bc4e6d336585a7d6ade968700ebd04 (diff) | |
download | sssd-dd60af1ca6f5887f12ff50532e2fde5f16c9d55b.tar.gz sssd-dd60af1ca6f5887f12ff50532e2fde5f16c9d55b.tar.xz sssd-dd60af1ca6f5887f12ff50532e2fde5f16c9d55b.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
Conflicts:
src/config/SSSDConfig.py
src/config/SSSDConfigTest.py
src/config/etc/sssd.api.conf
Diffstat (limited to 'src/responder')
-rw-r--r-- | src/responder/common/responder_common.c | 19 | ||||
-rw-r--r-- | src/responder/nss/nsssrv.c | 13 | ||||
-rw-r--r-- | src/responder/pam/pamsrv.c | 13 |
3 files changed, 42 insertions, 3 deletions
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 31c2cedc0..bc6f02ae1 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -791,7 +791,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(4, + ("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(7, diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c index cfc6c588f..fafd64edd 100644 --- a/src/responder/nss/nsssrv.c +++ b/src/responder/nss/nsssrv.c @@ -259,6 +259,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx, struct nss_ctx *nctx; int ret, max_retries; int hret; + int fd_limit; nctx = talloc_zero(mem_ctx, struct nss_ctx); if (!nctx) { @@ -317,7 +318,17 @@ int nss_process_init(TALLOC_CTX *mem_ctx, } /* Set up file descriptor limits */ - responder_set_fd_limit(DEFAULT_NSS_FD_LIMIT); + ret = confdb_get_int(nctx->rctx->cdb, nctx->rctx, + CONFDB_NSS_CONF_ENTRY, + CONFDB_SERVICE_FD_LIMIT, + DEFAULT_NSS_FD_LIMIT, + &fd_limit); + if (ret != EOK) { + DEBUG(0, + ("Failed to set up file descriptor limit\n")); + return ret; + } + responder_set_fd_limit(fd_limit); DEBUG(1, ("NSS Initialization complete\n")); diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c index 1bed212ed..9f02e8f0f 100644 --- a/src/responder/pam/pamsrv.c +++ b/src/responder/pam/pamsrv.c @@ -111,6 +111,7 @@ static int pam_process_init(TALLOC_CTX *mem_ctx, struct pam_ctx *pctx; int ret, max_retries; int id_timeout; + int fd_limit; pctx = talloc_zero(mem_ctx, struct pam_ctx); if (!pctx) { @@ -177,7 +178,17 @@ static int pam_process_init(TALLOC_CTX *mem_ctx, } /* Set up file descriptor limits */ - responder_set_fd_limit(DEFAULT_PAM_FD_LIMIT); + ret = confdb_get_int(pctx->rctx->cdb, pctx->rctx, + CONFDB_PAM_CONF_ENTRY, + CONFDB_SERVICE_FD_LIMIT, + DEFAULT_PAM_FD_LIMIT, + &fd_limit); + if (ret != EOK) { + DEBUG(0, + ("Failed to set up file descriptor limit\n")); + return ret; + } + responder_set_fd_limit(fd_limit); ret = EOK; |