Commit 78edc3a5 authored by Kevin Falcone's avatar Kevin Falcone
Browse files

Fix "already granted" logic

When the language for this changed in b29757e this stopped working.
Rather than regexing the error message, just check if the right exists.
parent af64dc21
......@@ -248,13 +248,14 @@ sub grant_group_queue_rights {
foreach my $queue (values %$queues) {
debug "Granting rights for queue " .$queue->Name. " to group ". $group->Name;
foreach my $right (@rights) {
my ($val,$msg) = $group->PrincipalObj->GrantRight(Right => $right, Object=>$queue);
debug "\t$right\n";
if ( $group->PrincipalObj->HasRight( Right => $right, Object => $queue ) ) {
debug "\t...skipped, already granted";
next;
}
my ($val,$msg) = $group->PrincipalObj->GrantRight(Right => $right, Object=>$queue);
if ( $val ) {
debug "\t...done.";
}
elsif ( $msg =~ /That principal already has that right/i ) {
debug "\t...skipped, already granted.\n";
} else {
die "Failed to grant $right to ". $group->Name ." for Queue ". $queue->Name;
}
......@@ -276,13 +277,14 @@ sub grant_group_cf_rights {
debug "Granting rights for custom field ". $cf->Name . " to group ". $group->Name;
foreach my $right (@rights) {
my ($val,$msg) = $group->PrincipalObj->GrantRight(Right => $right, Object=>$cf);
debug "\t$right";
if ( $group->PrincipalObj->HasRight( Right => $right, Object => $cf ) ) {
debug "\t...skipped, already granted";
next;
}
my ($val,$msg) = $group->PrincipalObj->GrantRight(Right => $right, Object=>$cf);
if ( $val ) {
debug "\t...done.";
}
elsif ( $msg =~ /That principal already has that right/i ) {
debug "\t...skipped, already granted.\n";
} else {
die "Failed to grant $right to ".$group->Name. " for Custom Field ". $cf->Name
.".\nError: $msg";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment