Comment 2 for bug 862559

Revision history for this message
Wolfgang Ullrich (w-ullrich) wrote :

The following code writes this to /var/log/auth.log:

------
... PAM_SERVICE: lightdm.
... Have no PAM_TTY.
... Have now XDisplay: "(null)" and XAuth: "(null)".
------

This is the pam_sm_authenticate function of the PAM module:

<code>

PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) {
    const char *service = NULL;
    char* xdisp = getenv("DISPLAY");
    char* xauth = getenv("XAUTHORITY");

    // Requested service
    pam_get_item(pamh, PAM_SERVICE, (const void **)(const void*)&service);
    if (service != NULL && strlen(service) > 0) {
        syslog(LOG_DEBUG, "PAM_SERVICE: %s.", (const char*)service);
    }

    if (xdisp == NULL) { // Trying to get the xdisplay
        pam_get_item(pamh, PAM_XDISPLAY, (const void **)(const void*)&xdisp);
        if (xdisp == NULL) {
            pam_get_item(pamh, PAM_TTY, (const void **)(const void*)&xdisp);
            if (xdisp == NULL || strlen(xdisp) == 0) {
                syslog(LOG_DEBUG, "Have no PAM_TTY.");
                xdisp = NULL;
            }
            else {
                syslog(LOG_DEBUG, "Have PAM_TTY: %s.", xdisp);
                if(xdisp[0] != ':'){// looks not like a X-Display
                    syslog(LOG_DEBUG, "Have no DISPLAY from PAM_TTY.");
                    xdisp = NULL;
                }
                else{
                    syslog(LOG_DEBUG, "Have DISPLAY %s from PAM_TTY.", xdisp);
                    setenv("DISPLAY", xdisp, -1);
                }
            }
        }
        else {
            syslog(LOG_DEBUG, "Have DISPLAY %s from pam_get_item.", xdisp);
            setenv("DISPLAY", xdisp, -1);
        }
    }
    else
        syslog(LOG_DEBUG, "Have DISPLAY %s from getenv.", xdisp);

    syslog(LOG_DEBUG, "Have now XDisplay: \"%s\" and XAuth: \"%s\".", xdisp, xauth);
}

</code>

This means none of the variables are set. The module cannot display it's widget.