From 10b5f6cbc4c19f77ea54602b4f3c210e9aa5445e Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Fri, 29 Sep 2017 08:00:32 +0100 Subject: [PATCH] fix bug in where workerconf acls are checked --- lib/App/Netdisco/Worker/Plugin.pm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin.pm b/lib/App/Netdisco/Worker/Plugin.pm index 70967456..6101f601 100644 --- a/lib/App/Netdisco/Worker/Plugin.pm +++ b/lib/App/Netdisco/Worker/Plugin.pm @@ -26,20 +26,24 @@ register 'register_worker' => sub { my $worker = sub { my $job = shift or return Status->error('missing job param'); - my $no = (exists $workerconf->{no} ? $workerconf->{no} : undef); - my $only = (exists $workerconf->{only} ? $workerconf->{only} : undef); + # worker might be vendor/platform specific + if (ref $job->device) { + my $no = (exists $workerconf->{no} ? $workerconf->{no} : undef); + my $only = (exists $workerconf->{only} ? $workerconf->{only} : undef); + + my $defer = Status->defer('worker is not applicable to this device'); + return $defer if $no and check_acl_no($job->device, $no); + return $defer if $only and not check_acl_only($job->device, $only); + } my @newuserconf = (); my @userconf = @{ setting('device_auth') || [] }; - # reduce device_auth by driver, worker's only/no + # reduce device_auth by driver foreach my $stanza (@userconf) { - if (ref $job->device) { - next if $no and check_acl_no($job->device, $no); - next if $only and not check_acl_only($job->device, $only); - } next if exists $stanza->{driver} and exists $workerconf->{driver} and (($stanza->{driver} || '') ne ($workerconf->{driver} || '')); + push @newuserconf, $stanza; }