gnutls-devel
[Top][All Lists]
Advanced

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

[gnutls-dev] Re: gnutls-cli -s triggered by SIGALRM too?


From: Simon Josefsson
Subject: [gnutls-dev] Re: gnutls-cli -s triggered by SIGALRM too?
Date: Fri Oct 3 00:49:01 2003
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Nikos Mavroyanopoulos <address@hidden> writes:

> On Sun, Sep 21, 2003 at 03:08:58AM +0200, Simon Josefsson wrote:
>
>> Hello, I'm working on a STARTTLS interface for Emacs using GNUTLS,
>> since the current Emacs solution uses a non-standard command line
>> application based on OpenSSL, so moving to gnutls-cli seems better.
>> 
>> However, triggering the STARTTLS negotiation by EOF seem slightly
>> problematic to do in a portable way from Emacs.  The old starttls
>> application triggered the STARTTLS negotiation by SIGALRM.  Would it
>> be possible to support this as well, in gnutls-cli?  Suggested patch
>> attached.
> I've just applied it in the cvs version. Thanks.

Thanks.  I've started to use it and I discovered two more problems:

* The FD_ZERO is not called after select() has called.

* Buffered IO (i.e., fgets()) doesn't work well with select().  The
  problem is that fgets() may fill the IO buffer with data to read,
  but only return one line (the remaining lines in the buffer will be
  returned by later calls to f* functions).  One solution is to
  rewrite the code to use read() instead of fgets(), but this would
  complicate the 'crlf' handling harder.  The following just disable
  the buffering instead.

2003-10-03  Simon Josefsson  <address@hidden>

        * src/cli.c (main): Disable buffering.  Clear FD set.

Index: cli.c
===================================================================
RCS file: /cvs/gnutls/gnutls/src/cli.c,v
retrieving revision 2.214
diff -u -p -u -w -r2.214 cli.c
--- cli.c       2 Oct 2003 15:02:31 -0000       2.214
+++ cli.c       2 Oct 2003 22:43:26 -0000
@@ -378,8 +378,13 @@ int main(int argc, char **argv)
 
        signal (SIGALRM, &starttls_alarm);
 
-       FD_ZERO(&rset);
+       /* do not buffer */
+       setbuf(stdin, NULL);
+       setbuf(stdout, NULL);
+       setbuf(stderr, NULL);
+
        for (;;) {
+               FD_ZERO(&rset);
                FD_SET(fileno(stdin), &rset);
                FD_SET(sd, &rset);
 




reply via email to

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