added peer IP address validation
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 29 Aug 2020 06:20:18 +0000 (08:20 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 29 Aug 2020 06:20:18 +0000 (08:20 +0200)
bak-git-server.pl

index fac76b7..b4c7eec 100755 (executable)
@@ -180,7 +180,14 @@ sub mkbasedir {
 while (my $client = $server->accept()) {
        my $line = <$client>;
        chomp($line);
-       warn "<<< $line\n";
+
+       my $peerhost = $client->peerhost;
+       if ( $peerhost !~ m/^(10\.13\.37\.|10\.60\.0\.)/ ) {
+               print $client "$peerhost not allowed\n";
+               next;
+       }
+
+       warn "<<< $peerhost $line\n";
        my ($user,$hostname,$pwd,$command,$rel_path,$message) = split(/\s+/,$line,6);
        $hostname =~ s/\..+$//;