diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2012-03-15 12:51:11 +1100 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2012-03-15 12:51:11 +1100 |
commit | 27b4357690f0cb6d6bf1c3501f92c8e2a38f8189 (patch) | |
tree | 21a012e8da6181b75669a9a620a2c7c9dc58bfa4 /src | |
parent | 016023a0fb8ec4ae377373a84be5bedd84832ee0 (diff) | |
download | lightdm-27b4357690f0cb6d6bf1c3501f92c8e2a38f8189.tar.gz |
Handle PAM interactions that have more than one message in one callback. Based on a patch from Ulrich Müller
Diffstat (limited to 'src')
-rw-r--r-- | src/session-child.c | 6 | ||||
-rw-r--r-- | src/session.c | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/session-child.c b/src/session-child.c index 7eaa645c..0177c65e 100644 --- a/src/session-child.c +++ b/src/session-child.c @@ -89,6 +89,7 @@ pam_conv_cb (int msg_length, const struct pam_message **msg, struct pam_response { int i, error; gboolean auth_complete = FALSE; + struct pam_response *response; gchar *username = NULL; /* Cancel authentication if requiring input */ @@ -119,17 +120,18 @@ pam_conv_cb (int msg_length, const struct pam_message **msg, struct pam_response } /* Get response */ - *resp = calloc (msg_length, sizeof (struct pam_response)); read_data (&error, sizeof (error)); if (error != PAM_SUCCESS) return error; + response = calloc (msg_length, sizeof (struct pam_response)); for (i = 0; i < msg_length; i++) { - struct pam_response *r = resp[i]; + struct pam_response *r = &response[i]; r->resp = read_string (); read_data (&r->resp_retcode, sizeof (r->resp_retcode)); } + *resp = response; return PAM_SUCCESS; } diff --git a/src/session.c b/src/session.c index c2b4e7ad..473ef92a 100644 --- a/src/session.c +++ b/src/session.c @@ -424,14 +424,14 @@ session_get_console_kit_cookie (Session *session) void session_respond (Session *session, struct pam_response *response) { + int error = PAM_SUCCESS; int i; g_return_if_fail (session != NULL); + write_data (session, &error, sizeof (error)); for (i = 0; i < session->priv->messages_length; i++) { - int error = PAM_SUCCESS; - write_data (session, &error, sizeof (error)); write_string (session, response[i].resp); write_data (session, &response[i].resp_retcode, sizeof (response[i].resp_retcode)); } |