Re: New protocol to avoid EOF?

2001-07-10 Thread Wayne Davison

On Tue, 26 Jun 2001, Martin Pool wrote:
 On 25 Jun 2001, Wayne Davison [EMAIL PROTECTED] wrote:
  I was wondering if the protocol should be updated to avoid ever
  assuming that an EOF on the socket was OK.  The only case I know of
  where this allowed is when we're listing modules from an rsync server.
  If we modified the protocol to have the daemon rsync send an EOF token
  (such as @RSYNCD: EOF) at the end of the list, this would allow the
  rsync client to always report an unexpected EOF as an error.

 Yes, that sounds good.  I think I applied the patch that clears up the
 is eof OK? flag, so please go ahead and send the new one.

I haven't seen this show up in the CVS version at pserver.samba.org.

Here's (finally) a combo patch that incorporates my previous two patches
(that removed the bogus EOF error) while also adding an EOF-marker
message if the other rsync is using the newest protocol (eliminating the
need for us to ever allow an actual EOF to be silently ignored).

..wayne..

---8--8--8--8---cut here---8--8--8--8---
Index: rsync/authenticate.c
--- rsync/authenticate.c22 Jun 2001 10:16:04 -  1.17
+++ rsync/authenticate.c10 Jul 2001 22:41:28 -
@@ -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: rsync/clientserver.c
--- rsync/clientserver.c7 May 2001 06:59:37 -   1.67
+++ rsync/clientserver.c10 Jul 2001 22:41:29 -
@@ -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,9 +107,11 @@
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;
}
+   if (strcmp(line,@RSYNCD: EOF) == 0)
+   return 0;

if (strncmp(line,@RSYNCD: AUTHREQD ,18) == 0) {
auth_client(fd, user, line+18);
@@ -277,7 +279,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;
}

@@ -377,10 +379,13 @@
 {
int n = lp_numservices();
int i;
-
+   extern int remote_version;
+
for (i=0;in;i++)
if (lp_list(i))
io_printf(fd, %-15s\t%s\n, lp_name(i), lp_comment(i));
+   if (remote_version = 25)
+   io_printf(fd,@RSYNCD: EOF\n);
 }

 /* this is called when a socket connection is established to a client
@@ -418,7 +423,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 +434,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: rsync/io.c
--- rsync/io.c  7 May 2001 06:59:37 -   1.85
+++ rsync/io.c  10 Jul 2001 22:41:41 -
@@ -178,12 +178,13 @@


if (n == 0) {
-   if (eof_error) {
-   rprintf(FERROR,
-%s: connection to server unexpectedly closed
- (%.0f bytes read so far)\n,
-RSYNC_NAME, (double)stats.total_read);
-   }
+   extern int remote_version;
+   if (!eof_error  remote_version  25)
+   exit_cleanup(0);
+   rprintf(FERROR,
+   %s: connection to server unexpectedly closed
+(%.0f bytes read so far)\n,
+   RSYNC_NAME, (double)stats.total_read);
exit_cleanup(RERR_STREAMIO);
}

@@ -560,9 +561,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;
Index: rsync/proto.h
--- rsync/proto.h   7 May 2001 

Re: New protocol to avoid EOF?

2001-06-26 Thread Martin Pool

On 25 Jun 2001, Wayne Davison [EMAIL PROTECTED] wrote:
 I was wondering if the protocol should be updated to avoid ever
 assuming that an EOF on the socket was OK.  The only case I know of
 where this allowed is when we're listing modules from an rsync server.
 If we modified the protocol to have the daemon rsync send an EOF token
 (such as @RSYND: EOF) at the end of the list, this would allow the
 rsync client to always report an unexpected EOF as an error.
 
 I've got a patch that implements this, but because it's built on top
 of my last bogus-module-list-error-removal patch, I'll only work up a
 diff if this is something that the maintainers want to do.

Yes, that sounds good.  I think I applied the patch that clears up the
is eof OK? flag, so please go ahead and send the new one.  We have
the technology to apply mismatched patches anyhow :-)

virtual beer

-- 
Martin




New protocol to avoid EOF?

2001-06-25 Thread Wayne Davison

I was wondering if the protocol should be updated to avoid ever
assuming that an EOF on the socket was OK.  The only case I know of
where this allowed is when we're listing modules from an rsync server.
If we modified the protocol to have the daemon rsync send an EOF token
(such as @RSYND: EOF) at the end of the list, this would allow the
rsync client to always report an unexpected EOF as an error.

I've got a patch that implements this, but because it's built on top
of my last bogus-module-list-error-removal patch, I'll only work up a
diff if this is something that the maintainers want to do.

..wayne..