Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:11.4:Update
dbus-1.937
dbus-1.2.10-fd-limit-backport.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File dbus-1.2.10-fd-limit-backport.patch of Package dbus-1.937
Index: dbus-1.4.1/bus/bus.c =================================================================== --- dbus-1.4.1.orig/bus/bus.c +++ dbus-1.4.1/bus/bus.c @@ -636,6 +636,24 @@ oom: return FALSE; } +static void +raise_file_descriptor_limit (BusContext *context) +{ + + /* I just picked this out of thin air; we need some extra + * descriptors for things like any internal pipes we create, + * inotify, connections to SELinux, etc. + */ + unsigned int arbitrary_extra_fds = 32; + unsigned int limit; + + limit = context->limits.max_completed_connections + + context->limits.max_incomplete_connections + + arbitrary_extra_fds; + + _dbus_request_file_descriptor_limit (limit); +} + static dbus_bool_t process_config_postinit (BusContext *context, BusConfigParser *parser, @@ -644,6 +662,8 @@ process_config_postinit (BusContext DBusHashTable *service_context_table; DBusList *watched_dirs = NULL; + raise_file_descriptor_limit (context); + service_context_table = bus_config_parser_steal_service_context_table (parser); if (!bus_registry_set_service_context_table (context->registry, service_context_table)) Index: dbus-1.4.1/configure.in =================================================================== --- dbus-1.4.1.orig/configure.in +++ dbus-1.4.1/configure.in @@ -534,6 +534,8 @@ fi AC_CHECK_HEADERS(dirent.h) +AC_CHECK_HEADERS(sys/resource.h) + AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)]) AC_CHECK_HEADERS(errno.h) Index: dbus-1.4.1/dbus/dbus-sysdeps.h =================================================================== --- dbus-1.4.1.orig/dbus/dbus-sysdeps.h +++ dbus-1.4.1/dbus/dbus-sysdeps.h @@ -527,6 +527,8 @@ void _dbus_flush_caches (void); const char * _dbus_replace_install_prefix (const char *configure_time_path); +void _dbus_request_file_descriptor_limit (unsigned int limit); + /** @} */ DBUS_END_DECLS Index: dbus-1.4.1/dbus/dbus-sysdeps-util-unix.c =================================================================== --- dbus-1.4.1.orig/dbus/dbus-sysdeps-util-unix.c +++ dbus-1.4.1/dbus/dbus-sysdeps-util-unix.c @@ -42,6 +42,9 @@ #include <errno.h> #include <fcntl.h> #include <sys/stat.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif #include <grp.h> #include <sys/socket.h> #include <dirent.h> @@ -369,6 +372,56 @@ _dbus_change_to_daemon_user (const char } #endif /* !HAVE_LIBAUDIT */ + +/** + * Attempt to ensure that the current process can open + * at least @limit file descriptors. + * + * If @limit is lower than the current, it will not be + * lowered. No error is returned if the request can + * not be satisfied. + * + * @limit Number of file descriptors + */ +void +_dbus_request_file_descriptor_limit (unsigned int limit) +{ +#ifdef HAVE_SETRLIMIT + struct rlimit lim; + struct rlimit target_lim; + unsigned int current_limit; + + /* No point to doing this practically speaking + * if we're not uid 0. We expect the system + * bus to use this before we change UID, and + * the session bus takes the Linux default + * of 1024 for both cur and max. + */ + if (getuid () != 0) + return; + + if (getrlimit (RLIMIT_NOFILE, &lim) < 0) + return; + + if (lim.rlim_cur >= limit) + return; + + /* Ignore "maximum limit", assume we have the "superuser" + * privileges. On Linux this is CAP_SYS_RESOURCE. + */ + target_lim.rlim_cur = target_lim.rlim_max = limit; + /* Also ignore errors; if we fail, we will at least work + * up to whatever limit we had, which seems better than + * just outright aborting. + * + * However, in the future we should probably log this so OS builders + * have a chance to notice any misconfiguration like dbus-daemon + * being started without CAP_SYS_RESOURCE. + */ + setrlimit (RLIMIT_NOFILE, &target_lim); +#endif +} + void _dbus_init_system_log (void) {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor