From ca789990246bab84bd8d3347177a7493c27a689d Mon Sep 17 00:00:00 2001 From: Dariusz Gadomski Date: Tue, 10 Nov 2015 10:52:02 +0100 Subject: [PATCH] Fix multi-line pam text info. There are pam modules (e.g. pam_vas) that may attempt to display multi-line PAM_TEXT_INFO messages. Polkit was interpreting the lines after the first one as a separate message that was not recognized causing the authorization to fail. Escaping these strings and unescaping them fixes the issue. --- src/polkitagent/polkitagenthelper-pam.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/polkitagent/polkitagenthelper-pam.c b/src/polkitagent/polkitagenthelper-pam.c index 19062aa..063d656 100644 --- a/src/polkitagent/polkitagenthelper-pam.c +++ b/src/polkitagent/polkitagenthelper-pam.c @@ -302,10 +302,15 @@ conversation_function (int n, const struct pam_message **msg, struct pam_respons case PAM_TEXT_INFO: fprintf (stdout, "PAM_TEXT_INFO "); conv2: - fputs (msg[i]->msg, stdout); - if (strlen (msg[i]->msg) > 0 && - msg[i]->msg[strlen (msg[i]->msg) - 1] != '\n') - fputc ('\n', stdout); + tmp = g_strdup (msg[i]->msg); + len = strlen (tmp); + if (len > 0 && tmp[len - 1] == '\n') + tmp[len - 1] = '\0'; + escaped = g_strescape (tmp, NULL); + g_free (tmp); + fputs (escaped, stdout); + g_free (escaped); + fputc ('\n', stdout); fflush (stdout); break; -- 1.9.1