Skip to content

Commit

Permalink
[backend] make roles available to the scheduler so that checkroles() …
Browse files Browse the repository at this point in the history
…can work
  • Loading branch information
mlschroe committed Apr 29, 2013
1 parent 5b44e8e commit 847592f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
29 changes: 13 additions & 16 deletions src/backend/BSXML.pm
Expand Up @@ -88,6 +88,17 @@ our @flags = (
[ 'access' => @disableenable ],
);

our @roles = (
[[ 'person' =>
'role',
'userid',
]],
[[ 'group' =>
'role',
'groupid',
]],
);

our $download = [
'download' =>
'baseurl',
Expand Down Expand Up @@ -119,14 +130,7 @@ our $proj = [
[ 'devel', =>
'project',
],
[[ 'person' =>
'role',
'userid',
]],
[[ 'group' =>
'role',
'groupid',
]],
@roles,
[ $download ],
$maintenance,
[ 'attributes' =>
Expand Down Expand Up @@ -171,14 +175,7 @@ our $pack = [
'project',
'package',
],
[[ 'person' =>
'role',
'userid',
]],
[[ 'group' =>
'role',
'groupid',
]],
@roles,
@disableenable,
@flags,
'url',
Expand Down
13 changes: 6 additions & 7 deletions src/backend/bs_sched
Expand Up @@ -812,13 +812,13 @@ sub checkroles {
my @oroles;
if (defined($opackid)) {
my $pdata = ($oproj->{'package'} || {})->{$opackid} || {};
push @roles, @{$pdata->{'person'} || []}, @{$pdata->{'group'} || []};
push @oroles, @{$pdata->{'person'} || []}, @{$pdata->{'group'} || []};
}
push @roles, @{$oproj->{'person'} || []}, @{$oproj->{'group'} || []};
push @oroles, @{$oproj->{'person'} || []}, @{$oproj->{'group'} || []};
while ($oprojid =~ /^(.+):/) {
$oprojid = $1;
$oproj = $projpacks->{$oprojid} || {};
push @roles, @{$oproj->{'person'} || []}, @{$oproj->{'group'} || []};
push @oroles, @{$oproj->{'person'} || []}, @{$oproj->{'group'} || []};
}
# make sure every user from oprojid can also access projid
# XXX: check type and roles
Expand All @@ -827,11 +827,10 @@ sub checkroles {
my @rx;
if (exists $r->{'userid'}) {
push @rx, grep {exists($_->{'userid'}) && $_->{'userid'} eq $r->{'userid'}} @roles;
}
if (exists $r->{'groupid'}) {
} elsif (exists $r->{'groupid'}) {
push @rx, grep {exists($_->{'groupid'}) && $_->{'groupid'} eq $r->{'groupid'}} @roles;
}
return 0 unless grep {$_->{'role'} eq $r->{'role'} || $_->{'role'} eq 'maintainer'} @rx;
}
return 0 unless grep {$_->{'role'} eq $r->{'role'} || $_->{'role'} eq 'maintainer'} @rx;
}
return 1;
}
Expand Down
5 changes: 5 additions & 0 deletions src/backend/bs_srcserver
Expand Up @@ -2548,6 +2548,11 @@ sub getprojpack {
for (qw{title description build publish debuginfo useforbuild remoteurl remoteproject download link sourceaccess privacy access lock}) {
$jinfo->{$_} = $proj->{$_} if exists $proj->{$_};
}
if ($proj->{'access'}) {
# we need the roles if the project is protected, see checkroles() in the scheduler
$jinfo->{'person'} = $proj->{'person'} if exists $proj->{'person'};
$jinfo->{'group'} = $proj->{'group'} if exists $proj->{'group'};
}
# Check build flags in project meta data
# packages inherit the project wide settings and may override them
my $pdisabled;
Expand Down

0 comments on commit 847592f

Please sign in to comment.