help-gsasl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stream buffering problems in batch mode


From: Simon Josefsson
Subject: Re: stream buffering problems in batch mode
Date: Tue, 26 Feb 2008 13:29:40 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

Enrico Scholz <address@hidden> writes:

> Hi,
>
> I try to use 'gsasl' (0.2.24) with the gnus email reader as an external
> GSSAPI authenticator.  This MUA needs to know when authentication succeeded
> an looks for the 'Client authentication finished' string, like in
>
> | # gsasl mailbox 143 --mechanism GSSAPI ...
> | . OK Capability completed.
> | . AUTHENTICATE GSSAPI
> | +
> | YIICGgYJKoZIhvcSAQICAQBuggIJMIICBaADAgE
> | ...
> | . OK Logged in.
> | Client authentication finished (server trusted)...
> | Enter application data (EOF to finish):
>
>
> Unfortunately, 'gsasl' uses stdout for printing IMAP responses and stderr
> for printing the status message ('Client authentication finished').
>
> When running 'gsasl' in batch mode (stdout/err are connected to pipes,
> not ttys), output is fully buffered and gnus gets confused due to
> missing/mixed data.
>
>
> I suggest to enable line buffered mode in a way like
>
> ---
> +  if (!isatty(1))
> +    {
> +      setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
> +      setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
> +    }
> ---

Hello Enrico!  Thanks for the report and patch.  I'd rather not touch
stderr buffering if not necessary (it is unbuffered, not even line
buffered, by default), what do you think of using the following patch
instead?  Does it work for you?

diff --git a/src/gsasl.c b/src/gsasl.c
index 5e9df8d..11bdb9d 100644
--- a/src/gsasl.c
+++ b/src/gsasl.c
@@ -410,6 +410,9 @@ main (int argc, char *argv[])
   if (connect_hostname && !args_info.hostname_arg)
     args_info.hostname_arg = strdup (connect_hostname);
 
+  if (!isatty (STDOUT_FILENO))
+    setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
+
   res = gsasl_init (&ctx);
   if (res != GSASL_OK)
     error (EXIT_FAILURE, 0, _("initialization failure: %s"),

Thanks,
/Simon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]