[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Thu Jun 4 21:23:49 UTC 2020


The branch, master has been updated
       via  01b9bbb0 Avoid a deadlock due to huge amounts of verbose messages.
       via  852a0b29 Tweak --copy-as docs a bit more.
       via  55290c85 Add hostname "lh" as a --no-cd localhost.
       via  e633091d Fix change_dir() leaving appended slash in curr_dir on failure.
      from  4c9fdb9f Handle --skip-compress right for new compressors

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 01b9bbb0f94e4ddd4b1e3ad678b220ca09bc0ad0
Author: Wayne Davison <wayne at opencoder.net>
Date:   Thu Jun 4 14:11:07 2020 -0700

    Avoid a deadlock due to huge amounts of verbose messages.
    
    Allow the receiver to increase their iobuf.msg xbuf if it fills up. This
    ensures that the receiver will never block trying to output a message,
    and thus it will always drain the data from the sender and keep the
    whole thing from clogging up.

commit 852a0b29c3ae08c28b3b0a455869b29fde34740c
Author: Wayne Davison <wayne at opencoder.net>
Date:   Thu Jun 4 13:07:50 2020 -0700

    Tweak --copy-as docs a bit more.

commit 55290c858425873a6bf2be7bc841dbb68c023767
Author: Wayne Davison <wayne at opencoder.net>
Date:   Thu Jun 4 12:37:07 2020 -0700

    Add hostname "lh" as a --no-cd localhost.

commit e633091d23ee483f4bc7a0f8bca15b5b17958fff
Author: Wayne Davison <wayne at opencoder.net>
Date:   Thu Jun 4 12:35:19 2020 -0700

    Fix change_dir() leaving appended slash in curr_dir on failure.

-----------------------------------------------------------------------

Summary of changes:
 io.c           | 15 ++++++++++++---
 rsync.yo       | 22 ++++++++++++++--------
 support/lsh    |  7 ++++++-
 support/lsh.sh |  3 ++-
 util.c         |  2 ++
 5 files changed, 36 insertions(+), 13 deletions(-)


Changeset truncated at 500 lines:

diff --git a/io.c b/io.c
index 999c34e5..ceff3784 100644
--- a/io.c
+++ b/io.c
@@ -954,8 +954,17 @@ int send_msg(enum msgcode code, const char *buf, size_t len, int convert)
 	} else
 #endif
 		needed = len + 4 + 3;
-	if (iobuf.msg.len + needed > iobuf.msg.size)
-		perform_io(needed, PIO_NEED_MSGROOM);
+	if (iobuf.msg.len + needed > iobuf.msg.size) {
+		if (!am_receiver)
+			perform_io(needed, PIO_NEED_MSGROOM);
+		else { /* We allow the receiver to increase their iobuf.msg size to avoid a deadlock. */
+			size_t old_size = iobuf.msg.size;
+			restore_iobuf_size(&iobuf.msg);
+			realloc_xbuf(&iobuf.msg, iobuf.msg.size * 2);
+			if (iobuf.msg.pos + iobuf.msg.len > old_size)
+				memcpy(iobuf.msg.buf + old_size, iobuf.msg.buf, iobuf.msg.pos + iobuf.msg.len - old_size);
+		}
+	}
 
 	pos = iobuf.msg.pos + iobuf.msg.len; /* Must be set after any flushing. */
 	if (pos >= iobuf.msg.size)
@@ -1176,7 +1185,7 @@ int read_line(int fd, char *buf, size_t bufsiz, int flags)
 
 #ifdef ICONV_OPTION
 	if (flags & RL_CONVERT && iconv_buf.size < bufsiz)
-		realloc_xbuf(&iconv_buf, bufsiz + 1024);
+		realloc_xbuf(&iconv_buf, ROUND_UP_1024(bufsiz) + 1024);
 #endif
 
   start:
diff --git a/rsync.yo b/rsync.yo
index dfcda72b..01017b2d 100644
--- a/rsync.yo
+++ b/rsync.yo
@@ -1908,14 +1908,6 @@ dit(bf(--copy-as=USER[:GROUP])) This option instructs rsync to use the USER and
 if the user that is running rsync has the ability to change users. If the group
 is not specified then the user's default groups are used.
 
-The option only affects one side of the transfer unless the transfer is local,
-in which case it affects both sides. Use the bf(--remote-option) to affect the
-remote side, such as bf(-M--copy-as=joe). For a local transfer, the "lsh"
-support file provides a local-shell helper script that can be used to allow a
-"localhost:" host-spec to be specified without needing to setup any remote
-shells (allowing you to specify remote options that affect the side of the
-transfer that is using the host-spec, and local options for the other side).
-
 This option can help to reduce the risk of an rsync being run as root into or
 out of a directory that might have live changes happening to it and you want to
 make sure that root-level read or write actions of system files are not
@@ -1924,6 +1916,15 @@ sometimes you need the root-level host-access credentials to be used, so this
 allows rsync to drop root for the copying part of the operation after the
 remote-shell or daemon connection is established.
 
+The option only affects one side of the transfer unless the transfer is local,
+in which case it affects both sides. Use the bf(--remote-option) to affect the
+remote side, such as bf(-M--copy-as=joe). For a local transfer, the lsh (or lsh.sh)
+support file provides a local-shell helper script that can be used to allow a
+"localhost:" or "lh:" host-spec to be specified without needing to setup any
+remote shells, allowing you to specify remote options that affect the side of
+the transfer that is using the host-spec (and using hostname "lh" avoids the
+overriding of the remote directory to the user's home dir).
+
 For example, the following rsync writes the local files as user "joe":
 
 verb(   sudo rsync -aiv --copy-as=joe host1:backups/joe/ /home/joe/)
@@ -1933,6 +1934,11 @@ available to that user, and makes it impossible for the joe user to do a timed
 exploit of the path to induce a change to a file that the joe user has no
 permissions to change.
 
+The following command does a local copy into the "dest/" dir as user "joe"
+(assumimg you've installed support/lsh into a dir on your $PATH):
+
+verb(   sudo rsync -aive lsh -M--copy-as=joe src/ lh:dest/)
+
 dit(bf(-T, --temp-dir=DIR)) This option instructs rsync to use DIR as a
 scratch directory when creating temporary copies of the files transferred
 on the receiving side.  The default behavior is to create each temporary
diff --git a/support/lsh b/support/lsh
index 2f64d311..81a593b6 100755
--- a/support/lsh
+++ b/support/lsh
@@ -26,7 +26,9 @@ my $host = shift;
 if ($host =~ s/^([^@]+)\@//) {
     $login_name = $1;
 }
-if ($host ne 'localhost') {
+if ($host eq 'lh') {
+    $no_chdir = 1;
+} elsif ($host ne 'localhost') {
     die "lsh: unable to connect to host $host\n";
 }
 
@@ -77,5 +79,8 @@ sub usage
 {
     die <<EOT;
 Usage: lsh [-l user] [--sudo] [--no-cd] localhost COMMAND [...]
+
+Note that if you pass hostname "lh" instead of "localhost" that
+the --no-cd option is implied.
 EOT
 }
diff --git a/support/lsh.sh b/support/lsh.sh
index b63444e3..f74a8ef4 100755
--- a/support/lsh.sh
+++ b/support/lsh.sh
@@ -7,7 +7,7 @@
 # command.
 
 user=''
-do_cd=y # Default path is user's home dir, just like ssh.
+do_cd=y # Default path is user's home dir (just like ssh) unless host is "lh".
 
 while : ; do
     case "$1" in
@@ -16,6 +16,7 @@ while : ; do
     --no-cd) do_cd=n; shift ;;
     -*) shift ;;
     localhost) shift; break ;;
+    lh) do_cd=n; shift; break ;;
     *) echo "lsh: unable to connect to host $1" 1>&2; exit 1 ;;
     esac
 done
diff --git a/util.c b/util.c
index e1a75565..2c734b7c 100644
--- a/util.c
+++ b/util.c
@@ -1116,6 +1116,7 @@ int change_dir(const char *dir, int set_path_only)
 		skipped_chdir = set_path_only;
 		memcpy(curr_dir, dir, len + 1);
 	} else {
+		unsigned int save_dir_len = curr_dir_len;
 		if (curr_dir_len + 1 + len >= sizeof curr_dir) {
 			errno = ENAMETOOLONG;
 			return 0;
@@ -1125,6 +1126,7 @@ int change_dir(const char *dir, int set_path_only)
 		memcpy(curr_dir + curr_dir_len, dir, len + 1);
 
 		if (!set_path_only && chdir(curr_dir)) {
+			curr_dir_len = save_dir_len;
 			curr_dir[curr_dir_len] = '\0';
 			return 0;
 		}


-- 
The rsync repository.



More information about the rsync-cvs mailing list