From 2da37508fe325df49c278ff7ddfe0ab79443453e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Jul 2016 16:35:55 +0100 Subject: [PATCH] WiP: make uid 0 immune to pending_fd_timeout --- bus/connection.c | 14 ++++++++++++++ test/dbus-daemon.c | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/bus/connection.c b/bus/connection.c index abcc50b..73bf9bd 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -672,10 +672,24 @@ pending_unix_fds_timeout_cb (void *data) { DBusConnection *connection = data; BusConnectionData *d = BUS_CONNECTION_DATA (connection); + unsigned long uid; int limit; _dbus_assert (d != NULL); limit = bus_context_get_pending_fd_timeout (d->connections->context); + + if (dbus_connection_get_unix_user (connection, &uid) && uid == 0) + { + bus_context_log (d->connections->context, DBUS_SYSTEM_LOG_WARNING, + "Connection \"%s\" (%s) has had Unix fds pending for " + "too long (pending_fd_timeout=%dms); tolerating it, " + "because it has uid 0", + d->name != NULL ? d->name : "(null)", + bus_connection_get_loginfo (connection), + limit); + return TRUE; + } + bus_context_log (d->connections->context, DBUS_SYSTEM_LOG_WARNING, "Connection \"%s\" (%s) has had Unix fds pending for too long, " "closing it (pending_fd_timeout=%d)", diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index c11cb2a..5642346 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -1008,6 +1008,12 @@ test_pending_fd_timeout (Fixture *f, if (f->skip) return; + if (getuid () == 0) + { + g_test_skip ("Cannot test, uid 0 is immune to this limit"); + return; + } + add_echo_filter (f); have_mem = dbus_connection_add_filter (f->left_conn, wait_for_disconnected_cb, -- 2.8.1