diff -u -r --new-file --exclude=CVS rsync-1.7.4/Makefile.in rsync-2.0.0/Makefile.in --- rsync-1.7.4/Makefile.in Thu Mar 26 15:51:09 1998 +++ rsync-2.0.0/Makefile.in Thu May 14 17:07:50 1998 @@ -21,23 +21,35 @@ .SUFFIXES: .c .o LIBOBJ=lib/getopt.o lib/fnmatch.o lib/zlib.o lib/compat.o -OBJS1=rsync.o exclude.o util.o md4.o main.o checksum.o match.o syscall.o -OBJS=$(OBJS1) flist.o io.o compat.o hlink.o token.o uidlist.o $(LIBOBJ) +OBJS1=rsync.o exclude.o util.o md4.o main.o checksum.o match.o syscall.o log.o +OBJS2=options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o +DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o +OBJS=$(OBJS1) $(OBJS2) $(DAEMON_OBJ) $(LIBOBJ) # note that the -I. is needed to handle config.h when using VPATH .c.o: $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@ -all: rsync +all: rsync rsync.1 rsyncd.conf.5 install: all -mkdir -p ${INSTALL_BIN} ${INSTALLCMD} -m 755 rsync ${INSTALL_BIN} -mkdir -p ${INSTALL_MAN}/man1 + -mkdir -p ${INSTALL_MAN}/man5 ${INSTALLCMD} -m 644 $(srcdir)/rsync.1 ${INSTALL_MAN}/man1 + ${INSTALLCMD} -m 644 $(srcdir)/rsyncd.conf.5 ${INSTALL_MAN}/man5 rsync: $(OBJS) $(CC) $(CFLAGS) -o rsync $(OBJS) $(LIBS) + +rsync.1: rsync.yo + yodl2man rsync.yo + mv rsync.man rsync.1 + +rsyncd.conf.5: rsyncd.conf.yo + yodl2man rsyncd.conf.yo + mv rsyncd.conf.man rsyncd.conf.5 proto: cat *.c | awk -f mkproto.awk > proto.h diff -u -r --new-file --exclude=CVS rsync-1.7.4/README rsync-2.0.0/README --- rsync-1.7.4/README Thu Mar 26 15:51:09 1998 +++ rsync-2.0.0/README Thu May 14 17:07:50 1998 @@ -72,6 +72,12 @@ Makefile and config.h appropriate for your system. Then type "make". +Note that on some systems you will have to force configure not to use +gcc because gcc may not support some features (such as 64 bit file +offsets) that your system may support. Set the environment variable CC +to the name of your native compiler before running configure in this +case. + Once built put a copy of rsync in your search path on the local and remote systems (or use "make install"). That's it! diff -u -r --new-file --exclude=CVS rsync-1.7.4/access.c rsync-2.0.0/access.c --- rsync-1.7.4/access.c Thu Jan 1 10:00:00 1970 +++ rsync-2.0.0/access.c Thu May 14 14:31:03 1998 @@ -0,0 +1,130 @@ +/* + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + hosts allow/deny code for rsync + + */ + +#include "rsync.h" + + +static int match_hostname(char *host, char *tok) +{ + if (!host || !*host) return 0; + return (fnmatch(tok, host, 0) == 0); +} + + +static int match_address(char *addr, char *tok) +{ + char *p; + unsigned long a, t, mask = ~0; + + if (!addr || !*addr) return 0; + + if (!isdigit(tok[0])) return 0; + + p = strchr(tok,'/'); + if (p) *p = 0; + + a = inet_addr(addr); + t = inet_addr(tok); + + if (p) { + *p = '/'; + } + + if (t == INADDR_NONE) { + rprintf(FERROR,"malformed address %s\n", tok); + return 0; + } + + a = ntohl(a); + t = ntohl(t); + + if (p) { + if (strchr(p+1,'.')) { + mask = inet_addr(p+1); + if (mask == INADDR_NONE) { + rprintf(FERROR,"malformed mask in %s\n", tok); + return 0; + } + mask = ntohl(mask); + } else { + int bits = atoi(p+1); + if (bits <= 0 || bits > 32) { + rprintf(FERROR,"malformed mask in %s\n", tok); + return 0; + } + mask &= (mask << (32-bits)); + } + } + + return ((a&mask) == (t&mask)); +} + +static int access_match(char *list, char *addr, char *host) +{ + char *tok; + char *list2 = strdup(list); + + if (!list2) out_of_memory("access_match"); + + strlower(list2); + if (host) strlower(host); + + for (tok=strtok(list2," ,\t"); tok; tok=strtok(NULL," ,\t")) { + if (match_hostname(host, tok) || match_address(addr, tok)) { + free(list2); + return 1; + } + } + + free(list2); + return 0; +} + +int allow_access(char *addr, char *host, char *allow_list, char *deny_list) +{ + /* if theres no deny list and no allow list then allow access */ + if ((!deny_list || !*deny_list) && (!allow_list || !*allow_list)) + return 1; + + /* if there is an allow list but no deny list then allow only hosts + on the allow list */ + if (!deny_list || !*deny_list) + return(access_match(allow_list, addr, host)); + + /* if theres a deny list but no allow list then allow + all hosts not on the deny list */ + if (!allow_list || !*allow_list) + return(!access_match(deny_list,addr,host)); + + /* if there are both type of list then allow all hosts on the + allow list */ + if (access_match(allow_list,addr,host)) + return 1; + + /* if there are both type of list and it's not on the allow then + allow it if its not on the deny */ + if (access_match(deny_list,addr,host)) + return 0; + + return 1; +} diff -u -r --new-file --exclude=CVS rsync-1.7.4/acconfig.h rsync-2.0.0/acconfig.h --- rsync-1.7.4/acconfig.h Thu Jan 1 10:00:00 1970 +++ rsync-2.0.0/acconfig.h Sun May 10 17:40:20 1998 @@ -0,0 +1,9 @@ +#undef HAVE_BROKEN_READDIR +#undef HAVE_ERRNO_DECL +#undef HAVE_LONGLONG +#undef HAVE_OFF64_T +#undef HAVE_REMSH +#undef HAVE_UNSIGNED_CHAR +#undef HAVE_UTIMBUF +#undef ino_t +#undef HAVE_CONNECT diff -u -r --new-file --exclude=CVS rsync-1.7.4/authenticate.c rsync-2.0.0/authenticate.c --- rsync-1.7.4/authenticate.c Thu Jan 1 10:00:00 1970 +++ rsync-2.0.0/authenticate.c Wed May 13 22:21:10 1998 @@ -0,0 +1,211 @@ +/* + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* support rsync authentication */ +#include "rsync.h" + +/*************************************************************************** +encode a buffer using base64 - simple and slow algorithm. null terminates +the result. + ***************************************************************************/ +static void base64_encode(char *buf, int len, char *out) +{ + char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + int bit_offset, byte_offset, idx, i; + unsigned char *d = (unsigned char *)buf; + char *p; + int bytes = (len*8 + 5)/6; + + memset(out, 0, bytes+1); + + for (i=0;i> (2-bit_offset)) & 0x3F; + } else { + idx = (d[byte_offset] << (bit_offset-2)) & 0x3F; + if (byte_offset+1 < len) { + idx |= (d[byte_offset+1] >> (8-(bit_offset-2))); + } + } + out[i] = b64[idx]; + } +} + +/* create a 16 byte challenge buffer */ +static void gen_challenge(char *addr, char *challenge) +{ + char input[32]; + struct timeval tv; + + memset(input, 0, sizeof(input)); + + strncpy((char *)input, addr, 16); + gettimeofday(&tv, NULL); + SIVAL(input, 16, tv.tv_sec); + SIVAL(input, 20, tv.tv_usec); + SIVAL(input, 24, getpid()); + + sum_init(); + sum_update(input, sizeof(input)); + sum_end(challenge); +} + + +/* return the secret for a user from the sercret file. maximum length + is len. null terminate it */ +static int get_secret(int module, char *user, char *secret, int len) +{ + char *fname = lp_secrets_file(module); + int fd, found=0; + char line[1024]; + char *p, *pass; + + if (!fname || !*fname) return 0; + + fd = open(fname,O_RDONLY); + if (fd == -1) return 0; + + while (!found) { + int i = 0; + memset(line, 0, sizeof(line)); + while (i<(sizeof(line)-1)) { + if (read(fd, &line[i], 1) != 1) { + memset(line, 0, sizeof(line)); + close(fd); + return 0; + } + if (line[i] == '\r') continue; + if (line[i] == '\n') break; + i++; + } + line[i] = 0; + if (line[0] == '#') continue; + p = strchr(line,':'); + if (!p) continue; + *p = 0; + if (strcmp(user, line)) continue; + pass = p+1; + found = 1; + } + + close(fd); + if (!found) return 0; + + if (strlen(pass) > len-1) { + memset(line, 0, sizeof(line)); + return 0; + } + + strcpy(secret, pass); + return 1; +} + +/* generate a 16 byte hash from a password and challenge */ +void generate_hash(char *in, char *challenge, char *out) +{ + char buf[16]; + + sum_init(); + sum_update(in, strlen(in)); + sum_update(challenge, strlen(challenge)); + sum_end(buf); + + base64_encode(buf, 16, out); +} + +/* possible negotiate authentication with the client. Use "leader" to + start off the auth if necessary */ +int auth_server(int fd, int module, char *addr, char *leader) +{ + char *users = lp_auth_users(module); + char challenge[16]; + char b64_challenge[30]; + char line[1024]; + char user[100]; + char secret[100]; + char pass[30]; + char pass2[30]; + char *tok; + + /* if no auth list then allow anyone in! */ + if (!users || !*users) return 1; + + gen_challenge(addr, challenge); + + base64_encode(challenge, 16, b64_challenge); + + io_printf(fd,"%s%s\n", leader, b64_challenge); + + if (!read_line(fd, line, sizeof(line)-1)) { + return 0; + } + + memset(user, 0, sizeof(user)); + memset(pass, 0, sizeof(pass)); + + if (sscanf(line,"%99s %29s", user, pass) != 2) { + return 0; + } + + users = strdup(users); + if (!users) return 0; + + for (tok=strtok(users," ,\t"); tok; tok = strtok(NULL," ,\t")) { + if (strcmp(tok, user) == 0) break; + } + free(users); + + if (!tok) { + return 0; + } + + memset(secret, 0, sizeof(secret)); + if (!get_secret(module, user, secret, sizeof(secret)-1)) { + memset(secret, 0, sizeof(secret)); + return 0; + } + + generate_hash(secret, b64_challenge, pass2); + memset(secret, 0, sizeof(secret)); + + return (strcmp(pass, pass2) == 0); +} + + +void auth_client(int fd, char *user, char *challenge) +{ + char *pass; + char pass2[30]; + + if (!user || !*user) return; + + if (!(pass=getenv("RSYNC_PASSWORD"))) { + pass = getpass("Password: "); + } + + if (!pass || !*pass) { + pass = ""; + } + + generate_hash(pass, challenge, pass2); + + io_printf(fd, "%s %s\n", user, pass2); +} + diff -u -r --new-file --exclude=CVS rsync-1.7.4/checksum.c rsync-2.0.0/checksum.c --- rsync-1.7.4/checksum.c Thu Mar 26 15:51:09 1998 +++ rsync-2.0.0/checksum.c Thu May 14 17:07:51 1998 @@ -34,7 +34,7 @@ { int i; uint32 s1, s2; - signed char *buf = (signed char *)buf1; + schar *buf = (schar *)buf1; s1 = s2 = 0; for (i = 0; i < (len-4); i+=4) { @@ -93,13 +93,13 @@ } -void file_checksum(char *fname,char *sum,off_t size) +void file_checksum(char *fname,char *sum,OFF_T size) { - off_t i; + OFF_T i; MDstruct MD; struct map_struct *buf; int fd; - off_t len = size; + OFF_T len = size; char tmpchunk[CSUM_CHUNK]; bzero(sum,csum_length); diff -u -r --new-file --exclude=CVS rsync-1.7.4/clientserver.c rsync-2.0.0/clientserver.c --- rsync-1.7.4/clientserver.c Thu Jan 1 10:00:00 1970 +++ rsync-2.0.0/clientserver.c Thu May 14 01:44:04 1998 @@ -0,0 +1,331 @@ +/* + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* the socket based protocol for setting up a connection wit rsyncd */ + +#include "rsync.h" + +extern int module_id; +extern int read_only; +extern int verbose; +extern int rsync_port; + +int start_socket_client(char *host, char *path, int argc, char *argv[]) +{ + int fd, i; + char *sargs[MAX_ARGS]; + int sargc=0; + char line[1024]; + char *p, *user=NULL; + extern int remote_version; + + p = strchr(host, '@'); + if (p) { + user = host; + host = p+1; + *p = 0; + } + + if (!user) user = getenv("USER"); + if (!user) user = getenv("LOGNAME"); + + fd = open_socket_out(host, rsync_port); + if (fd == -1) { + exit_cleanup(1); + } + + server_options(sargs,&sargc); + + sargs[sargc++] = "."; + + if (path && *path) + sargs[sargc++] = path; + + sargs[sargc] = NULL; + + io_printf(fd,"@RSYNCD: %d\n", PROTOCOL_VERSION); + + if (!read_line(fd, line, sizeof(line)-1)) { + return -1; + } + + if (sscanf(line,"@RSYNCD: %d", &remote_version) != 1) { + return -1; + } + + p = strchr(path,'/'); + if (p) *p = 0; + io_printf(fd,"%s\n",path); + if (p) *p = '/'; + + while (1) { + if (!read_line(fd, line, sizeof(line)-1)) { + return -1; + } + + if (strncmp(line,"@RSYNCD: AUTHREQD ",18) == 0) { + auth_client(fd, user, line+18); + continue; + } + + if (strcmp(line,"@RSYNCD: OK") == 0) break; + rprintf(FINFO,"%s\n", line); + } + + for (i=0;i 1) verbose = 1; + + argc -= optind; + argp = argv + optind; + optind = 0; + + start_server(fd, fd, argc, argp); + + return 0; +} + +/* send a list of available modules to the client. Don't list those + with "list = False". */ +static void send_listing(int fd) +{ + int n = lp_numservices(); + int i; + + for (i=0;i 0) { + line[len] = 0; + io_printf(fd,"%s", line); + } + } + if (f) fclose(f); + io_printf(fd,"\n"); + } + + if (!read_line(fd, line, sizeof(line)-1)) { + return -1; + } + + if (sscanf(line,"@RSYNCD: %d", &remote_version) != 1) { + io_printf(fd,"@ERROR: protocol startup error\n"); + return -1; + } + + while (i == -1) { + line[0] = 0; + if (!read_line(fd, line, sizeof(line)-1)) { + return -1; + } + + if (!*line || strcmp(line,"#list")==0) { + send_listing(fd); + return -1; + } + + if (*line == '#') { + /* it's some sort of command that I don't understand */ + io_printf(fd,"@ERROR: Unknown command '%s'\n", line); + return -1; + } + + i = lp_number(line); + if (i == -1) { + io_printf(fd,"@ERROR: Unknown module '%s'\n", line); + return -1; + } + } + + return rsync_module(fd, i); +} + + +int daemon_main(void) +{ + if (is_a_socket(STDIN_FILENO)) { + /* we are running via inetd */ + return start_daemon(STDIN_FILENO); + } + + become_daemon(); + + start_accept_loop(rsync_port, start_daemon); + return -1; +} + diff -u -r --new-file --exclude=CVS rsync-1.7.4/compat.c rsync-2.0.0/compat.c --- rsync-1.7.4/compat.c Thu Mar 26 15:51:09 1998 +++ rsync-2.0.0/compat.c Thu May 14 17:07:51 1998 @@ -40,35 +40,37 @@ void setup_protocol(int f_out,int f_in) { - if (am_server) { - remote_version = read_int(f_in); - write_int(f_out,PROTOCOL_VERSION); - write_flush(f_out); - } else { - write_int(f_out,PROTOCOL_VERSION); - write_flush(f_out); - remote_version = read_int(f_in); - } + if (remote_version == 0) { + if (am_server) { + remote_version = read_int(f_in); + write_int(f_out,PROTOCOL_VERSION); + write_flush(f_out); + } else { + write_int(f_out,PROTOCOL_VERSION); + write_flush(f_out); + remote_version = read_int(f_in); + } + } - if (remote_version < MIN_PROTOCOL_VERSION || - remote_version > MAX_PROTOCOL_VERSION) { - fprintf(FERROR,"protocol version mismatch - is your shell clean?\n"); - exit_cleanup(1); - } - - if (verbose > 2) - fprintf(FINFO, "local_version=%d remote_version=%d\n", - PROTOCOL_VERSION, remote_version); - - if (remote_version >= 12) { - if (am_server) { - checksum_seed = time(NULL); - write_int(f_out,checksum_seed); - } else { - checksum_seed = read_int(f_in); - } - } - - checksum_init(); + if (remote_version < MIN_PROTOCOL_VERSION || + remote_version > MAX_PROTOCOL_VERSION) { + rprintf(FERROR,"protocol version mismatch - is your shell clean?\n"); + exit_cleanup(1); + } + + if (verbose > 2) + rprintf(FINFO, "local_version=%d remote_version=%d\n", + PROTOCOL_VERSION, remote_version); + + if (remote_version >= 12) { + if (am_server) { + checksum_seed = time(NULL); + write_int(f_out,checksum_seed); + } else { + checksum_seed = read_int(f_in); + } + } + + checksum_init(); } diff -u -r --new-file --exclude=CVS rsync-1.7.4/config.h.in rsync-2.0.0/config.h.in --- rsync-1.7.4/config.h.in Thu Mar 26 15:51:09 1998 +++ rsync-2.0.0/config.h.in Thu May 14 17:07:51 1998 @@ -1,115 +1,224 @@ /* config.h.in. Generated automatically from configure.in by autoheader. */ -/* compiler specifics */ -#undef const +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define if your system has a working fnmatch function. */ +#undef HAVE_FNMATCH + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if your struct stat has st_rdev. */ +#undef HAVE_ST_RDEV + +/* Define if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define if utime(file, NULL) sets file's timestamp to the present. */ +#undef HAVE_UTIME_NULL + +/* Define as __inline if that's what the C compiler calls it. */ #undef inline -#undef HAVE_INLINE -/* defines for basic types */ -#undef gid_t +/* Define to `int' if doesn't define. */ #undef mode_t + +/* Define to `long' if doesn't define. */ #undef off_t + +/* Define to `int' if doesn't define. */ #undef pid_t + +/* Define as the return type of signal handlers (int or void). */ +#undef RETSIGTYPE + +/* Define to `unsigned' if doesn't define. */ #undef size_t + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to `int' if doesn't define. */ #undef uid_t -/* The number of bytes in some types */ -#undef SIZEOF_LONG +#undef HAVE_BROKEN_READDIR +#undef HAVE_ERRNO_DECL +#undef HAVE_LONGLONG +#undef HAVE_OFF64_T +#undef HAVE_REMSH +#undef HAVE_UNSIGNED_CHAR +#undef HAVE_UTIMBUF +#undef ino_t +#undef HAVE_CONNECT + +/* The number of bytes in a int. */ #undef SIZEOF_INT + +/* The number of bytes in a long. */ +#undef SIZEOF_LONG + +/* The number of bytes in a short. */ #undef SIZEOF_SHORT -/* defines for header files */ -#undef HAVE_SYS_WAIT_H -#undef HAVE_FCNTL_H -#undef HAVE_SYS_FCNTL_H -#undef HAVE_SYS_SELECT_H -#undef HAVE_SYS_PARAM_H -#undef TIME_WITH_SYS_TIME -#undef HAVE_DIRENT_H -#undef HAVE_MALLOC_H -#undef HAVE_SYS_DIR_H -#undef HAVE_SYS_TIME_H -#undef HAVE_SYS_TIMES_H -#undef HAVE_UNISTD_H -#undef HAVE_GRP_H -#undef HAVE_CTYPE_H -#undef HAVE_SYS_FILIO_H -#undef HAVE_SYS_IOCTL_H -#undef HAVE_UTIME_H -#undef HAVE_STRING_H -#undef HAVE_STDLIB_H -#undef HAVE_SYS_SOCKET_H -#undef HAVE_SYS_MODE_H +/* Define if you have the bcopy function. */ +#undef HAVE_BCOPY -/* specific functions */ -#undef HAVE_FCHMOD +/* Define if you have the bzero function. */ +#undef HAVE_BZERO + +/* Define if you have the chmod function. */ #undef HAVE_CHMOD -#undef HAVE_MKNOD + +/* Define if you have the chown function. */ +#undef HAVE_CHOWN + +/* Define if you have the fchmod function. */ +#undef HAVE_FCHMOD + +/* Define if you have the fstat function. */ #undef HAVE_FSTAT + +/* Define if you have the getcwd function. */ +#undef HAVE_GETCWD + +/* Define if you have the getopt_long function. */ +#undef HAVE_GETOPT_LONG + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the glob function. */ +#undef HAVE_GLOB + +/* Define if you have the lchown function. */ +#undef HAVE_LCHOWN + +/* Define if you have the link function. */ +#undef HAVE_LINK + +/* Define if you have the memmove function. */ +#undef HAVE_MEMMOVE + +/* Define if you have the mkdir function. */ +#undef HAVE_MKDIR + +/* Define if you have the mknod function. */ +#undef HAVE_MKNOD + +/* Define if you have the pipe function. */ +#undef HAVE_PIPE + +/* Define if you have the readlink function. */ +#undef HAVE_READLINK + +/* Define if you have the setlinebuf function. */ +#undef HAVE_SETLINEBUF + +/* Define if you have the setsid function. */ +#undef HAVE_SETSID + +/* Define if you have the strchr function. */ #undef HAVE_STRCHR + +/* Define if you have the strdup function. */ #undef HAVE_STRDUP + +/* Define if you have the strerror function. */ #undef HAVE_STRERROR + +/* Define if you have the strtok function. */ #undef HAVE_STRTOK -#undef HAVE_WAITPID -#undef HAVE_BCOPY -#undef HAVE_BZERO -#undef HAVE_READLINK -#undef HAVE_LINK + +/* Define if you have the utime function. */ #undef HAVE_UTIME + +/* Define if you have the utimes function. */ #undef HAVE_UTIMES -#undef HAVE_GETOPT_LONG -#undef HAVE_FNMATCH -#undef HAVE_LONGLONG -#undef HAVE_UTIMBUF -#undef HAVE_MEMMOVE -#undef HAVE_MMAP -#undef HAVE_LCHOWN -#undef HAVE_SETLINEBUF -#undef HAVE_GETCWD -/* specific programs */ -#undef HAVE_REMSH +/* Define if you have the vsnprintf function. */ +#undef HAVE_VSNPRINTF -#ifndef HAVE_MEMMOVE -#define memmove(d,s,n) bcopy(s,d,n) -#endif +/* Define if you have the waitpid function. */ +#undef HAVE_WAITPID +/* Define if you have the header file. */ +#undef HAVE_COMPAT_H -/* for signal declarations */ -#undef RETSIGTYPE +/* Define if you have the header file. */ +#undef HAVE_CTYPE_H -/* needed for mknod */ -#undef HAVE_ST_RDEV +/* Define if you have the header file. */ +#undef HAVE_DIRENT_H -/* Define if the system does not provide POSIX.1 features except - with this defined. */ -#undef _POSIX_1_SOURCE +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H -/* Define if you need to in order for stat and other things to work. */ -#undef _POSIX_SOURCE +/* Define if you have the header file. */ +#undef HAVE_GRP_H -/* Define as the return type of signal handlers (int or void). */ -#undef RETSIGTYPE +/* Define if you have the header file. */ +#undef HAVE_NDIR_H -/* pgrp info */ -#undef GETPGRP_VOID -#undef SETPGRP_VOID +/* Define if you have the header file. */ +#undef HAVE_STDLIB_H -/* Define if you can safely include both and . */ +/* Define if you have the header file. */ +#undef HAVE_STRING_H -/* HP/UX source */ -#undef _HPUX_SOURCE +/* Define if you have the header file. */ +#undef HAVE_SYS_DIR_H -/* Use the "union wait" union to get process status from wait3/waitpid */ -#undef HAVE_UNION_WAIT +/* Define if you have the header file. */ +#undef HAVE_SYS_FCNTL_H -/* Define if contains a declaration for extern int errno */ -#undef HAVE_ERRNO_DECL +/* Define if you have the header file. */ +#undef HAVE_SYS_FILIO_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_MODE_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_UNISTD_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_WAIT_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the header file. */ +#undef HAVE_UTIME_H + +/* Define if you have the inet library (-linet). */ +#undef HAVE_LIBINET + +/* Define if you have the nsl library (-lnsl). */ +#undef HAVE_LIBNSL -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -#undef _ALL_SOURCE -#endif +/* Define if you have the nsl_s library (-lnsl_s). */ +#undef HAVE_LIBNSL_S +/* Define if you have the socket library (-lsocket). */ +#undef HAVE_LIBSOCKET diff -u -r --new-file --exclude=CVS rsync-1.7.4/configure rsync-2.0.0/configure --- rsync-1.7.4/configure Sun Apr 5 16:10:29 1998 +++ rsync-2.0.0/configure Thu May 14 17:07:51 1998 @@ -2207,7 +2207,7 @@ fi done -for ac_func in memmove getopt_long lchown setlinebuf +for ac_func in memmove getopt_long lchown setlinebuf vsnprintf setsid glob do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2214: checking for $ac_func" >&5 @@ -2289,7 +2289,7 @@ fi -echo $ac_n "checking for long long... $ac_c" +echo $ac_n "checking for long long ... $ac_c" if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else @@ -2297,7 +2297,7 @@ #line 2298 "configure" #include "confdefs.h" #include -main() { long long x = 1000000000000; char b[20]; sprintf(b,"%lld", x); exit(strcmp("1000000000000", b) == 0? 0: 1); } +main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); } EOF if { (eval echo configure:2303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then @@ -2315,9 +2315,91 @@ fi +echo $ac_n "checking for off64_t ... $ac_c" +if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +#include +main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) return 1; exit((lstat64("/dev/null", &st)==0)?0:1); } +EOF +if { (eval echo configure:2330: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + echo yes;cat >> confdefs.h <<\EOF +#define HAVE_OFF64_T 1 +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo no +fi +rm -fr conftest* +fi + + +echo $ac_n "checking for unsigned char ... $ac_c" +if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() { char c; c=250; exit((c > 0)?0:1); } +EOF +if { (eval echo configure:2356: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + echo yes;cat >> confdefs.h <<\EOF +#define HAVE_UNSIGNED_CHAR 1 +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo no +fi +rm -fr conftest* +fi + + +echo $ac_n "checking for broken readdir ... $ac_c" +if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +#include +main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d); +if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 && +di->d_name[0] == 0) return 0; return 1;} +EOF +if { (eval echo configure:2385: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + echo yes - you are using the broken /usr/ucb/cc;cat >> confdefs.h <<\EOF +#define HAVE_BROKEN_READDIR 1 +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo no +fi +rm -fr conftest* +fi + + echo $ac_n "checking for utimbuf ... $ac_c" cat > conftest.$ac_ext < #include @@ -2325,7 +2407,7 @@ struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf); ; return 0; } EOF -if { (eval echo configure:2329: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2411: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo yes;cat >> confdefs.h <<\EOF #define HAVE_UTIMBUF 1 @@ -2338,6 +2420,270 @@ echo no fi rm -f conftest* + +# The following test taken from the cvs sources +# If we can't find connect, try looking in -lsocket, -lnsl, and -linet. +# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has +# libsocket.so which has a bad implementation of gethostbyname (it +# only looks in /etc/hosts), so we only look for -lsocket if we need +# it. +echo $ac_n "checking for connect""... $ac_c" 1>&6 +echo "configure:2432: checking for connect" >&5 +if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char connect(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_connect) || defined (__stub___connect) +choke me +#else +connect(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_connect=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_connect=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +case "$LIBS" in +*-lnsl*) ;; +*) echo $ac_n "checking for printf in -lnsl_s""... $ac_c" 1>&6 +echo "configure:2480: checking for printf in -lnsl_s" >&5 +ac_lib_var=`echo nsl_s'_'printf | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lnsl_s $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo nsl_s | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + ;; +esac +case "$LIBS" in +*-lnsl*) ;; +*) echo $ac_n "checking for printf in -lnsl""... $ac_c" 1>&6 +echo "configure:2530: checking for printf in -lnsl" >&5 +ac_lib_var=`echo nsl'_'printf | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lnsl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo nsl | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + ;; +esac +case "$LIBS" in +*-lsocket*) ;; +*) echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 +echo "configure:2580: checking for connect in -lsocket" >&5 +ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsocket $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo socket | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + ;; +esac +case "$LIBS" in +*-linet*) ;; +*) echo $ac_n "checking for connect in -linet""... $ac_c" 1>&6 +echo "configure:2630: checking for connect in -linet" >&5 +ac_lib_var=`echo inet'_'connect | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-linet $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo inet | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + ;; +esac +if test "$ac_cv_lib_socket_connect" = "yes" || + test "$ac_cv_lib_inet_connect" = "yes"; then + ac_cv_func_connect=yes + cat >> confdefs.h <<\EOF +#define HAVE_CONNECT 1 +EOF + +fi +fi + + trap '' 1 2 15 cat > confcache <<\EOF diff -u -r --new-file --exclude=CVS rsync-1.7.4/configure.in rsync-2.0.0/configure.in --- rsync-1.7.4/configure.in Sun Apr 5 16:10:29 1998 +++ rsync-2.0.0/configure.in Thu May 14 17:07:51 1998 @@ -42,7 +42,7 @@ AC_FUNC_UTIME_NULL AC_CHECK_FUNCS(waitpid strtok pipe getcwd mkdir strdup strerror chown chmod mknod) AC_CHECK_FUNCS(fchmod fstat strchr bcopy bzero readlink link utime utimes) -AC_CHECK_FUNCS(memmove getopt_long lchown setlinebuf) +AC_CHECK_FUNCS(memmove getopt_long lchown setlinebuf vsnprintf setsid glob) echo $ac_n "checking for working fnmatch... $ac_c" AC_TRY_RUN([#include @@ -50,17 +50,71 @@ echo yes;AC_DEFINE(HAVE_FNMATCH), echo no) -echo $ac_n "checking for long long... $ac_c" +echo $ac_n "checking for long long ... $ac_c" AC_TRY_RUN([#include -main() { long long x = 1000000000000; char b[20]; sprintf(b,"%lld", x); exit(strcmp("1000000000000", b) == 0? 0: 1); }], +main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }], echo yes;AC_DEFINE(HAVE_LONGLONG), echo no) +echo $ac_n "checking for off64_t ... $ac_c" +AC_TRY_RUN([#include +#include +main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) return 1; exit((lstat64("/dev/null", &st)==0)?0:1); }], +echo yes;AC_DEFINE(HAVE_OFF64_T), +echo no) + +echo $ac_n "checking for unsigned char ... $ac_c" +AC_TRY_RUN([#include +main() { char c; c=250; exit((c > 0)?0:1); }], +echo yes;AC_DEFINE(HAVE_UNSIGNED_CHAR), +echo no) + +echo $ac_n "checking for broken readdir ... $ac_c" +AC_TRY_RUN([#include +#include +main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d); +if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 && +di->d_name[0] == 0) return 0; return 1;} ], +echo yes - you are using the broken /usr/ucb/cc;AC_DEFINE(HAVE_BROKEN_READDIR), +echo no) + echo $ac_n "checking for utimbuf ... $ac_c" AC_TRY_COMPILE([#include #include ], [struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf);], echo yes;AC_DEFINE(HAVE_UTIMBUF), echo no) + +# The following test taken from the cvs sources +# If we can't find connect, try looking in -lsocket, -lnsl, and -linet. +# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has +# libsocket.so which has a bad implementation of gethostbyname (it +# only looks in /etc/hosts), so we only look for -lsocket if we need +# it. +AC_CHECK_FUNC(connect, :, +[case "$LIBS" in +*-lnsl*) ;; +*) AC_CHECK_LIB(nsl_s, printf) ;; +esac +case "$LIBS" in +*-lnsl*) ;; +*) AC_CHECK_LIB(nsl, printf) ;; +esac +case "$LIBS" in +*-lsocket*) ;; +*) AC_CHECK_LIB(socket, connect) ;; +esac +case "$LIBS" in +*-linet*) ;; +*) AC_CHECK_LIB(inet, connect) ;; +esac +dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value +dnl has been cached. +if test "$ac_cv_lib_socket_connect" = "yes" || + test "$ac_cv_lib_inet_connect" = "yes"; then + ac_cv_func_connect=yes + AC_DEFINE(HAVE_CONNECT) +fi]) + AC_OUTPUT(Makefile lib/dummy) diff -u -r --new-file --exclude=CVS rsync-1.7.4/connection.c rsync-2.0.0/connection.c --- rsync-1.7.4/connection.c Thu Jan 1 10:00:00 1970 +++ rsync-2.0.0/connection.c Wed May 13 19:38:55 1998 @@ -0,0 +1,46 @@ +/* + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* support the max connections option */ +#include "rsync.h" + + +/**************************************************************************** +simple routine to do connection counting +****************************************************************************/ +int claim_connection(char *fname,int max_connections) +{ + int fd, i; + + if (max_connections <= 0) + return 1; + + fd = open(fname,O_RDWR|O_CREAT, 0600); + + if (fd == -1) { + return 0; + } + + /* find a free spot */ + for (i=0;i