summaryrefslogtreecommitdiff
path: root/bus/connection.c
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2012-04-11 23:05:33 -0400
committerDavid Zeuthen <davidz@redhat.com>2012-04-12 10:53:50 -0400
commit8734e4a16ff220a7af0fd718ba50f92d23c496cf (patch)
treecb19b50f0ea6659d24ca36e86855751d85537afa /bus/connection.c
parent3ad045bb8bd3dc3d4544970a4cdb1f2504981cbd (diff)
downloaddbus-8734e4a16ff220a7af0fd718ba50f92d23c496cf.tar.gz
Avoid using monotonic time in the DBUS_COOKIE_SHA1 authentication method
When libdbus-1 moved to using monotonic time support for the DBUS_COOKIE_SHA1 authentication was broken, in particular interoperability with non-libdbus-1 implementations such as GDBus. The problem is that if monotonic clocks are available in the OS, _dbus_get_current_time() will not return the number of seconds since the Epoch so using it for DBUS_COOKIE_SHA1 will violate the D-Bus specification. If both peers are using libdbus-1 it's not a problem since both ends will use the wrong time and thus agree. However, if the other end is another implementation and following the spec it will not work. First, we change _dbus_get_current_time() back so it always returns time since the Epoch and we then rename it _dbus_get_real_time() to make this clear. We then introduce _dbus_get_monotonic_time() and carefully make all current users of _dbus_get_current_time() use it, if applicable. During this audit, one of the callers, _dbus_generate_uuid(), was currently using monotonic time but it was decided to make it use real time instead. Signed-off-by: David Zeuthen <davidz@redhat.com> Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48580
Diffstat (limited to 'bus/connection.c')
-rw-r--r--bus/connection.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/bus/connection.c b/bus/connection.c
index 97e5f64b..d69758c9 100644
--- a/bus/connection.c
+++ b/bus/connection.c
@@ -606,8 +606,8 @@ bus_connections_setup_connection (BusConnections *connections,
d->connections = connections;
d->connection = connection;
- _dbus_get_current_time (&d->connection_tv_sec,
- &d->connection_tv_usec);
+ _dbus_get_monotonic_time (&d->connection_tv_sec,
+ &d->connection_tv_usec);
_dbus_assert (connection_data_slot >= 0);
@@ -776,7 +776,7 @@ bus_connections_expire_incomplete (BusConnections *connections)
DBusList *link;
int auth_timeout;
- _dbus_get_current_time (&tv_sec, &tv_usec);
+ _dbus_get_monotonic_time (&tv_sec, &tv_usec);
auth_timeout = bus_context_get_auth_timeout (connections->context);
link = _dbus_list_get_first_link (&connections->incomplete);
@@ -1772,8 +1772,8 @@ bus_connections_expect_reply (BusConnections *connections,
cprd->pending = pending;
cprd->connections = connections;
- _dbus_get_current_time (&pending->expire_item.added_tv_sec,
- &pending->expire_item.added_tv_usec);
+ _dbus_get_monotonic_time (&pending->expire_item.added_tv_sec,
+ &pending->expire_item.added_tv_usec);
_dbus_verbose ("Added pending reply %p, replier %p receiver %p serial %u\n",
pending,