diff --git a/.gitignore b/.gitignore
index 110c6c7..f1dcee3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
-SOURCES/rsync-3.0.9.tar.gz
-SOURCES/rsync-patches-3.0.9.tar.gz
+SOURCES/rsync-3.1.2.tar.gz
+SOURCES/rsync-patches-3.1.2.tar.gz
diff --git a/.rsync.metadata b/.rsync.metadata
index c455d01..0ee2af5 100644
--- a/.rsync.metadata
+++ b/.rsync.metadata
@@ -1,2 +1,2 @@
-c64c8341984aea647506eb504496999fd968ddfc SOURCES/rsync-3.0.9.tar.gz
-2f2bf85090270ec1d38e189415bf624a1637cadc SOURCES/rsync-patches-3.0.9.tar.gz
+0d4c7fb7fe3fc80eeff922a7c1d81df11dbb8a1a SOURCES/rsync-3.1.2.tar.gz
+5ba449a5e570ac372b35ec0fdabb1a9c33c70cb4 SOURCES/rsync-patches-3.1.2.tar.gz
diff --git a/SOURCES/rsync-3.0.9-ineffective-owner.patch b/SOURCES/rsync-3.0.9-ineffective-owner.patch
deleted file mode 100644
index 05515f9..0000000
--- a/SOURCES/rsync-3.0.9-ineffective-owner.patch
+++ /dev/null
@@ -1,66 +0,0 @@
---- a/rsync.c
-+++ b/rsync.c
-@@ -418,31 +418,6 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
- 		get_acl(fname, sxp);
- #endif
- 
--#ifdef SUPPORT_XATTRS
--	if (am_root < 0)
--		set_stat_xattr(fname, file, new_mode);
--	if (preserve_xattrs && fnamecmp)
--		set_xattr(fname, file, fnamecmp, sxp);
--#endif
--
--	if (!preserve_times
--	 || (!(preserve_times & PRESERVE_DIR_TIMES) && S_ISDIR(sxp->st.st_mode))
--	 || (!(preserve_times & PRESERVE_LINK_TIMES) && S_ISLNK(sxp->st.st_mode)))
--		flags |= ATTRS_SKIP_MTIME;
--	if (!(flags & ATTRS_SKIP_MTIME)
--	    && cmp_time(sxp->st.st_mtime, file->modtime) != 0) {
--		int ret = set_modtime(fname, file->modtime, sxp->st.st_mode);
--		if (ret < 0) {
--			rsyserr(FERROR_XFER, errno, "failed to set times on %s",
--				full_fname(fname));
--			goto cleanup;
--		}
--		if (ret == 0) /* ret == 1 if symlink could not be set */
--			updated = 1;
--		else
--			file->flags |= FLAG_TIME_FAILED;
--	}
--
- 	change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file);
- 	change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP)
- 		  && sxp->st.st_gid != (gid_t)F_GROUP(file);
-@@ -490,6 +465,31 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
- 		updated = 1;
- 	}
- 
-+#ifdef SUPPORT_XATTRS
-+	if (am_root < 0)
-+		set_stat_xattr(fname, file, new_mode);
-+	if (preserve_xattrs && fnamecmp)
-+		set_xattr(fname, file, fnamecmp, sxp);
-+#endif
-+
-+	if (!preserve_times
-+	 || (!(preserve_times & PRESERVE_DIR_TIMES) && S_ISDIR(sxp->st.st_mode))
-+	 || (!(preserve_times & PRESERVE_LINK_TIMES) && S_ISLNK(sxp->st.st_mode)))
-+		flags |= ATTRS_SKIP_MTIME;
-+	if (!(flags & ATTRS_SKIP_MTIME)
-+	    && cmp_time(sxp->st.st_mtime, file->modtime) != 0) {
-+		int ret = set_modtime(fname, file->modtime, sxp->st.st_mode);
-+		if (ret < 0) {
-+			rsyserr(FERROR_XFER, errno, "failed to set times on %s",
-+				full_fname(fname));
-+			goto cleanup;
-+		}
-+		if (ret == 0) /* ret == 1 if symlink could not be set */
-+			updated = 1;
-+		else
-+			file->flags |= FLAG_TIME_FAILED;
-+	}
-+
- #ifdef SUPPORT_ACLS
- 	/* It's OK to call set_acl() now, even for a dir, as the generator
- 	 * will enable owner-writability using chmod, if necessary.
diff --git a/SOURCES/rsync-3.1.0-protect_args.patch b/SOURCES/rsync-3.1.0-protect_args.patch
deleted file mode 100644
index 3ee30c9..0000000
--- a/SOURCES/rsync-3.1.0-protect_args.patch
+++ /dev/null
@@ -1,32 +0,0 @@
---- ./util.c	2011-04-23 00:51:55.000000000 +0200
-+++ ./util.c	2013-06-14 15:10:21.381102268 +0200
-@@ -25,6 +25,7 @@
- 
- extern int verbose;
- extern int module_id;
-+extern int protect_args;
- extern int modify_window;
- extern int relative_paths;
- extern int preserve_times;
-@@ -719,6 +720,11 @@
- 	if (strncmp(arg, base, base_len) == 0)
- 		arg += base_len;
- 
-+        if (protect_args) {
-+               glob_expand(arg, argv_p, argc_p, maxargs_p);
-+               return;
-+        }
-+        
- 	if (!(arg = strdup(arg)))
- 		out_of_memory("glob_expand_module");
- 
---- rsync-3.0.9.orig/t_unsafe.c
-+++ rsync-3.0.9/t_unsafe.c
-@@ -28,6 +28,7 @@ int am_root = 0;
- int read_only = 0;
- int list_only = 0;
- int verbose = 0;
-+int protect_args = 0;
- int preserve_perms = 0;
- int preserve_executability = 0;
- 
diff --git a/SOURCES/rsync-3.1.0-sigterm-handle.patch b/SOURCES/rsync-3.1.0-sigterm-handle.patch
deleted file mode 100644
index 2e665d5..0000000
--- a/SOURCES/rsync-3.1.0-sigterm-handle.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-diff --git a/rsync.c b/rsync.c
-index 104b274..b50146c 100644
---- a/rsync.c
-+++ b/rsync.c
-@@ -37,6 +37,7 @@ extern int preserve_times;
- extern int copy_devices;
- extern int am_root;
- extern int am_server;
-+extern int am_daemon;
- extern int am_sender;
- extern int am_receiver;
- extern int am_generator;
-@@ -537,7 +538,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
- 	return updated;
- }
- 
--RETSIGTYPE sig_int(UNUSED(int val))
-+RETSIGTYPE sig_int(int sig_num)
- {
- 	/* KLUGE: if the user hits Ctrl-C while ssh is prompting
- 	 * for a password, then our cleanup's sending of a SIGUSR1
-@@ -548,6 +549,11 @@ RETSIGTYPE sig_int(UNUSED(int val))
- 	 * not ssh waiting for a password, then this tiny delay
- 	 * shouldn't hurt anything. */
- 	msleep(400);
-+
-+	/* If we're an rsync daemon listener (not a daemon server),
-+	 * we'll exit with status 0 if we received SIGTERM. */
-+	if (am_daemon && !am_server && sig_num == SIGTERM)
-+		exit_cleanup(0);
- 	exit_cleanup(RERR_SIGNAL);
- }
- 
diff --git a/SOURCES/rsync-3.1.2-zlib.patch b/SOURCES/rsync-3.1.2-zlib.patch
new file mode 100644
index 0000000..50f699e
--- /dev/null
+++ b/SOURCES/rsync-3.1.2-zlib.patch
@@ -0,0 +1,13 @@
+diff --git a/token.c.old b/token.c
+index ad9b9bc..b2a3614 100644
+--- a/token.c.old
++++ b/token.c
+@@ -21,7 +21,7 @@
+ 
+ #include "rsync.h"
+ #include "itypes.h"
+-#include <zlib.h>
++#include "zlib/zlib.h"
+ 
+ extern int do_compression;
+ extern int protocol_version;
diff --git a/SOURCES/rsync-man.patch b/SOURCES/rsync-man.patch
index ee8ce46..d1a08ca 100644
--- a/SOURCES/rsync-man.patch
+++ b/SOURCES/rsync-man.patch
@@ -8,14 +8,3 @@
       \-\-specials              preserve special files
   \-D                          same as \-\-devices \-\-specials
   \-t, \-\-times                 preserve modification times
-
---- rsync-3.0.9/options.c   2012-09-18 13:33:27.085255598 +0200
-+++ rsync-3.0.9/options.c   2012-09-19 10:50:00.500816340 +0200
-@@ -432,6 +432,7 @@
- #ifdef ICONV_OPTION
-   rprintf(F,"     --iconv=CONVERT_SPEC    request charset conversion of filenames\n");
- #endif
-+  rprintf(F,"     --checksum-seed=NUM     set block/file checksum seed (advanced)\n");
-   rprintf(F," -4, --ipv4                  prefer IPv4\n");
-   rprintf(F," -6, --ipv6                  prefer IPv6\n");
-   rprintf(F,"     --version               print version number\n");
diff --git a/SPECS/rsync.spec b/SPECS/rsync.spec
index 85b01f2..d5f6d55 100644
--- a/SPECS/rsync.spec
+++ b/SPECS/rsync.spec
@@ -7,8 +7,8 @@
 
 Summary: A program for synchronizing files over a network
 Name: rsync
-Version: 3.0.9
-Release: 18%{?prerelease}%{?dist}
+Version: 3.1.2
+Release: 4%{?prerelease}%{?dist}
 Group: Applications/Internet
 URL: http://rsync.samba.org/
 
@@ -28,10 +28,8 @@ License: GPLv3+
 
 Patch0: rsync-3.0.10-lose-track.patch
 Patch1: rsync-man.patch
-Patch2: rsync-3.1.0-protect_args.patch
 Patch3: rsync-3.0.6-iconv-logging.patch
-Patch4: rsync-3.0.9-ineffective-owner.patch
-Patch5: rsync-3.1.0-sigterm-handle.patch
+Patch4: rsync-3.1.2-zlib.patch
 
 %description
 Rsync uses a reliable algorithm to bring remote and host files into
@@ -53,8 +51,6 @@ package.
 %setup -q -b 1
 %endif
 
-chmod -x support/*
-
 #Needed for compatibility with previous patched rsync versions
 patch -p1 -i patches/acls.diff
 patch -p1 -i patches/xattrs.diff
@@ -64,10 +60,8 @@ patch -p1 -i patches/copy-devices.diff
 
 %patch0 -p1 -b .lose-track
 %patch1 -p1 -b .man
-%patch2 -p1 -b .protect_args
 %patch3 -p1 -b .iconv-logging
-%patch4 -p1 -b .ineffective-owner
-%patch5 -p1 -b .sigterm-handle
+%patch4 -p1 -b .zlib
 
 %build
 rm -fr autom4te.cache
@@ -90,12 +84,16 @@ install -D -m644 %{SOURCE4} $RPM_BUILD_ROOT/%{_sysconfdir}/rsyncd.conf
 install -D -m644 %{SOURCE5} $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/rsyncd
 install -D -m644 %{SOURCE6} $RPM_BUILD_ROOT/%{_unitdir}/rsyncd@.service
 
+%check
+make check
+chmod -x support/*
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(-,root,root)
-%doc COPYING NEWS OLDNEWS README support/ tech_report.tex
+%doc COPYING NEWS OLDNEWS README tech_report.tex support/
 %{_bindir}/%{name}
 %{_mandir}/man1/%{name}.1*
 %{_mandir}/man5/rsyncd.conf.5*
@@ -115,6 +113,15 @@ rm -rf $RPM_BUILD_ROOT
 %systemd_postun_with_restart rsyncd.service
 
 %changelog
+* Wed Oct 18 2017 Michal Ruprich - 3.1.2-4
+- Related: #1432899 - removing dependencies on perl
+- using the bundled zlib.h(#1491582)
+- turning on upstream tests
+
+* Wed Aug 30 2017 Michal Ruprich - 3.1.2-1
+- Resolves: #1432899 - Rebase rsync to version >= 3.1.0
+- rebase to 3.1.2
+
 * Tue Jan 24 2017 Michal Ruprich - 3.0.9-18
 - Resolves: #1324754 -  rsyncd unit enters failed state on exit