diff -Nru policykit-1-0.105/debian/changelog policykit-1-0.105/debian/changelog --- policykit-1-0.105/debian/changelog 2015-03-03 13:48:59.000000000 +0000 +++ policykit-1-0.105/debian/changelog 2015-11-23 09:31:35.000000000 +0000 @@ -1,3 +1,9 @@ +policykit-1 (0.105-4ubuntu3.14.04.1) trusty; urgency=medium + + * Fix handling of multi-line helper output. (LP: #1510824) + + -- Dariusz Gadomski Fri, 20 Nov 2015 15:36:30 +0100 + policykit-1 (0.105-4ubuntu2.14.04.1) trusty; urgency=medium * debian/patches/fix_memleak.patch: diff -Nru policykit-1-0.105/debian/patches/escape-helper-output.patch policykit-1-0.105/debian/patches/escape-helper-output.patch --- policykit-1-0.105/debian/patches/escape-helper-output.patch 1970-01-01 00:00:00.000000000 +0000 +++ policykit-1-0.105/debian/patches/escape-helper-output.patch 2015-11-23 09:31:35.000000000 +0000 @@ -0,0 +1,141 @@ +Description: Escape helper output to handle multiline messages + Some pam modules produce multiline messages which caused errors in + PolkitAgentSession as the subsequent lines were interpreted as separate + messages unrecognized by the authenticator. Escaping every message allows + to avoid such behaviour. + . + policykit-1 (0.105-4ubuntu2.14.04.2) trusty; urgency=medium + . + * Fix handling of multi-line helper output. (LP: #1510824) +Description: + TODO: Put a short summary on the line above and replace this paragraph + with a longer explanation of this change. Complete the meta-information + with other relevant fields (see below for details). To make it easier, the + information below has been extracted from the changelog. Adjust it or drop + it. + . + +--- policykit-1-0.105.orig/src/polkitagent/polkitagenthelper-pam.c ++++ policykit-1-0.105/src/polkitagent/polkitagenthelper-pam.c +@@ -39,25 +39,35 @@ static void + send_to_helper (const gchar *str1, + const gchar *str2) + { ++ char *escaped; ++ char *tmp2; ++ size_t len2; ++ ++ tmp2 = g_strdup(str2); ++ len2 = strlen(tmp2); + #ifdef PAH_DEBUG +- fprintf (stderr, "polkit-agent-helper-1: writing `%s' to stdout\n", str1); ++ fprintf (stderr, "polkit-agent-helper-1: writing `%s ' to stdout\n", str1); + #endif /* PAH_DEBUG */ +- fprintf (stdout, "%s", str1); ++ fprintf (stdout, "%s ", str1); ++ ++ if (len2 > 0 && tmp2[len2 - 1] == '\n') ++ tmp2[len2 - 1] = '\0'; ++ escaped = g_strescape (tmp2, NULL); + #ifdef PAH_DEBUG +- fprintf (stderr, "polkit-agent-helper-1: writing `%s' to stdout\n", str2); ++ fprintf (stderr, "polkit-agent-helper-1: writing `%s' to stdout\n", escaped); + #endif /* PAH_DEBUG */ +- fprintf (stdout, "%s", str2); +- if (strlen (str2) > 0 && str2[strlen (str2) - 1] != '\n') +- { ++ fprintf (stdout, "%s", escaped); + #ifdef PAH_DEBUG +- fprintf (stderr, "polkit-agent-helper-1: writing newline to stdout\n"); ++ fprintf (stderr, "polkit-agent-helper-1: writing newline to stdout\n"); + #endif /* PAH_DEBUG */ +- fputc ('\n', stdout); +- } ++ fputc ('\n', stdout); + #ifdef PAH_DEBUG + fprintf (stderr, "polkit-agent-helper-1: flushing stdout\n"); + #endif /* PAH_DEBUG */ + fflush (stdout); ++ ++ g_free (escaped); ++ g_free (tmp2); + } + + int +@@ -89,7 +99,7 @@ main (int argc, char *argv[]) + + /* Special-case a very common error triggered in jhbuild setups */ + s = g_strdup_printf ("Incorrect permissions on %s (needs to be setuid root)", argv[0]); +- send_to_helper ("PAM_ERROR_MSG ", s); ++ send_to_helper ("PAM_ERROR_MSG", s); + g_free (s); + goto error; + } +@@ -226,7 +236,6 @@ conversation_function (int n, const stru + struct pam_response *aresp; + char buf[PAM_MAX_RESP_SIZE]; + int i; +- gchar *escaped = NULL; + + data = data; + if (n <= 0 || n > PAM_MAX_NUM_MSG) +@@ -243,35 +252,13 @@ conversation_function (int n, const stru + { + + case PAM_PROMPT_ECHO_OFF: +-#ifdef PAH_DEBUG +- fprintf (stderr, "polkit-agent-helper-1: writing `PAM_PROMPT_ECHO_OFF ' to stdout\n"); +-#endif /* PAH_DEBUG */ +- fprintf (stdout, "PAM_PROMPT_ECHO_OFF "); ++ send_to_helper ("PAM_PROMPT_ECHO_OFF", msg[i]->msg); + goto conv1; + + case PAM_PROMPT_ECHO_ON: +-#ifdef PAH_DEBUG +- fprintf (stderr, "polkit-agent-helper-1: writing `PAM_PROMPT_ECHO_ON ' to stdout\n"); +-#endif /* PAH_DEBUG */ +- fprintf (stdout, "PAM_PROMPT_ECHO_ON "); +- conv1: +-#ifdef PAH_DEBUG +- fprintf (stderr, "polkit-agent-helper-1: writing `%s' to stdout\n", msg[i]->msg); +-#endif /* PAH_DEBUG */ +- if (strlen (msg[i]->msg) > 0 && msg[i]->msg[strlen (msg[i]->msg) - 1] == '\n') +- msg[i]->msg[strlen (msg[i]->msg) - 1] == '\0'; +- escaped = g_strescape (msg[i]->msg, NULL); +- fputs (escaped, stdout); +- g_free (escaped); +-#ifdef PAH_DEBUG +- fprintf (stderr, "polkit-agent-helper-1: writing newline to stdout\n"); +-#endif /* PAH_DEBUG */ +- fputc ('\n', stdout); +-#ifdef PAH_DEBUG +- fprintf (stderr, "polkit-agent-helper-1: flushing stdout\n"); +-#endif /* PAH_DEBUG */ +- fflush (stdout); ++ send_to_helper ("PAM_PROMPT_ECHO_ON", msg[i]->msg); + ++ conv1: + if (fgets (buf, sizeof buf, stdin) == NULL) + goto error; + +@@ -285,17 +272,11 @@ conversation_function (int n, const stru + break; + + case PAM_ERROR_MSG: +- fprintf (stdout, "PAM_ERROR_MSG "); +- goto conv2; ++ send_to_helper ("PAM_ERROR_MSG", msg[i]->msg); ++ break; + + 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); +- fflush (stdout); ++ send_to_helper ("PAM_TEXT_INFO", msg[i]->msg); + break; + + default: diff -Nru policykit-1-0.105/debian/patches/series policykit-1-0.105/debian/patches/series --- policykit-1-0.105/debian/patches/series 2015-03-03 13:48:39.000000000 +0000 +++ policykit-1-0.105/debian/patches/series 2015-11-23 09:31:35.000000000 +0000 @@ -10,3 +10,4 @@ 09_pam_environment.patch git_type_registration.patch fix_memleak.patch +escape-helper-output.patch