diff options
author | Wayne Davison <wayned@samba.org> | 2015-09-13 16:15:17 -0700 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2015-09-13 16:23:54 -0700 |
commit | bb853b32055a16e983267c6f5b8244aac311fdf9 (patch) | |
tree | 6a7069e316d6ff8547051390f30bdf8b09a71092 /support/rrsync | |
parent | cce44865c1ac64a434390b96489252ed576ef951 (diff) | |
download | rsync-bb853b32055a16e983267c6f5b8244aac311fdf9.tar.gz |
Add -wo option for write-only rrsync mode.
Diffstat (limited to 'support/rrsync')
-rw-r--r-- | support/rrsync | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/support/rrsync b/support/rrsync index 5d2b8ae0..9195aa2f 100644 --- a/support/rrsync +++ b/support/rrsync @@ -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, |