Subject: Re: bug#71969: [PATCH] Support interactive D-Bus authentication

From: Michael Albinus <[email-masked]>
Date: Sat, 06 Jul 2024 17:24:45 +0200

Eli Zaretskii <[email-masked]> writes:

Hi Eli,

>> > Furthermore, does exist dbus_message_set_allow_interactive_authorization
>> > "since ever"? Or shall we check for the existence in configure.ac, like
>> > we do it with other dbus_* functions?
>>
>> I've just checked the dbus git repo.
>> dbus_message_set_allow_interactive_authorization was added in
>> D-Bus 1.8.10, so we need a check in configure.ac.
>
> Is this really a build-time condition, not a run-time condition?  Can
> we know in advance which version of D-Bus will be used at run time?

Well, we must call this function, or not, in dbusbind.c. Of course it
depends on the libdbus-1.so version whether it is available at
runtime. But we must know already at build time, whether the function is
offered via /usr/include/dbus-1.0/dbus/dbus-message.h. Otherwise, the
function call would result in a compiler error.

So it is a build time dependency. We do a similar check for other D-Bus
functions in configure.ac, see this snippet:

--8<---------------cut here---------------start------------->8---
     AC_CHECK_FUNCS([dbus_watch_get_unix_fd \
		    dbus_type_is_valid \
		    dbus_validate_bus_name \
                    dbus_validate_path \
		    dbus_validate_interface \
		    dbus_validate_member])
--8<---------------cut here---------------end--------------->8---

And in dbusbind.c, we have then code like

--8<---------------cut here---------------start------------->8---
#if HAVE_DBUS_WATCH_GET_UNIX_FD
  /* TODO: Reverse these on w32, which prefers the opposite.  */
  int fd = dbus_watch_get_unix_fd (watch);
  if (fd == -1)
    fd = dbus_watch_get_socket (watch);
#else
  int fd = dbus_watch_get_fd (watch);
#endif
--8<---------------cut here---------------end--------------->8---

Of course there is the risk, that Emacs is compiled with a function call
(based on an include file), which does not exist at runtime, because the
Emacs program runs somewhere else. OTOH, D-Bus 1.8.10 was tagged in the
D-Bus git on "Thu Nov 6 15:39:51 2014 +0000". The likelihood, that we run
into problems, is small, and the check in configure.ac is just "to be
sure".

Best regards, Michael.