summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenno <benno@openbsd.org>2019-02-21 22:12:48 +0000
committerbenno <benno@openbsd.org>2019-02-21 22:12:48 +0000
commit521a61e942f44321af9ff81f0934febd43b70597 (patch)
treebb7cca143164391c470d47564803518694f397a1
parentkristaps 156cf3b7d459efe133d603158fc33c243dc07ba0 (diff)
downloadwireguard-openbsd-521a61e942f44321af9ff81f0934febd43b70597.tar.xz
wireguard-openbsd-521a61e942f44321af9ff81f0934febd43b70597.zip
kristaps 7721288a1d170f4d789bf7a7b822f14f91f7bcb9
In order for GPL rsync(1) to work with --delete when openrsync is a remote sender, we need to set the FLIST_TOP_LEVEL bit for all top-level directories. This is because the GPL rsync(1) uses this bit to determine which directories to scan for files for deletion.
-rw-r--r--usr.bin/rsync/flist.c8
-rw-r--r--usr.bin/rsync/rsync.58
2 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/rsync/flist.c b/usr.bin/rsync/flist.c
index 6ccf871df49..18897479525 100644
--- a/usr.bin/rsync/flist.c
+++ b/usr.bin/rsync/flist.c
@@ -1,4 +1,4 @@
-/* $Id: flist.c,v 1.18 2019/02/21 22:07:44 benno Exp $ */
+/* $Id: flist.c,v 1.19 2019/02/21 22:12:48 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2019 Florian Obser <florian@openbsd.org>
@@ -43,6 +43,7 @@
* They are sent as the first byte for a file transmission and encode
* information that affects subsequent transmissions.
*/
+#define FLIST_TOP_LEVEL 0x0001 /* needed for remote --delete */
#define FLIST_MODE_SAME 0x0002 /* mode is repeat */
#define FLIST_RDEV_SAME 0x0004 /* rdev is repeat */
#define FLIST_UID_SAME 0x0008 /* uid is repeat */
@@ -144,6 +145,9 @@ flist_dedupe(struct sess *sess, struct flist **fl, size_t *sz)
* If we have the first element as the ".", then that's the "top
* directory" of our transfer.
* Otherwise, mark up all top-level directories in the set.
+ * XXX: the FLIST_TOP_LEVEL flag should indicate what is and what isn't
+ * a top-level directory, but I'm not sure if GPL rsync(1) respects it
+ * the same way.
*/
static void
flist_topdirs(struct sess *sess, struct flist *fl, size_t flsz)
@@ -291,6 +295,8 @@ flist_send(struct sess *sess, int fdin, int fdout, const struct flist *fl,
*/
flag = FLIST_NAME_LONG;
+ if ((FLSTAT_TOP_DIR & f->st.flags))
+ flag |= FLIST_TOP_LEVEL;
LOG3(sess, "%s: sending file metadata: "
"size %jd, mtime %jd, mode %o",
diff --git a/usr.bin/rsync/rsync.5 b/usr.bin/rsync/rsync.5
index b675982c1bb..1696f085d0c 100644
--- a/usr.bin/rsync/rsync.5
+++ b/usr.bin/rsync/rsync.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rsync.5,v 1.10 2019/02/18 21:55:27 benno Exp $
+.\" $OpenBSD: rsync.5,v 1.11 2019/02/21 22:12:48 benno Exp $
.\"
.\" Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: February 18 2019 $
+.Dd $Mdocdate: February 21 2019 $
.Dt RSYNC 5
.Os
.Sh NAME
@@ -251,6 +251,10 @@ The status byte may consist of the following bits and determines which
of the optional fields are transmitted.
.Pp
.Bl -tag -compact -width Ds
+.It 0x01
+A top-level directory.
+(Only applies to directory files.)
+If specified, the matching local directory is for deletions.
.It 0x02
Do not send the file mode: it is a repeat of the last file's mode.
.It 0x08