diff options
author | David Zeuthen <davidz@redhat.com> | 2012-04-11 23:05:33 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2012-04-12 10:53:50 -0400 |
commit | 8734e4a16ff220a7af0fd718ba50f92d23c496cf (patch) | |
tree | cb19b50f0ea6659d24ca36e86855751d85537afa /test/name-test | |
parent | 3ad045bb8bd3dc3d4544970a4cdb1f2504981cbd (diff) | |
download | dbus-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 'test/name-test')
-rw-r--r-- | test/name-test/test-pending-call-dispatch.c | 4 | ||||
-rw-r--r-- | test/name-test/test-pending-call-timeout.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/test/name-test/test-pending-call-dispatch.c b/test/name-test/test-pending-call-dispatch.c index 57582d49..c8b5a467 100644 --- a/test/name-test/test-pending-call-dispatch.c +++ b/test/name-test/test-pending-call-dispatch.c @@ -98,9 +98,9 @@ main (int argc, char *argv[]) { long delta; - _dbus_get_current_time (&start_tv_sec, &start_tv_usec); + _dbus_get_monotonic_time (&start_tv_sec, &start_tv_usec); _run_iteration (conn); - _dbus_get_current_time (&end_tv_sec, &end_tv_usec); + _dbus_get_monotonic_time (&end_tv_sec, &end_tv_usec); /* we just care about seconds */ delta = end_tv_sec - start_tv_sec; diff --git a/test/name-test/test-pending-call-timeout.c b/test/name-test/test-pending-call-timeout.c index 381113bd..d051faba 100644 --- a/test/name-test/test-pending-call-timeout.c +++ b/test/name-test/test-pending-call-timeout.c @@ -82,9 +82,9 @@ main (int argc, char *argv[]) { long delta; - _dbus_get_current_time (&start_tv_sec, &start_tv_usec); + _dbus_get_monotonic_time (&start_tv_sec, &start_tv_usec); _run_iteration (conn); - _dbus_get_current_time (&end_tv_sec, &end_tv_usec); + _dbus_get_monotonic_time (&end_tv_sec, &end_tv_usec); /* we just care about seconds */ delta = end_tv_sec - start_tv_sec; |