summaryrefslogtreecommitdiffstats
path: root/patches/polkit-0.105/0034-0.114-Fix-multi-line-pam-text-info.patch
blob: 5c51de5a78c6bd63e0a87709ae69aaa53ad08dfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From: Dariusz Gadomski <dariusz.gadomski@canonical.com>
Date: Tue, 10 Nov 2015 10:52:02 +0100
Subject: [PATCH] 0.114: 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.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92886
Origin: upstream, 0.114, commit:10597322eccc320f9053821750ae9af51e918d74

Imported from policykit-1_0.105-25.debian.tar.xz

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 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 19062aa8d0da..063d656dcbef 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;