aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-08-30 10:58:41 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-08-30 10:58:41 +0300
commit5ed4f7b0dbc72fde6cb94fb051e87f6264115629 (patch)
treed6689b8c86fc14009bdc109bf48e3fbac4f049cf
parentd45c8b4133e882b3d37ef63930849d714a517010 (diff)
downloadgitaclhook-master.tar.gz
gitaclhook-master.tar.bz2
Use proper logical operatorsHEADmaster
-rw-r--r--lib/GitACL.pm16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/GitACL.pm b/lib/GitACL.pm
index 4c1cc67..2bb78e5 100644
--- a/lib/GitACL.pm
+++ b/lib/GitACL.pm
@@ -155,13 +155,13 @@ sub match_user($$) {
}
sub match_ref($$) {
my ($self, $expr) = @_;
return ($self->{ref} =~ /$expr/) if ($expr =~ /^\^/);
- return ("$self->{ref}/" eq $expr or index($self->{ref}, $expr) == 0)
+ return ("$self->{ref}/" eq $expr || index($self->{ref}, $expr) == 0)
if ($expr =~ /\/$/);
return $self->{ref} eq $expr;
}
sub match_tree($$) {
my ($self, $expr) = @_;
@@ -177,16 +177,16 @@ sub match_tree($$) {
$self->{tree_init} = 1;
}
for (my $i = 0; $i <= $#{$self->{tree}}; ) {
my $dir = $self->{tree}[$i];
- if (($expr =~ /^\^/ and $dir =~ /$expr/)
- or ($expr =~ /\/$/
- and ("$dir/" eq $expr or index($dir, $expr) == 0))
- or $dir eq $expr) {
+ if (($expr =~ /^\^/ && $dir =~ /$expr/)
+ || ($expr =~ /\/$/
+ && ("$dir/" eq $expr or index($dir, $expr) == 0))
+ || $dir eq $expr) {
splice(@{$self->{tree}}, $i, 1);
} else {
++$i;
}
}
@@ -199,13 +199,13 @@ sub match_tuple($$) {
return ( \&deny, "malformed line: " . join(' ', @x) ) unless $#x >= 2;
return ( \&deny, "unknown keyword" )
unless ($x[0] eq 'allow' || $x[0] eq 'deny');
return ( 0, "project mismatch" )
- if ($x[1] ne "all" and $x[1] ne $self->{project_name});
+ if ($x[1] ne "all" && $x[1] ne $self->{project_name});
return ( 0, "user mismatch" )
unless $self->match_user($x[2]);
return ( 0, "op mismatch" )
if ($#x >= 3 && index(uc $x[3], $self->{op}) == -1);
return ( 0, "ref mismatch" )
if ($#x >= 4 && !$self->match_ref($x[4]));
@@ -267,18 +267,18 @@ sub new {
} else {
my ($u) = getpwuid $<;
$obj->{user_name} = $u;
}
$obj->deny("no such user") unless $obj->{user_name};
my $httpdusr = git_value('config', 'hooks.acl.httpd-user');
- if (defined($httpdusr) and $obj->{user_name} eq $httpdusr) {
+ if (defined($httpdusr) && $obj->{user_name} eq $httpdusr) {
$obj->deny("need authenticated user") unless $ENV{AUTH_TYPE};
$obj->{user_name} = $ENV{REMOTE_USER};
$obj->{ip} = $ENV{REMOTE_ADDR};
} else {
- my $ipvar = git_value('config', 'hooks.acl.ip-env-var') or 'SSH_CLIENT';
+ my $ipvar = git_value('config', 'hooks.acl.ip-env-var') || 'SSH_CLIENT';
if (defined($ENV{$ipvar})) {
my @a = split /\S/, $ENV{$ipvar}, 2;
$obj->{ip} = $a[0];
} else {
my $sa = getpeername(STDIN);
if ($sa) {

Return to:

Send suggestions and report system problems to the System administrator.