kov changed libgksu/trunk/ChangeLog, libgksu/trunk/libgksu/libgksu.c
Gustavo Noronha
kov at costa.debian.org
Thu Sep 7 18:10:37 UTC 2006
Mensagem de log:
ignore lines with some constraints while waiting for "gksu: waiting"
-----
Modified: libgksu/trunk/ChangeLog
===================================================================
--- libgksu/trunk/ChangeLog 2006-09-03 23:59:10 UTC (rev 716)
+++ libgksu/trunk/ChangeLog 2006-09-07 18:10:36 UTC (rev 717)
@@ -1,3 +1,12 @@
+2006-09-07 Gustavo Noronha Silva <kov at debian.org>
+
+ * libgksu/libgksu.c:
+ - have gksu ignore lines coming from the process 'till it is able
+ to find the gksu: waiting line; this is done observing some
+ time and size constraints, though, so we won't end up in an infinite
+ loop; this addresses #17139; libpam-mount should now work happily with
+ debug on
+
2006-09-02 Gustavo Noronha Silva <kov at debian.org>
* configure.ac:
Modified: libgksu/trunk/libgksu/libgksu.c
===================================================================
--- libgksu/trunk/libgksu/libgksu.c 2006-09-03 23:59:10 UTC (rev 716)
+++ libgksu/trunk/libgksu/libgksu.c 2006-09-07 18:10:36 UTC (rev 717)
@@ -1898,93 +1898,120 @@
fprintf (stderr, "DEBUG (run:post-after-pass) buf: -%s-\n", buf);
}
- if (!strncmp (buf, "su", 2))
+ FD_ZERO (&rfds);
+ FD_SET (fdpty, &rfds);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ int loop_count = 0;
+ while (TRUE)
{
- gchar **strings;
+ int retval = 0;
- if (password)
+ if (!strncmp (buf, "su", 2))
{
- nullify_password (password);
- unset_gnome_keyring_password (context);
- }
+ gchar **strings;
- strings = g_strsplit (buf, ":", 2);
- if (strings[1] && !strncmp (strings[1], " Authentication failure", 23))
- g_set_error (error, gksu_quark,
- GKSU_ERROR_WRONGPASS,
- _("Wrong password."));
- g_strfreev (strings);
+ if (password)
+ {
+ nullify_password (password);
+ unset_gnome_keyring_password (context);
+ }
- if (context->debug)
- fprintf (stderr, "DEBUG (auth_failed) buf: -%s-\n", buf);
- }
- else if (!strncmp (buf, "gksu: waiting", 13))
- {
- gchar *line;
+ strings = g_strsplit (buf, ":", 2);
+ if (strings[1] && !strncmp (strings[1], " Authentication failure", 23))
+ g_set_error (error, gksu_quark,
+ GKSU_ERROR_WRONGPASS,
+ _("Wrong password."));
+ g_strfreev (strings);
- if (password)
+ if (context->debug)
+ fprintf (stderr, "DEBUG (auth_failed) buf: -%s-\n", buf);
+
+ break;
+ }
+ else if (!strncmp (buf, "gksu: waiting", 13))
{
- set_gnome_keyring_password (context, password);
- nullify_password (password);
- }
+ gchar *line;
- if (context->debug)
- fprintf (stderr, "DEBUG (gksu: waiting) buf: -%s-\n", buf);
+ if (password)
+ {
+ set_gnome_keyring_password (context, password);
+ nullify_password (password);
+ }
- line = g_strdup_printf ("gksu-run: %s\n", context->display);
- write (fdpty, line, strlen(line));
- g_free (line);
+ if (context->debug)
+ fprintf (stderr, "DEBUG (gksu: waiting) buf: -%s-\n", buf);
- line = g_strdup_printf ("gksu-run: %s\n", context->xauth);
- write (fdpty, line, strlen(line));
- g_free (line);
+ line = g_strdup_printf ("gksu-run: %s\n", context->display);
+ write (fdpty, line, strlen(line));
+ g_free (line);
- tcdrain (fdpty);
+ line = g_strdup_printf ("gksu-run: %s\n", context->xauth);
+ write (fdpty, line, strlen(line));
+ g_free (line);
- bzero (buf, 256);
- read (fdpty, buf, 255);
- }
- else
- {
- gchar *emsg = NULL;
- gchar *converted_str = NULL;
- GError *converr = NULL;
+ tcdrain (fdpty);
- if (password)
- nullify_password (password);
+ bzero (buf, 256);
+ read (fdpty, buf, 255);
- converted_str = g_locale_to_utf8 (buf, -1, NULL, NULL, &converr);
- if (converr)
+ break;
+ }
+
+ retval = select (fdpty + 1, &rfds, NULL, NULL, &tv);
+ if ((loop_count > 50) || (!retval))
{
- g_warning (_("Failed to communicate with "
- "gksu-run-helper.\n\n"
- "Received:\n"
- " %s\n"
- "While expecting:\n"
- " %s"), buf, "gksu: waiting");
- emsg = g_strdup_printf (_("Failed to communicate with "
- "gksu-run-helper.\n\n"
- "Received bad string "
- "while expecting:\n"
- " %s"), "gksu: waiting");
- g_error_free (converr);
+ gchar *emsg = NULL;
+ gchar *converted_str = NULL;
+ GError *converr = NULL;
+
+ if (password)
+ nullify_password (password);
+
+ converted_str = g_locale_to_utf8 (buf, -1, NULL, NULL, &converr);
+ if (converr)
+ {
+ g_warning (_("Failed to communicate with "
+ "gksu-run-helper.\n\n"
+ "Received:\n"
+ " %s\n"
+ "While expecting:\n"
+ " %s"), buf, "gksu: waiting");
+ emsg = g_strdup_printf (_("Failed to communicate with "
+ "gksu-run-helper.\n\n"
+ "Received bad string "
+ "while expecting:\n"
+ " %s"), "gksu: waiting");
+ g_error_free (converr);
+ }
+ else
+ emsg = g_strdup_printf (_("Failed to communicate with "
+ "gksu-run-helper.\n\n"
+ "Received:\n"
+ " %s\n"
+ "While expecting:\n"
+ " %s"), converted_str, "gksu: waiting");
+ g_free (converted_str);
+
+ g_set_error (error, gksu_quark, GKSU_ERROR_HELPER, emsg);
+ g_free (emsg);
+
+ if (context->debug)
+ fprintf (stderr, "DEBUG (failed!) buf: -%s-\n", buf);
+
+ return FALSE;
}
- else
- emsg = g_strdup_printf (_("Failed to communicate with "
- "gksu-run-helper.\n\n"
- "Received:\n"
- " %s\n"
- "While expecting:\n"
- " %s"), converted_str, "gksu: waiting");
- g_free (converted_str);
+ else if (retval == -1)
+ {
+ if (context->debug)
+ fprintf (stderr, "DEBUG (select failed!) buf: %s\n", buf);
+ return FALSE;
+ }
- g_set_error (error, gksu_quark, GKSU_ERROR_HELPER, emsg);
- g_free (emsg);
-
+ read (fdpty, buf, 255);
if (context->debug)
- fprintf (stderr, "DEBUG (failed!) buf: -%s-\n", buf);
-
- return FALSE;
+ fprintf (stderr, "DEBUG (run:after-pass) buf: -%s-\n", buf);
+ loop_count++;
}
if (!password_needed || used_gnome_keyring)
More information about the gksu-commits
mailing list