Fixed: #823088 - rsync loses track of files with different directory prefixes

Fixed: #495310 - rsync contains forked copy of zlib
This commit is contained in:
Michal Luscon 2012-10-18 11:26:47 +02:00
parent 9e47b4bf23
commit d1bb487096
4 changed files with 193 additions and 66 deletions

View File

@ -0,0 +1,165 @@
From 7da17144fd764a2420a8d08897475c0b7fdbf956 Mon Sep 17 00:00:00 2001
From: Wayne Davison <wayned@samba.org>
Date: Mon, 21 Nov 2011 09:22:14 -0800
Subject: [PATCH] Add compatibility with an unmodified zlib.
---
Makefile.in | 4 ++--
batch.c | 2 +-
configure.ac | 26 +++++++++++++++++++++++++-
options.c | 2 +-
token.c | 24 +++++++++++++++---------
5 files changed, 44 insertions(+), 14 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 946a742..1b603b5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -31,7 +31,7 @@
HEADERS=byteorder.h config.h errcode.h proto.h rsync.h ifuncs.h lib/pool_alloc.h
LIBOBJ=lib/wildmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o lib/md5.o \
lib/permstring.o lib/pool_alloc.o lib/sysacls.o lib/sysxattrs.o @LIBOBJS@
-ZLIBOBJ=zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o \
+zlib_OBJS=zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o \
zlib/trees.o zlib/zutil.o zlib/adler32.o zlib/compress.o zlib/crc32.o
OBJS1=flist.o rsync.o generator.o receiver.o cleanup.o sender.o exclude.o \
util.o main.o checksum.o match.o syscall.o log.o backup.o
@@ -41,7 +41,7 @@ OBJS3=progress.o pipe.o
DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o
popt_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \
popt/popthelp.o popt/poptparse.o
-OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(DAEMON_OBJ) $(LIBOBJ) $(ZLIBOBJ) @BUILD_POPT@
+OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(DAEMON_OBJ) $(LIBOBJ) @BUILD_ZLIB@ @BUILD_POPT@
TLS_OBJ = tls.o syscall.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
diff --git a/batch.c b/batch.c
index b63f0c5..78d567d 100644
--- a/batch.c
+++ b/batch.c
@@ -20,7 +20,7 @@
*/
#include "rsync.h"
-#include "zlib/zlib.h"
+#include <zlib.h>
#include <time.h>
extern int eol_nulls;
diff --git a/configure.ac b/configure.ac
index 58aeea0..9e6b555 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,6 +78,9 @@ fi
AC_ARG_WITH(included-popt,
AC_HELP_STRING([--with-included-popt], [use bundled popt library, not from system]))
+AC_ARG_WITH(included-zlib,
+ AC_HELP_STRING([--with-included-zlib], [use bundled zlib library, not from system]))
+
AC_ARG_WITH(rsync-path,
AC_HELP_STRING([--with-rsync-path=PATH], [set default --rsync-path to PATH (default: rsync)]),
[ RSYNC_PATH="$with_rsync_path" ],
@@ -343,7 +346,8 @@ AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h \
sys/un.h sys/attr.h mcheck.h arpa/inet.h arpa/nameser.h locale.h \
netdb.h malloc.h float.h limits.h iconv.h libcharset.h langinfo.h \
sys/acl.h acl/libacl.h attr/xattr.h sys/xattr.h sys/extattr.h \
- popt.h popt/popt.h netinet/in_systm.h netinet/ip.h)
+ popt.h popt/popt.h netinet/in_systm.h netinet/ip.h \
+ zlib.h)
AC_HEADER_MAJOR
AC_CACHE_CHECK([if makedev takes 3 args],rsync_cv_MAKEDEV_TAKES_3_ARGS,[
@@ -773,6 +777,25 @@ else
AC_MSG_RESULT(no)
fi
+# We default to using our zlib unless --with-included-zlib=no is given.
+if test x"$with_included_zlib" != x"no"; then
+ with_included_zlib=yes
+elif test x"$ac_cv_header_zlib_h" != x"yes"; then
+ with_included_zlib=yes
+fi
+if test x"$with_included_zlib" != x"yes"; then
+ AC_CHECK_LIB(z, deflateParams, , [with_included_zlib=yes])
+fi
+
+AC_MSG_CHECKING([whether to use included zlib])
+if test x"$with_included_zlib" = x"yes"; then
+ AC_MSG_RESULT($srcdir/zlib)
+ BUILD_ZLIB='$(zlib_OBJS)'
+ CFLAGS="$CFLAGS -I$srcdir/zlib"
+else
+ AC_MSG_RESULT(no)
+fi
+
AC_CACHE_CHECK([for unsigned char],rsync_cv_SIGNED_CHAR_OK,[
AC_TRY_COMPILE([],[signed char *s = ""],
rsync_cv_SIGNED_CHAR_OK=yes,rsync_cv_SIGNED_CHAR_OK=no)])
@@ -926,6 +949,7 @@ AC_SUBST(OBJ_SAVE)
AC_SUBST(OBJ_RESTORE)
AC_SUBST(CC_SHOBJ_FLAG)
AC_SUBST(BUILD_POPT)
+AC_SUBST(BUILD_ZLIB)
AC_SUBST(MAKE_MAN)
AC_CHECK_FUNCS(_acl __acl _facl __facl)
diff --git a/options.c b/options.c
index d32376f..e8db07c 100644
--- a/options.c
+++ b/options.c
@@ -22,7 +22,7 @@
#include "rsync.h"
#include "ifuncs.h"
#include <popt.h>
-#include "zlib/zlib.h"
+#include <zlib.h>
extern int module_id;
extern int local_server;
diff --git a/token.c b/token.c
index 381d5c1..7628e2e 100644
--- a/token.c
+++ b/token.c
@@ -21,7 +21,11 @@
#include "rsync.h"
#include "ifuncs.h"
-#include "zlib/zlib.h"
+#include <zlib.h>
+
+#ifndef Z_INSERT_ONLY
+#define Z_INSERT_ONLY Z_SYNC_FLUSH
+#endif
extern int do_compression;
extern int module_id;
@@ -415,14 +415,16 @@
toklen -= n1;
tx_strm.next_in = (Bytef *)map_ptr(buf, offset, n1);
tx_strm.avail_in = n1;
- tx_strm.next_out = (Bytef *) obuf;
- tx_strm.avail_out = AVAIL_OUT_SIZE(CHUNK_SIZE);
- r = deflate(&tx_strm, Z_INSERT_ONLY);
- if (r != Z_OK || tx_strm.avail_in != 0) {
- rprintf(FERROR, "deflate on token returned %d (%d bytes left)\n",
- r, tx_strm.avail_in);
- exit_cleanup(RERR_STREAMIO);
- }
+ do {
+ tx_strm.next_out = (Bytef *) obuf;
+ tx_strm.avail_out = AVAIL_OUT_SIZE(CHUNK_SIZE);
+ r = deflate(&tx_strm, Z_INSERT_ONLY);
+ if (r != Z_OK) {
+ rprintf(FERROR, "deflate on token returned %d (%d bytes left)\n",
+ r, tx_strm.avail_in);
+ exit_cleanup(RERR_STREAMIO);
+ }
+ } while (tx_strm.avail_in != 0);
} while (toklen > 0);
}
}
--
1.7.11.4

View File

@ -0,0 +1,11 @@
--- rsync-3.0.9/flist.c 2011-08-27 23:58:04.000000000 +0200
+++ rsync-3.0.9/flist.c 2012-10-16 13:25:30.201627611 +0200
@@ -369,7 +369,7 @@
pathname = dir;
pathname_len = dirlen;
- if (!dir)
+ if (!dir || (*dir=='.' && dirlen==1))
dir = orig_dir;
if (!change_dir(dir, CD_NORMAL)) {

View File

@ -1,59 +0,0 @@
From 562c23886699a93882d9a090475a44f5761f7d8d Mon Sep 17 00:00:00 2001
From: "Vojtech Vitek (V-Teq)" <vvitek@redhat.com>
Date: Wed, 14 Sep 2011 18:31:35 +0200
Subject: [PATCH] Adapt do_symlink() from upstream 3.0.8+; fix context
---
configure.ac | 1 +
syscall.c | 20 ++++++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index ff21b3a..c841013 100644
--- a/configure.ac
+++ b/configure.ac
@@ -979,6 +979,7 @@ else
AC_MSG_RESULT(Using FreeBSD extattrs)
AC_DEFINE(HAVE_FREEBSD_XATTRS, 1, [True if you have FreeBSD xattrs])
AC_DEFINE(SUPPORT_XATTRS, 1)
+ AC_DEFINE(NO_SYMLINK_USER_XATTRS, 1, [True if symlinks do not support user xattrs])
;;
*)
if test x"$enable_xattr_support" = x"yes"; then
diff --git a/syscall.c b/syscall.c
index c85f73e..ddfd042 100644
--- a/syscall.c
+++ b/syscall.c
@@ -53,11 +53,27 @@ int do_unlink(const char *fname)
return unlink(fname);
}
-int do_symlink(const char *fname1, const char *fname2)
+int do_symlink(const char *lnk, const char *fname)
{
if (dry_run) return 0;
RETURN_ERROR_IF_RO_OR_LO;
- return symlink(fname1, fname2);
+
+#if defined NO_SYMLINK_XATTRS || defined NO_SYMLINK_USER_XATTRS
+ /* For --fake-super, we create a normal file with mode 0600
+ * and write the lnk into it. */
+ if (am_root < 0) {
+ int ok, len = strlen(lnk);
+ int fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR);
+ if (fd < 0)
+ return -1;
+ ok = write(fd, lnk, len) == len;
+ if (close(fd) < 0)
+ ok = 0;
+ return ok ? 0 : -1;
+ }
+#endif
+
+ return symlink(lnk, fname);
}
#ifdef HAVE_LINK
--
1.7.6

View File

@ -7,17 +7,19 @@
Summary: A program for synchronizing files over a network
Name: rsync
Version: 3.0.9
Release: 3%{?prerelease}%{?dist}
Release: 4%{?prerelease}%{?dist}
Group: Applications/Internet
URL: http://rsync.samba.org/
Source0: ftp://rsync.samba.org/pub/rsync/rsync-%{version}%{?prerelease}.tar.gz
Source1: ftp://rsync.samba.org/pub/rsync/rsync-patches-%{version}%{?prerelease}.tar.gz
Source2: rsync.xinetd
BuildRequires: libacl-devel, libattr-devel, autoconf, popt-devel
BuildRequires: libacl-devel, libattr-devel, autoconf, popt-devel, zlib-devel
Requires: zlib
License: GPLv3+
Patch0: rsync-3.0.8-no-symlink-user-xattrs.patch
Patch0: rsync-3.0.10-bundled-zlib.patch
Patch1: rsync-3.0.10-lose-track.patch
%description
Rsync uses a reliable algorithm to bring remote and host files into
@ -48,13 +50,17 @@ patch -p1 -i patches/xattrs.diff
#Enable --copy-devices parameter
patch -p1 -i patches/copy-devices.diff
#%patch0 -p1 -b .no-symlink-user-xattrs
%patch0 -p1 -b .bundled-zlib
%patch1 -p1 -b .lose-track
%build
rm -fr autom4te.cache
autoconf
autoheader
%configure
autoconf -o configure.sh
autoheader && touch config.h.in
%configure \
--with-included-zlib=no
make proto
make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS"
@ -77,6 +83,10 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man5/rsyncd.conf.5*
%changelog
* Tue Oct 16 2012 Michal Luscon <mluscon@redhat.com> 3.0.9-4
- Fixed: #823088 - rsync loses track of files with different directory prefixes
- Fixed: #495310 - rsync contains forked copy of zlib
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.0.9-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild