summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDariusz Gadomski <dariusz.gadomski@canonical.com>2015-11-10 10:52:02 +0100
committerMiloslav Trmač <mitr@redhat.com>2015-11-18 23:30:42 +0100
commit10597322eccc320f9053821750ae9af51e918d74 (patch)
treeeb625efe2a9486d51f5b5f766ff32c017935baa7
parent1eb34277febcb281c1840af738aad3a2fdd9c28d (diff)
downloadpolkit-10597322eccc320f9053821750ae9af51e918d74.tar.gz
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. https://bugs.freedesktop.org/show_bug.cgi?id=92886
-rw-r--r--src/polkitagent/polkitagenthelper-pam.c13
1 files 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;