Add -wo option for write-only rrsync mode.
authorWayne Davison <wayned@samba.org>
Sun, 13 Sep 2015 23:15:17 +0000 (16:15 -0700)
committerWayne Davison <wayned@samba.org>
Sun, 13 Sep 2015 23:23:54 +0000 (16:23 -0700)
NEWS
support/rrsync

diff --git a/NEWS b/NEWS
index 3ab8b2df6cfcc35818e51a138882fa241993cac9..10719884b91989a548e16d1126d1257d83da869f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,7 @@ Changes since 3.1.1:
       BackupPC happier.
     - Made configure choose to use linux xattrs on netbsd (rather than not
       supporting xattrs).
+    - Added -wo (write-only) option to rrsync support script.
     - Misc. manpage tweaks.
 
   DEVELOPER RELATED:
index 5d2b8ae0ab089ff24c1ed7bb02769c37197793a8..9195aa2f61bddd7d2598a1a573964f5a9c84a3a2 100644 (file)
@@ -15,11 +15,21 @@ use constant RSYNC => '/usr/bin/rsync';
 use constant LOGFILE => 'rrsync.log';
 
 my $Usage = <<EOM;
-Use 'command="$0 [-ro] SUBDIR"'
+Use 'command="$0 [-ro|-wo] SUBDIR"'
        in front of lines in $ENV{HOME}/.ssh/authorized_keys
 EOM
 
-our $ro = (@ARGV && $ARGV[0] eq '-ro') ? shift : '';   # -ro = Read-Only
+# Handle the -ro and -wo options.
+our $only = '';
+while (@ARGV && $ARGV[0] =~ /^-([rw])o$/) {
+    my $r_or_w = $1;
+    if ($only && $only ne $r_or_w) {
+       die "$0: the -ro and -wo options conflict.\n";
+    }
+    $only = $r_or_w;
+    shift;
+}
+
 our $subdir = shift;
 die "$0: No subdirectory specified\n$Usage" unless defined $subdir;
 $subdir = abs_path($subdir);
@@ -41,7 +51,8 @@ die "$0: Not invoked via sshd\n$Usage"        unless defined $command;
 die "$0: SSH_ORIGINAL_COMMAND='$command' is not rsync\n" unless $command =~ s/^rsync\s+//;
 die "$0: --server option is not first\n" unless $command =~ /^--server\s/;
 our $am_sender = $command =~ /^--server\s+--sender\s/; # Restrictive on purpose!
-die "$0 -ro: sending to read-only server not allowed\n" if $ro && !$am_sender;
+die "$0 sending to read-only server not allowed\n" if $only eq 'r' && !$am_sender;
+die "$0 reading from write-only server not allowed\n" if $only eq 'w' && $am_sender;
 
 ### START of options data produced by the cull_options script. ###
 
@@ -116,8 +127,8 @@ our %long_opt = (
   'perms' => 0,
   'preallocate' => 0,
   'recursive' => 0,
-  'remove-sent-files' => $ro ? -1 : 0,
-  'remove-source-files' => $ro ? -1 : 0,
+  'remove-sent-files' => $only eq 'r' ? -1 : 0,
+  'remove-source-files' => $only eq 'r' ? -1 : 0,
   'safe-links' => 0,
   'sender' => 0,
   'server' => 0,