Archived
1
0
This repository has been archived on 2021-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
ACU/hooks/gl-pre-git

39 lines
894 B
Plaintext
Raw Normal View History

2013-09-28 09:15:31 +00:00
#!/usr/bin/env perl
use strict;
use warnings;
use v5.10;
use File::Basename;
use Net::IP;
use ACU::Log;
$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log";
# First, check if the repository is in the YYYY/ directory
exit 0 if ($ENV{GL_REPO} !~ /^2[0-9]{3}\/.+\/.+/);
my $ip = $1 if ($ENV{'SSH_CLIENT'} =~ m/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/);
say "Votre IP est : $ip.";
$ip = Net::IP->new($ip) or die ("IP invalide");
my $schoolnetwork = Net::IP->new('192.168.0.0/16');
if ($ip->overlaps($schoolnetwork) != $IP_A_IN_B_OVERLAP)
{
log ERROR, "Vous n'êtes pas autorisé à envoyer vos modifications depuis cette IP.";
exit 1;
}
my $sshnetwork = Net::IP->new('10.41.253.0/24');
if ($ip->overlaps($sshnetwork) == $IP_A_IN_B_OVERLAP)
{
log ERROR, "Vous n'êtes pas autorisé à envoyer vos modifications depuis cette IP.";
exit 1;
}
exit 0;