summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-02-17 11:50:27 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-02-17 14:27:32 -0500
commit1a63155b0797c2b1963424e5c0f5d3a62f8cc7cc (patch)
tree3e2293986461fd191b07b8e2892ed45914d554de
parent3ae9dd80a23168a0451f0d090bd74eaf01fdd951 (diff)
downloadsssd-1a63155b0797c2b1963424e5c0f5d3a62f8cc7cc.tar.gz
sssd-1a63155b0797c2b1963424e5c0f5d3a62f8cc7cc.tar.bz2
sssd-1a63155b0797c2b1963424e5c0f5d3a62f8cc7cc.zip
RESPONDERS: Allow increasing the file-descriptor limit
This patch will increase the file descriptor limit to 8k or the limits.conf maximum, whichever is lesser. https://fedorahosted.org/sssd/ticket/1197
-rw-r--r--src/responder/common/responder.h3
-rw-r--r--src/responder/common/responder_common.c36
-rw-r--r--src/responder/nss/nsssrv.c4
-rw-r--r--src/responder/pam/pamsrv.c5
4 files changed, 48 insertions, 0 deletions
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
index 48678ff9..619ae46e 100644
--- a/src/responder/common/responder.h
+++ b/src/responder/common/responder.h
@@ -25,6 +25,7 @@
#include <stdint.h>
#include <sys/un.h>
#include <pcre.h>
+#include <sys/resource.h>
#include "config.h"
#include "talloc.h"
#include "tevent.h"
@@ -266,4 +267,6 @@ sss_dp_get_account_recv(TALLOC_CTX *mem_ctx,
bool sss_utf8_check(const uint8_t *s, size_t n);
+void responder_set_fd_limit(rlim_t fd_limit);
+
#endif /* __SSS_RESPONDER_H__ */
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index a48ac556..94a9fdb6 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -648,3 +648,39 @@ int responder_logrotate(DBusMessage *message,
return monitor_common_pong(message, conn);
}
+
+void responder_set_fd_limit(rlim_t fd_limit)
+{
+ struct rlimit current_limit, new_limit;
+ int limret;
+
+ /* First determine the maximum hard limit */
+ limret = getrlimit(RLIMIT_NOFILE, &current_limit);
+ if (limret == 0) {
+ DEBUG(SSSDBG_TRACE_INTERNAL,
+ ("Current fd limit: [%d]\n",
+ current_limit.rlim_cur));
+ /* Choose the lesser of the requested and the hard limit */
+ if (current_limit.rlim_max < fd_limit) {
+ new_limit.rlim_cur = current_limit.rlim_max;
+ } else {
+ new_limit.rlim_cur = fd_limit;
+ }
+ new_limit.rlim_max = current_limit.rlim_max;
+
+ limret = setrlimit(RLIMIT_NOFILE, &new_limit);
+ if (limret == 0) {
+ DEBUG(SSSDBG_CONF_SETTINGS,
+ ("Maximum file descriptors set to [%d]\n",
+ new_limit.rlim_cur));
+ } else {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Could not set new fd limits. Proceeding with [%d]\n",
+ current_limit.rlim_cur));
+ }
+ } else {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Could not determine fd limits. "
+ "Proceeding with system values\n"));
+ }
+}
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index a85695b0..3c23f1bf 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -45,6 +45,7 @@
#include "sbus/sbus_client.h"
#define DEFAULT_PWFIELD "*"
+#define DEFAULT_NSS_FD_LIMIT 8192
#define SHELL_REALLOC_INCREMENT 5
#define SHELL_REALLOC_MAX 50
@@ -307,6 +308,9 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
return EIO;
}
+ /* Set up file descriptor limits */
+ responder_set_fd_limit(DEFAULT_NSS_FD_LIMIT);
+
DEBUG(1, ("NSS Initialization complete\n"));
return EOK;
diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c
index be459b11..2786fe4e 100644
--- a/src/responder/pam/pamsrv.c
+++ b/src/responder/pam/pamsrv.c
@@ -44,6 +44,8 @@
#include "responder/pam/pamsrv.h"
#include "responder/common/negcache.h"
+#define DEFAULT_PAM_FD_LIMIT 8192
+
#define SSS_PAM_SBUS_SERVICE_VERSION 0x0001
#define SSS_PAM_SBUS_SERVICE_NAME "pam"
@@ -183,6 +185,9 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
goto done;
}
+ /* Set up file descriptor limits */
+ responder_set_fd_limit(DEFAULT_PAM_FD_LIMIT);
+
ret = EOK;
done: