Unexpected gdbus behaviour during PAM authentication

David Llewellyn-Jones david at flypig.co.uk
Sun Jan 15 01:27:20 UTC 2017


On 13/01/17 15:47, Bastien Nocera wrote:
> On Fri, 2017-01-13 at 14:37 +0000, David Llewellyn-Jones wrote:
>>
>> I've been experiencing strange behaviour connecting to the system bus
>> from a pam module. This is on Ubuntu 16.04 using gdbus and gdbus-
>> codegen
>> for both the caller and listening service.
>>

[snip - gdbus details]

>> Does anyone have any suggestion for why this might be happening?
> 
> GDBus's threads and PAM really don't mix. You'll need to either use
> something like dbus-glib, which is single-threaded and sync, move your
> D-Bus code to a small helper you'd talk to over Unix sockets (yeah, I
> know...), or wait until PAM dies.
> 
> FWIW, this problem is one of the reasons why fprintd (and pam_fprintd)
> is written using dbus-glib rather than GDBus.

I've attempted to convert the pam module to use dbus-glib, using your
pam_fprintd.c code as a template (which has been very helpful, thank
you!). Unfortunately I'm still running in to problems.

After removing all of the previous gdbus code and replacing it with the
following dbus-glib code, I now get segfaults occurring.

-------
GError * error = NULL;
DBusGConnection * connection;

connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (connection == NULL) {
  syslog(LOG_ERR, "pam_test: connection error: %s\n", error->message);
  g_clear_error (&error);
}
else {
  dbus_g_connection_unref (connection);
}
-------

Originally I had a more complete set of code following this, but I found
the above was enough to trigger the problem.

Here's the code on github:
https://github.com/llewelld/dbus-pam-test/blob/5940e11d939f587a7c1b42c00a02d0a5cc7dc2c3/src/pam_test.c#L131

and here's the segfault entry from syslog:

Jan 14 23:12:17 Owen kernel: [ 4683.886530] compiz[11249]: segfault at
7f34cd0ac8a0 ip 00007f34f8692908 sp 00007ffe6e955970 error 4 in
libglib-2.0.so.0.4800.1[7f34f8649000+10f000]

Am I doing something wrong? In case it's important, the segfault doesn't
occur the first time the module is run, but consistently when it's
called for a second time. Again, this is all using the Unity lockscreen
on Ubuntu 16.04.

David
-- 
Website: http://www.flypig.co.uk


More information about the dbus mailing list