#!/usr/bin/perl # Name: /usr/local/bin/rrsync Author: Joe Smith 30-Sep-2004 # Purpose: Restricts rsync to subdirectory declared in .ssh/authorized_keys # (should have a symlink in /usr/bin) use Socket; use constant LOGFILE => 'rrsync.log'; my $Usage = <>',LOGFILE) { my ($mm,$hh) = (localtime)[1,2]; my $host = $ENV{SSH_CLIENT} || 'unknown'; $host =~ s/ .*//; # Keep only the client's IP addr $host = gethostbyaddr(inet_aton($host),AF_INET) || $host; $_ = sprintf "%-13s",$host; print LOG "$hh:$mm $_ [$command] =",($dir eq $orig ? " OK" : "> $dir"),"\n"; close LOG; } exec "$cmd $dir" or die "exec($cmd $dir) failed: $? $!"; # Note: This assumes that the rsync protocol will not be maliciously hijacked.