summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2013-10-24 10:25:26 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2013-10-24 10:25:26 (GMT)
commit5769594665c28999ecbe76d8c9eda44adff27549 (patch) (side-by-side diff)
treee271fe15eafd1b60fc229a1362517462df4b36fa
parent33ba97cd28f138b49697273e445b479d42bf42a9 (diff)
downloadgitaclhook-5769594665c28999ecbe76d8c9eda44adff27549.tar.gz
gitaclhook-5769594665c28999ecbe76d8c9eda44adff27549.tar.bz2
Take into account the user primary group.
* MANIFEST: Add new files. * lib/GitACL.pm (match_primary_group): New function. (match_user): Use match_primary_group. * lib/GitACL/File.pm (check_acl): Minor fix.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--MANIFEST2
-rw-r--r--lib/GitACL.pm9
-rw-r--r--lib/GitACL/File.pm2
3 files changed, 12 insertions, 1 deletions
diff --git a/MANIFEST b/MANIFEST
index be26d52..4e26ac4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5,3 +5,5 @@ lib/GitACL.pm
lib/GitACL/File.pm
lib/GitACL/LDAP.pm
gitacl.schema
+META.yml Module YAML meta-data (added by MakeMaker)
+META.json Module JSON meta-data (added by MakeMaker)
diff --git a/lib/GitACL.pm b/lib/GitACL.pm
index 57b38b8..f1f792a 100644
--- a/lib/GitACL.pm
+++ b/lib/GitACL.pm
@@ -94,11 +94,20 @@ sub git_value(@) {
return $_;
}
+sub match_primary_group($$) {
+ my ($user_name,$group_name) = @_;
+ my ($name,$passwd,$uid,$gid,$members) = getpwnam($user_name) or return 0;
+ ($name) = getgrgid($gid) or return 0;
+ return 1 if $name eq $group_name;
+ return 0;
+}
+
sub match_user($$) {
my ($self, $expr) = @_;
return 1 if ($expr eq 'all');
return 0 if ($expr eq 'none');
if ($expr =~ /^%(.+)/) {
+ return 1 if match_primary_group($self->{user_name}, $1);
my ($name,$passwd,$gid,$members) = getgrnam($1) or return 0;
my @a = split(/\s+/,$members);
for (my $i = 0; $i <= $#a; $i++) {
diff --git a/lib/GitACL/File.pm b/lib/GitACL/File.pm
index 49378b0..8842ffd 100644
--- a/lib/GitACL/File.pm
+++ b/lib/GitACL/File.pm
@@ -24,7 +24,7 @@ sub check_acl {
my @ret;
my $filename = GitACL::git_value('config', 'hooks.aclfile');
- $self->allow("no ACL configured for $self->project_name")
+ $self->allow("no ACL configured for ".$self->project_name)
unless defined($filename);
open($fd, "<", $filename)

Return to:

Send suggestions and report system problems to the System administrator.