Fix confusion between "is it authenticated?" and "try to authenticate"
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 22 Aug 2013 22:43:02 +0000 (00:43 +0200)
committerRalf Habacker <ralf.habacker@freenet.de>
Thu, 22 Aug 2013 22:45:11 +0000 (00:45 +0200)
commit36bb2125d1dbca0ee30fbe29090c4a6a7be37854
tree9d1c3d9c0c1ba305666d6a0aed8e689bab946fc1
parent1809c7ad2a72b7186bbff0180aaae72337055829
Fix confusion between "is it authenticated?" and "try to authenticate"

Historically, _dbus_transport_get_is_authenticated() has had the
side-effect of trying to advance the authentication state machine (if
there's enough buffered input to do so). This seems an inappropriate
activity for what looks like a simple getter.

Split it into _dbus_transport_try_to_authenticate (which does what it
always used to do) and _dbus_transport_peek_is_authenticated (which
is the simple getter version).

To minimize the difference in behaviour for the stable branch of D-Bus,
I've only used _dbus_transport_peek_is_authenticated where it was used
in an assertion, which should clearly not have side effects (and I've
checked that the asserting function cannot be called until both
authentication and authorization have completed). Replacing most of the
calls to get_is_authenticated with try_to_authenticate is a possible
piece of future work.

Based on patches from Cosimo Alfarano, who noticed this
assertion-with-side-effects.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
https://bugs.freedesktop.org/show_bug.cgi?id=39720
Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.com>
dbus/dbus-connection.c
dbus/dbus-transport-protected.h
dbus/dbus-transport-socket.c
dbus/dbus-transport.c
dbus/dbus-transport.h