diff -u -r --new-file --exclude=CVS rsync-2.0.19/clientserver.c rsync-2.1.0/clientserver.c --- rsync-2.0.19/clientserver.c Sat Jul 18 00:46:51 1998 +++ rsync-2.1.0/clientserver.c Mon Jul 20 15:43:27 1998 @@ -118,6 +118,7 @@ char *name = lp_name(i); char *user; int start_glob=0; + int ret; char *request=NULL; extern int am_sender; extern int remote_version; @@ -251,7 +252,7 @@ } } - parse_arguments(argc, argv); + ret = parse_arguments(argc, argv); if (request) { if (*user) { @@ -276,6 +277,11 @@ if (remote_version > 17 && am_sender) io_start_multiplex_out(fd); + if (!ret) { + rprintf(FERROR,"Error parsing options (unsupported option?) - aborting\n"); + exit_cleanup(1); + } + start_server(fd, fd, argc, argp); return 0; @@ -375,7 +381,15 @@ push_dir("/", 0); if (is_a_socket(STDIN_FILENO)) { - /* we are running via inetd */ + int i; + + /* we are running via inetd - close off stdout and + stderr so that library functions (and getopt) don't + try to use them. Redirect them to /dev/null */ + for (i=1;i<3;i++) { + close(i); + open("/dev/null", O_RDWR); + } return start_daemon(STDIN_FILENO); } diff -u -r --new-file --exclude=CVS rsync-2.0.19/cvs.log rsync-2.1.0/cvs.log --- rsync-2.0.19/cvs.log Sat Jul 18 00:53:10 1998 +++ rsync-2.1.0/cvs.log Mon Jul 20 15:43:59 1998 @@ -6305,3 +6305,96 @@ Log Message: preparing for release of 2.0.19 + +**************************************** +Date: Sunday July 19, 1998 @ 14:50 +Author: tridge + +Update of /data/cvs/rsync +In directory samba:/tmp/cvs-serv19094 + +Modified Files: + main.c options.c proto.h socket.c +Log Message: +- close stdout and stderr and reopen then as /dev/null when running as +a daemon. This prevents library functions (such as getopt) stuffing up +our protocol stream when errors are detected. + +- defer the error message from the options parsing until after the +socket is multiplexed. This allows clients sending new options which +the remote server doesn't understand to get a sensible error message. + + + +**************************************** +Date: Sunday July 19, 1998 @ 15:22 +Author: tridge + +Update of /data/cvs/rsync +In directory samba:/tmp/cvs-serv22203 + +Modified Files: + clientserver.c +Log Message: +- defer the error message from the options parsing until after the +socket is multiplexed. This allows clients sending new options which +the remote server doesn't understand to get a sensible error message. + + + +**************************************** +Date: Sunday July 19, 1998 @ 20:51 +Author: tridge + +Update of /data/cvs/rsync +In directory samba:/tmp/cvs-serv24080 + +Modified Files: + io.c +Log Message: +always use a timeout to select, even if --timeout is not +specified. This makes things easier to debug. + + + +**************************************** +Date: Monday July 20, 1998 @ 15:36 +Author: tridge + +Update of /data/cvs/rsync +In directory samba:/tmp/cvs-serv12483 + +Modified Files: + io.c rsync.c socket.c util.c +Log Message: +I think I might havefinally fixed the rsync hanging bug. It was caused +by a read during an io_flush() triggered during a readfd(). A simple +logic bug in the io code :( + + + +**************************************** +Date: Monday July 20, 1998 @ 15:43 +Author: rsync-bu + +Update of /data/cvs/rsync +In directory samba:/data/people/rsync-bugs/rsync + +Modified Files: + version.h +Log Message: +preparing for release of 2.1.0 + + +**************************************** +Date: Monday July 20, 1998 @ 15:43 +Author: rsync-bu + +Update of /data/cvs/rsync/packaging/redhat/5.0 +In directory samba:/data/people/rsync-bugs/rsync/packaging/redhat/5.0 + +Modified Files: + rsync.spec +Log Message: +preparing for release of 2.1.0 + diff -u -r --new-file --exclude=CVS rsync-2.0.19/io.c rsync-2.1.0/io.c --- rsync-2.0.19/io.c Sat Jul 18 00:46:51 1998 +++ rsync-2.1.0/io.c Mon Jul 20 15:43:27 1998 @@ -24,6 +24,9 @@ */ #include "rsync.h" +/* if no timeout is specified then use a 60 second select timeout */ +#define SELECT_TIMEOUT 60 + static int io_multiplexing_out; static int io_multiplexing_in; static int multiplex_in_fd; @@ -67,6 +70,7 @@ static int read_buffer_len; static int read_buffer_size; static int no_flush; +static int no_flush_read; /* read from a socket with IO timeout. return the number of bytes read. If no bytes can be read then exit, never return @@ -75,7 +79,9 @@ { int n, ret=0; + no_flush_read++; io_flush(); + no_flush_read--; while (ret == 0) { fd_set fds; @@ -83,11 +89,10 @@ FD_ZERO(&fds); FD_SET(fd, &fds); - tv.tv_sec = io_timeout; + tv.tv_sec = io_timeout?io_timeout:SELECT_TIMEOUT; tv.tv_usec = 0; - if (select(fd+1, &fds, NULL, NULL, - io_timeout?&tv:NULL) != 1) { + if (select(fd+1, &fds, NULL, NULL, &tv) != 1) { check_timeout(); continue; } @@ -252,7 +257,9 @@ continue; } + no_flush_read++; io_flush(); + no_flush_read--; ret = read_unbuffered(fd,buffer + total,N-total); total += ret; @@ -318,7 +325,7 @@ fd_set w_fds, r_fds; int fd_count, count; struct timeval tv; - int reading; + int reading=0; int blocked=0; no_flush++; @@ -329,8 +336,10 @@ FD_SET(fd,&w_fds); fd_count = fd+1; - reading = (buffer_f_in != -1 && - read_buffer_len < MAX_READ_BUFFER); + if (!no_flush_read) { + reading = (buffer_f_in != -1 && + read_buffer_len < MAX_READ_BUFFER); + } if (reading) { FD_SET(buffer_f_in,&r_fds); @@ -338,13 +347,13 @@ fd_count = buffer_f_in+1; } - tv.tv_sec = io_timeout; + tv.tv_sec = io_timeout?io_timeout:SELECT_TIMEOUT; tv.tv_usec = 0; count = select(fd_count, reading?&r_fds:NULL, &w_fds,NULL, - io_timeout?&tv:NULL); + &tv); if (count <= 0) { check_timeout(); diff -u -r --new-file --exclude=CVS rsync-2.0.19/main.c rsync-2.1.0/main.c --- rsync-2.0.19/main.c Sat Jul 18 00:46:51 1998 +++ rsync-2.1.0/main.c Mon Jul 20 15:43:27 1998 @@ -566,7 +566,9 @@ carried across */ orig_umask = (int)umask(0); - parse_arguments(argc, argv); + if (!parse_arguments(argc, argv)) { + exit_cleanup(1); + } argc -= optind; argv += optind; diff -u -r --new-file --exclude=CVS rsync-2.0.19/options.c rsync-2.1.0/options.c --- rsync-2.0.19/options.c Sat Jul 18 00:46:51 1998 +++ rsync-2.1.0/options.c Mon Jul 20 15:43:27 1998 @@ -197,7 +197,8 @@ {"port", 1, 0, OPT_PORT}, {0,0,0,0}}; -void parse_arguments(int argc, char *argv[]) + +int parse_arguments(int argc, char *argv[]) { int opt; int option_index; @@ -301,7 +302,7 @@ preserve_hard_links=1; #else rprintf(FERROR,"ERROR: hard links not supported on this platform\n"); - exit_cleanup(1); + return 0; #endif break; @@ -412,10 +413,10 @@ break; default: - /* rprintf(FERROR,"bad option -%c\n",opt); */ - exit_cleanup(1); + return 0; } } + return 1; } diff -u -r --new-file --exclude=CVS rsync-2.0.19/packaging/redhat/5.0/rsync.spec rsync-2.1.0/packaging/redhat/5.0/rsync.spec --- rsync-2.0.19/packaging/redhat/5.0/rsync.spec Sat Jul 18 00:52:59 1998 +++ rsync-2.1.0/packaging/redhat/5.0/rsync.spec Mon Jul 20 15:43:49 1998 @@ -1,10 +1,10 @@ Summary: Program for efficient remote updates of files. Name: rsync -Version: 2.0.19 +Version: 2.1.0 Release: 1 Copyright: GPL Group: Applications/Networking -Source: ftp://samba.anu.edu.au/pub/rsync/rsync-2.0.19.tar.gz +Source: ftp://samba.anu.edu.au/pub/rsync/rsync-2.1.0.tar.gz URL: http://samba.anu.edu.au/rsync/ Packager: Andrew Tridgell BuildRoot: /tmp/rsync diff -u -r --new-file --exclude=CVS rsync-2.0.19/proto.h rsync-2.1.0/proto.h --- rsync-2.0.19/proto.h Sat Jul 18 00:46:51 1998 +++ rsync-2.1.0/proto.h Mon Jul 20 15:43:27 1998 @@ -94,7 +94,7 @@ void match_sums(int f,struct sum_struct *s,struct map_struct *buf,OFF_T len); void match_report(void); void usage(int F); -void parse_arguments(int argc, char *argv[]); +int parse_arguments(int argc, char *argv[]); void server_options(char **args,int *argc); BOOL pm_process( char *FileName, BOOL (*sfunc)(char *), diff -u -r --new-file --exclude=CVS rsync-2.0.19/rsync.c rsync-2.1.0/rsync.c --- rsync-2.0.19/rsync.c Sat Jul 18 00:46:51 1998 +++ rsync-2.1.0/rsync.c Mon Jul 20 15:43:27 1998 @@ -961,7 +961,7 @@ if (!get_tmpname(fnametmp,fname)) { if (buf) unmap_file(buf); - close(fd1); + if (fd1 != -1) close(fd1); continue; } @@ -969,7 +969,7 @@ rprintf(FERROR,"mktemp %s failed\n",fnametmp); receive_data(f_in,buf,-1,NULL,file->length); if (buf) unmap_file(buf); - close(fd1); + if (fd1 != -1) close(fd1); continue; } @@ -990,7 +990,7 @@ rprintf(FERROR,"open %s : %s\n",fnametmp,strerror(errno)); receive_data(f_in,buf,-1,NULL,file->length); if (buf) unmap_file(buf); - close(fd1); + if (fd1 != -1) close(fd1); continue; } diff -u -r --new-file --exclude=CVS rsync-2.0.19/socket.c rsync-2.1.0/socket.c --- rsync-2.0.19/socket.c Sat Jul 18 00:46:51 1998 +++ rsync-2.1.0/socket.c Mon Jul 20 15:43:27 1998 @@ -281,27 +281,30 @@ ****************************************************************************/ void become_daemon(void) { - if (fork()) + int i; + + if (fork()) { _exit(0); + } /* detach from the terminal */ #ifdef HAVE_SETSID setsid(); #else #ifdef TIOCNOTTY - { - int i = open("/dev/tty", O_RDWR); - if (i >= 0) - { - ioctl(i, (int) TIOCNOTTY, (char *)0); - close(i); - } + i = open("/dev/tty", O_RDWR); + if (i >= 0) { + ioctl(i, (int) TIOCNOTTY, (char *)0); + close(i); } #endif /* TIOCNOTTY */ #endif - close(0); - close(1); - close(2); + /* make sure that stdin, stdout an stderr don't stuff things + up (library functions, for example) */ + for (i=0;i<3;i++) { + close(i); + open("/dev/null", O_RDWR); + } } /******************************************************************* diff -u -r --new-file --exclude=CVS rsync-2.0.19/util.c rsync-2.1.0/util.c --- rsync-2.0.19/util.c Sat Jul 18 00:46:51 1998 +++ rsync-2.1.0/util.c Mon Jul 20 15:43:27 1998 @@ -291,7 +291,7 @@ } ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode); - if (ofd < 0) { + if (ofd == -1) { rprintf(FERROR,"open %s: %s\n", dest,strerror(errno)); close(ifd); diff -u -r --new-file --exclude=CVS rsync-2.0.19/version.h rsync-2.1.0/version.h --- rsync-2.0.19/version.h Sat Jul 18 00:52:57 1998 +++ rsync-2.1.0/version.h Mon Jul 20 15:43:48 1998 @@ -1 +1 @@ -#define VERSION "2.0.19" +#define VERSION "2.1.0"