use constant LOGFILE => 'rrsync.log';
my $Usage = <<EOM;
-Use 'command="$0 [-ro|-wo] SUBDIR"'
- in front of lines in $ENV{HOME}/.ssh/authorized_keys
+Use 'command="$0 [-ro|-wo|-no-munge] SUBDIR"'
+ in front of lines in $ENV{HOME}/.ssh/authorized_keys
EOM
-# Handle the -ro and -wo options.
+# Handle the -ro, -wo, & -no-munge options.
our $only = '';
-while (@ARGV && $ARGV[0] =~ /^-([rw])o$/) {
+our $force_munge = 1;
+while (@ARGV) {
+ if ($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";
+ die "$0: the -ro and -wo options conflict.\n";
}
$only = $r_or_w;
- shift;
+ } elsif ($ARGV[0] eq '-no-munge') {
+ $force_munge = 0;
+ } else {
+ last;
+ }
+ shift;
}
our $subdir = shift;
# SSH_CONNECTION=client_addr client_port server_port
my $command = $ENV{SSH_ORIGINAL_COMMAND};
-die "$0: Not invoked via sshd\n$Usage" unless defined $command;
+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!
'link-dest' => 2,
'links' => 0,
'list-only' => 0,
- 'log-file' => $only eq 'r' ? -1 : 3,
+ 'log-file' => 3,
'log-format' => 1,
'max-alloc' => 1,
'max-delete' => 1,
'mkpath' => 0,
'modify-window' => 1,
'msgs2stderr' => 0,
+ 'munge-links' => 0,
'new-compress' => 0,
'no-W' => 0,
'no-implied-dirs' => 0,
'no-msgs2stderr' => 0,
+ 'no-munge-links' => -1,
'no-r' => 0,
'no-relative' => 0,
'no-specials' => 0,
'perms' => 0,
'preallocate' => 0,
'recursive' => 0,
- 'remove-sent-files' => $only eq 'r' ? -1 : 0,
- 'remove-source-files' => $only eq 'r' ? -1 : 0,
+ 'remove-sent-files' => 0,
+ 'remove-source-files' => 0,
'safe-links' => 0,
- 'sender' => $only eq 'w' ? -1 : 0,
+ 'sender' => 0,
'server' => 0,
'size-only' => 0,
'skip-compress' => 1,
### END of options data produced by the cull_options script. ###
+if ($only eq 'r') {
+ foreach my $opt (keys %long_opt) {
+ if ($opt =~ /^(remove-|log-file)/) {
+ $long_opt{$opt} = -1;
+ }
+ }
+} elsif ($only eq 'w') {
+ $long_opt{'sender'} = -1;
+}
+
if ($short_disabled ne '') {
$short_no_arg =~ s/[$short_disabled]//go;
$short_with_num =~ s/[$short_disabled]//go;
push(@opts, check_arg($last_opt, $_, $check_type));
$check_type = 0;
} elsif ($in_options) {
- push(@opts, $_);
if ($_ eq '.') {
$in_options = 0;
} else {
die "$0: invalid option: '-'\n" if $_ eq '-';
+ push(@opts, $_);
next if /^-$short_no_arg*(e\d*\.\w*)?$/o || /^-$short_with_num\d+$/o;
my($opt,$arg) = /^--([^=]+)(?:=(.*))?$/;
die "$0: invalid rsync-command syntax or options\n" if $in_options;
if ($subdir ne '/') {
- die "$0: do not use .. in any path!\n" if grep m{(^|/)\.\.(/|$)}, @args;
+ die "$0: do not use .. in any path!\n" if grep m{(^|/)\.\.(/|$)}, @args;
+}
+
+if ($force_munge) {
+ push(@opts, '--munge-links');
}
@args = ( '.' ) if !@args;
}
# Note: This assumes that the rsync protocol will not be maliciously hijacked.
-exec(RSYNC, @opts, '--', @args) or die "exec(rsync @opts -- @args) failed: $? $!";
+exec(RSYNC, @opts, '--', '.', @args) or die "exec(rsync @opts -- . @args) failed: $? $!";
sub check_arg
{
}
$arg;
}
+
+# vim: sw=2