<p dir="ltr">If you won't find a solution, you might want to try pam_exec.</p>
<br><div class="gmail_quote"><div dir="ltr">On Sun, Jan 15, 2017, 02:27 David Llewellyn-Jones <<a href="mailto:david@flypig.co.uk">david@flypig.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 13/01/17 15:47, Bastien Nocera wrote:<br class="gmail_msg">
> On Fri, 2017-01-13 at 14:37 +0000, David Llewellyn-Jones wrote:<br class="gmail_msg">
>><br class="gmail_msg">
>> I've been experiencing strange behaviour connecting to the system bus<br class="gmail_msg">
>> from a pam module. This is on Ubuntu 16.04 using gdbus and gdbus-<br class="gmail_msg">
>> codegen<br class="gmail_msg">
>> for both the caller and listening service.<br class="gmail_msg">
>><br class="gmail_msg">
<br class="gmail_msg">
[snip - gdbus details]<br class="gmail_msg">
<br class="gmail_msg">
>> Does anyone have any suggestion for why this might be happening?<br class="gmail_msg">
><br class="gmail_msg">
> GDBus's threads and PAM really don't mix. You'll need to either use<br class="gmail_msg">
> something like dbus-glib, which is single-threaded and sync, move your<br class="gmail_msg">
> D-Bus code to a small helper you'd talk to over Unix sockets (yeah, I<br class="gmail_msg">
> know...), or wait until PAM dies.<br class="gmail_msg">
><br class="gmail_msg">
> FWIW, this problem is one of the reasons why fprintd (and pam_fprintd)<br class="gmail_msg">
> is written using dbus-glib rather than GDBus.<br class="gmail_msg">
<br class="gmail_msg">
I've attempted to convert the pam module to use dbus-glib, using your<br class="gmail_msg">
pam_fprintd.c code as a template (which has been very helpful, thank<br class="gmail_msg">
you!). Unfortunately I'm still running in to problems.<br class="gmail_msg">
<br class="gmail_msg">
After removing all of the previous gdbus code and replacing it with the<br class="gmail_msg">
following dbus-glib code, I now get segfaults occurring.<br class="gmail_msg">
<br class="gmail_msg">
-------<br class="gmail_msg">
GError * error = NULL;<br class="gmail_msg">
DBusGConnection * connection;<br class="gmail_msg">
<br class="gmail_msg">
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);<br class="gmail_msg">
if (connection == NULL) {<br class="gmail_msg">
  syslog(LOG_ERR, "pam_test: connection error: %s\n", error->message);<br class="gmail_msg">
  g_clear_error (&error);<br class="gmail_msg">
}<br class="gmail_msg">
else {<br class="gmail_msg">
  dbus_g_connection_unref (connection);<br class="gmail_msg">
}<br class="gmail_msg">
-------<br class="gmail_msg">
<br class="gmail_msg">
Originally I had a more complete set of code following this, but I found<br class="gmail_msg">
the above was enough to trigger the problem.<br class="gmail_msg">
<br class="gmail_msg">
Here's the code on github:<br class="gmail_msg">
<a href="https://github.com/llewelld/dbus-pam-test/blob/5940e11d939f587a7c1b42c00a02d0a5cc7dc2c3/src/pam_test.c#L131" rel="noreferrer" class="gmail_msg" target="_blank">https://github.com/llewelld/dbus-pam-test/blob/5940e11d939f587a7c1b42c00a02d0a5cc7dc2c3/src/pam_test.c#L131</a><br class="gmail_msg">
<br class="gmail_msg">
and here's the segfault entry from syslog:<br class="gmail_msg">
<br class="gmail_msg">
Jan 14 23:12:17 Owen kernel: [ 4683.886530] compiz[11249]: segfault at<br class="gmail_msg">
7f34cd0ac8a0 ip 00007f34f8692908 sp 00007ffe6e955970 error 4 in<br class="gmail_msg">
libglib-2.0.so.0.4800.1[7f34f8649000+10f000]<br class="gmail_msg">
<br class="gmail_msg">
Am I doing something wrong? In case it's important, the segfault doesn't<br class="gmail_msg">
occur the first time the module is run, but consistently when it's<br class="gmail_msg">
called for a second time. Again, this is all using the Unity lockscreen<br class="gmail_msg">
on Ubuntu 16.04.<br class="gmail_msg">
<br class="gmail_msg">
David<br class="gmail_msg">
--<br class="gmail_msg">
Website: <a href="http://www.flypig.co.uk" rel="noreferrer" class="gmail_msg" target="_blank">http://www.flypig.co.uk</a><br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
dbus mailing list<br class="gmail_msg">
<a href="mailto:dbus@lists.freedesktop.org" class="gmail_msg" target="_blank">dbus@lists.freedesktop.org</a><br class="gmail_msg">
<a href="https://lists.freedesktop.org/mailman/listinfo/dbus" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dbus</a><br class="gmail_msg">
</blockquote></div>