--timeout option doesn't work when copying between directories

2019-10-31 Thread Marco Nelissen via rsync
It appears that the --timeout only works when using the rsync
protocol, but not when copying between two directories. So if the
destination is on a network filesystem and the network link is
disconnected, rsync will only abort the operation once the underlying
system finally reports that the destination is no longer reachable,
which can take quite a while.
Is this the intended behavior? If so, should the documentation/manpage
spell this out explicitly?

-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html


[PATCH v2] Replace mkproto.pl with mkproto.awk

2019-10-31 Thread Ethan Sommer via rsync
This replaces the build dependency on perl with one on awk which is
already used throughout the build system and is much more ubiquitous
than perl
---
 Makefile.in |  2 +-
 mkproto.awk | 39 +++
 mkproto.pl  | 48 
 3 files changed, 40 insertions(+), 49 deletions(-)
 create mode 100644 mkproto.awk
 delete mode 100644 mkproto.pl

diff --git a/Makefile.in b/Makefile.in
index f912f312..d7ddbc41 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -210,7 +210,7 @@ proto.h: proto.h-tstamp
@if test -f proto.h; then :; else cp -p $(srcdir)/proto.h .; fi
 
 proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c config.h
-   perl $(srcdir)/mkproto.pl $(srcdir)/*.c $(srcdir)/lib/compat.c
+   awk -f $(srcdir)/mkproto.awk $(srcdir)/*.c $(srcdir)/lib/compat.c
 
 man: rsync.1 rsyncd.conf.5 man-copy
 
diff --git a/mkproto.awk b/mkproto.awk
new file mode 100644
index ..d3802f95
--- /dev/null
+++ b/mkproto.awk
@@ -0,0 +1,39 @@
+#!/usr/bin/awk -f
+
+BEGIN {
+while ((getline i < "proto.h") > 0) old_protos = old_protos ? old_protos 
"\n" i : i
+protos = "/* This file is automatically generated with \"make proto\". DO 
NOT EDIT */\n"
+}
+
+inheader {
+protos = protos "\n" ((inheader = /\)[ \t]*$/ ? 0 : 1) ? $0 : $0 ";")
+next
+}
+
+/^FN_(LOCAL|GLOBAL)_[^(]+\([^,()]+/ {
+local = /^FN_LOCAL/
+gsub(/^FN_(LOC|GLOB)AL_|,.*$/, "")
+sub(/^BOOL\(/, "BOOL ")
+sub(/^CHAR\(/, "char ")
+sub(/^INTEGER\(/, "int ")
+sub(/^STRING\(/, "char *")
+protos = protos "\n" $0 (local ? "(int module_id);" : "(void);")
+next
+}
+
+/^static|^extern|;/||!/^[A-Za-z][A-Za-z0-9_]* / { next }
+
+/\(.*\)[ \t]*$/ {
+protos = protos "\n" $0 ";"
+next
+}
+
+/\(/ {
+inheader = 1
+protos = protos "\n" $0
+}
+
+END {
+if (old_protos != protos) print protos > "proto.h"
+print "" > "proto.h-tstamp"
+}
diff --git a/mkproto.pl b/mkproto.pl
deleted file mode 100644
index cdeb2ea3..
--- a/mkproto.pl
+++ /dev/null
@@ -1,48 +0,0 @@
-# generate prototypes for rsync
-
-$old_protos = '';
-if (open(IN, 'proto.h')) {
-$old_protos = join('', );
-close IN;
-}
-
-%FN_MAP = (
-BOOL => 'BOOL ',
-CHAR => 'char ',
-INTEGER => 'int ',
-STRING => 'char *',
-);
-
-$inheader = 0;
-$protos = qq|/* This file is automatically generated with "make proto". DO NOT 
EDIT */\n\n|;
-
-while (<>) {
-if ($inheader) {
-   if (/[)][ \t]*$/) {
-   $inheader = 0;
-   s/$/;/;
-   }
-   $protos .= $_;
-} elsif (/^FN_(LOCAL|GLOBAL)_([^(]+)\(([^,()]+)/) {
-   $ret = $FN_MAP{$2};
-   $func = $3;
-   $arg = $1 eq 'LOCAL' ? 'int module_id' : 'void';
-   $protos .= "$ret$func($arg);\n";
-} elsif (/^static|^extern/ || /[;]/ || !/^[A-Za-z][A-Za-z0-9_]* /) {
-   ;
-} elsif (/[(].*[)][ \t]*$/) {
-   s/$/;/;
-   $protos .= $_;
-} elsif (/[(]/) {
-   $inheader = 1;
-   $protos .= $_;
-}
-}
-
-if ($old_protos ne $protos) {
-open(OUT, '>proto.h') or die $!;
-print OUT $protos;
-close OUT;
-}
-
-open(OUT, '>proto.h-tstamp') and close OUT;
-- 
2.23.0


-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html


Re: [PATCH] Replace mkproto.pl with mkproto.awk

2019-10-31 Thread Ethan Sommer via rsync
> I can't speak for rsync, but nowadays Perl isn't that rare, that a
> dependeny on it for build purpose would matter. IMHO.
It might not be rare, but it's certainly less universally available than
awk, which is preinstalled on pretty much every unix-like OS out there.

> There are many flavours of AWK. Are you sure, that your AWK replacement
> runs everwhere?
I tested every common implementation I know of, and found that it didn't
work with busybox, awk, I'll be sending the updated patch that works
with at least gawk, mawk, nawk, busybox awk, and openbsd awk right after
this.

-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html


Re: [PATCH] Replace mkproto.pl with mkproto.awk

2019-10-31 Thread Heiko Schlittermann via rsync
Ethan Sommer via rsync  (Do 31 Okt 2019 17:38:17 CET):
> This replaces the build dependency on perl with one on awk which is
> already used in the build system and is much more ubiquitous than perl

I can't speak for rsync, but nowadays Perl isn't that rare, that a
dependeny on it for build purpose would matter. IMHO.

There are many flavours of AWK. Are you sure, that your AWK replacement
runs everwhere?

Best regards from Dresden/Germany
Viele Grüße aus Dresden
Heiko Schlittermann
--
 SCHLITTERMANN.de  internet & unix support -
 Heiko Schlittermann, Dipl.-Ing. (TU) - {fon,fax}: +49.351.802998{1,3} -
 gnupg encrypted messages are welcome --- key ID: F69376CE -
 ! key id 7CBF764A and 972EAC9F are revoked since 2015-01  -


signature.asc
Description: PGP signature
-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html


rsync CLI protocol documentation

2019-10-31 Thread Mailing List SVR via rsync

Hi all,

I would like to implement rsync compatibility in my app. I'm building an 
ssh server and I want to support rsync.


For example I execute this command:

1) rsync -a -e "ssh -p 2022" /home/nicola/test.sh nicola@127.0.0.1:/

and I get this exec command over ssh:

2) rsync --server -logDtpre.iLsfxC . /

I could simply execute the requested command and let it communicate with 
the remote rsync command at point 1.


This should work but I need more control over the uploaded files and 
their paths. I need to check for user quota ecc.. so basically I need to 
emulate the protocol implemented in rsync CLI inside my app.


There are several libraries that implement rsync protocol itself out of 
there (for example to create and apply deltas) but I cannot find 
libraries or documentation about rsync CLI itself.


To be more clear, after I receive the rsync command over ssh I get this 
4 bytes:


1f 00 00 00

since 1f = 31 this is the protocol version

I have to answer with the remote protocol version for example, if I want 
to emulate protocol version 31:


1f 00 00 00

and then I need to send this 5 (magic) bytes:

3f 94 8b b4 5d

after this the rsync client prints:

(Client) Protocol versions: remote=31, negotiated=31
FILE_STRUCT_LEN=24, EXTRA_LEN=4

and then sends the file lists.

Inside the bytes I receive server side I can read the file name but I 
need some docs on how to parse these bytes and what I need to expect.


I would like to have some documentation about this protocol for rsync 
CLI, is this documented somewhere?


For example I implemented scp support in my app and I found very useful 
this blog post:


https://web.archive.org/web/20170215184048/https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works

is there something similar for rsync?

Even some suggestions about the relevant source code to study would be 
helpful,


thanks
Nicola


--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html


[PATCH] Replace mkproto.pl with mkproto.awk

2019-10-31 Thread Ethan Sommer via rsync
This replaces the build dependency on perl with one on awk which is
already used in the build system and is much more ubiquitous than perl
---
 Makefile.in |  2 +-
 mkproto.awk | 39 +++
 mkproto.pl  | 48 
 3 files changed, 40 insertions(+), 49 deletions(-)
 create mode 100644 mkproto.awk
 delete mode 100644 mkproto.pl

diff --git a/Makefile.in b/Makefile.in
index f912f312..d7ddbc41 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -210,7 +210,7 @@ proto.h: proto.h-tstamp
@if test -f proto.h; then :; else cp -p $(srcdir)/proto.h .; fi
 
 proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c config.h
-   perl $(srcdir)/mkproto.pl $(srcdir)/*.c $(srcdir)/lib/compat.c
+   awk -f $(srcdir)/mkproto.awk $(srcdir)/*.c $(srcdir)/lib/compat.c
 
 man: rsync.1 rsyncd.conf.5 man-copy
 
diff --git a/mkproto.awk b/mkproto.awk
new file mode 100644
index ..0c6fcdd1
--- /dev/null
+++ b/mkproto.awk
@@ -0,0 +1,39 @@
+#!/usr/bin/awk -f
+
+BEGIN {
+while (getline i <"proto.h") old_protos = old_protos ? old_protos "\n" i : 
i
+protos = "/* This file is automatically generated with \"make proto\". DO 
NOT EDIT */\n"
+}
+
+inheader {
+protos = protos "\n" ((inheader = /\)[ \t]*$/ ? 0 : 1) ? $0 : $0 ";")
+next
+}
+
+/^FN_(LOCAL|GLOBAL)_[^(]+\([^,()]+/ {
+local = /^FN_LOCAL/
+gsub(/^FN_(LOC|GLOB)AL_|,.*$/, "")
+sub(/^BOOL\(/, "BOOL ")
+sub(/^CHAR\(/, "char ")
+sub(/^INTEGER\(/, "int ")
+sub(/^STRING\(/, "char *")
+protos = protos "\n" $0 (local ? "(int module_id);" : "(void);")
+next
+}
+
+/^static|^extern|;/||!/^[A-Za-z][A-Za-z0-9_]* / { next }
+
+/\(.*\)[ \t]*$/ {
+protos = protos "\n" $0 ";"
+next
+}
+
+/\(/ {
+inheader = 1
+protos = protos "\n" $0
+}
+
+END {
+if (old_protos != protos) print protos > "proto.h"
+print "" > "proto.h-tstamp"
+}
diff --git a/mkproto.pl b/mkproto.pl
deleted file mode 100644
index cdeb2ea3..
--- a/mkproto.pl
+++ /dev/null
@@ -1,48 +0,0 @@
-# generate prototypes for rsync
-
-$old_protos = '';
-if (open(IN, 'proto.h')) {
-$old_protos = join('', );
-close IN;
-}
-
-%FN_MAP = (
-BOOL => 'BOOL ',
-CHAR => 'char ',
-INTEGER => 'int ',
-STRING => 'char *',
-);
-
-$inheader = 0;
-$protos = qq|/* This file is automatically generated with "make proto". DO NOT 
EDIT */\n\n|;
-
-while (<>) {
-if ($inheader) {
-   if (/[)][ \t]*$/) {
-   $inheader = 0;
-   s/$/;/;
-   }
-   $protos .= $_;
-} elsif (/^FN_(LOCAL|GLOBAL)_([^(]+)\(([^,()]+)/) {
-   $ret = $FN_MAP{$2};
-   $func = $3;
-   $arg = $1 eq 'LOCAL' ? 'int module_id' : 'void';
-   $protos .= "$ret$func($arg);\n";
-} elsif (/^static|^extern/ || /[;]/ || !/^[A-Za-z][A-Za-z0-9_]* /) {
-   ;
-} elsif (/[(].*[)][ \t]*$/) {
-   s/$/;/;
-   $protos .= $_;
-} elsif (/[(]/) {
-   $inheader = 1;
-   $protos .= $_;
-}
-}
-
-if ($old_protos ne $protos) {
-open(OUT, '>proto.h') or die $!;
-print OUT $protos;
-close OUT;
-}
-
-open(OUT, '>proto.h-tstamp') and close OUT;
-- 
2.23.0


-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html