On Thu, 14 Jun 2001, Martin Pool wrote:
> I'm slightly concerned that this may cause some other failure modes to
> falsely cause the client to return 0.

I was thinking about this myself.  The code sets "eof_error = 0" for any
user of read_line(), and (judging from my quick inspection) this doesn't
seem right to me.  Perhaps read_line() should take an extra parameter
that indicates whether and EOF is OK or not.  We could then change the
calling code to normally pass that EOF is not OK except when we're doing
a module listing.  Here's a patch.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: authenticate.c
--- authenticate.c      26 Oct 2000 07:31:29 -0000      1.16
+++ authenticate.c      14 Jun 2001 17:38:26 -0000
@@ -224,7 +224,7 @@

        io_printf(fd,"%s%s\n", leader, b64_challenge);

-       if (!read_line(fd, line, sizeof(line)-1)) {
+       if (!read_line(fd, line, sizeof(line)-1, 0)) {
                return NULL;
        }

Index: clientserver.c
--- clientserver.c      7 May 2001 06:59:37 -0000       1.67
+++ clientserver.c      14 Jun 2001 17:38:26 -0000
@@ -44,9 +44,9 @@
        extern int am_sender;
        extern struct in_addr socket_address;
        extern char *shell_cmd;
+       extern int list_only;

        if (argc == 0 && !am_sender) {
-               extern int list_only;
                list_only = 1;
        }

@@ -93,7 +93,7 @@

        io_printf(fd,"@RSYNCD: %d\n", PROTOCOL_VERSION);

-       if (!read_line(fd, line, sizeof(line)-1)) {
+       if (!read_line(fd, line, sizeof(line)-1, 0)) {
                return -1;
        }

@@ -107,7 +107,7 @@
        if (p) *p = '/';

        while (1) {
-               if (!read_line(fd, line, sizeof(line)-1)) {
+               if (!read_line(fd, line, sizeof(line)-1, list_only)) {
                        return -1;
                }

@@ -277,7 +277,7 @@
        argv[argc++] = "rsyncd";

        while (1) {
-               if (!read_line(fd, line, sizeof(line)-1)) {
+               if (!read_line(fd, line, sizeof(line)-1, 0)) {
                        return -1;
                }

@@ -418,7 +418,7 @@
                io_printf(fd,"\n");
        }

-       if (!read_line(fd, line, sizeof(line)-1)) {
+       if (!read_line(fd, line, sizeof(line)-1, 0)) {
                return -1;
        }

@@ -429,7 +429,7 @@

        while (i == -1) {
                line[0] = 0;
-               if (!read_line(fd, line, sizeof(line)-1)) {
+               if (!read_line(fd, line, sizeof(line)-1, 0)) {
                        return -1;
                }

Index: io.c
--- io.c        7 May 2001 06:59:37 -0000       1.85
+++ io.c        14 Jun 2001 17:38:28 -0000
@@ -560,9 +636,9 @@
        write_buf(f,(char *)&c,1);
 }

-int read_line(int f, char *buf, int maxlen)
+int read_line(int f, char *buf, int maxlen, int eof_ok)
 {
-       eof_error = 0;
+       eof_error = !eof_ok;

        while (maxlen) {
                buf[0] = 0;
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---


Reply via email to