Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
policyd
policyd
Commits
45b514b5
Commit
45b514b5
authored
Apr 01, 2017
by
Nigel Kukard
Browse files
Added additional debugging information and short-circuit optimizations
parent
cf484f1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
cbp/policies.pm
View file @
45b514b5
# Policy handling functions
# Copyright (C) 2009-201
5
, AllWorldIT
# Copyright (C) 2009-201
7
, AllWorldIT
# Copyright (C) 2008, LinuxRulz
#
# This program is free software; you can redistribute it and/or modify
...
...
@@ -100,7 +100,7 @@ sub getPolicy
# Process the Members
foreach
my
$policyMember
(
@
{
$policyMembers
})
{
# Make debugging a bit easier
my
$debugTxt
=
sprintf
('
[
ID:%s/Name:%s]
',
$policyMember
->
{'
ID
'},
$policyMember
->
{'
Name
'});
my
$debugTxt
=
sprintf
('
[
PolicyID:%s/MemberID:%s/Priority:%s/Name:%s]
',
$policyMember
->
{'
PolicyID
'},
$policyMember
->
{'
ID
'},
$policyMember
->
{'
Priority
'},
$policyMember
->
{'
Name
'});
#
# Source Test
...
...
@@ -184,6 +184,7 @@ sub getPolicy
next
if
(
!
$destinationMatch
);
$matchedPolicies
->
{
$policyMember
->
{'
Priority
'}}
->
{
$policyMember
->
{'
PolicyID
'}}
=
1
;
last
;
}
# Work through the list and build our result, which is a priority hash with matches as an array
...
...
@@ -226,6 +227,7 @@ sub getPolicyMembers
@TP@policies.Disabled = 0
AND @TP@policy_members.Disabled = 0
AND @TP@policy_members.PolicyID = @TP@policies.ID
ORDER BY @TP@policies.Priority ASC
');
if
(
!
$sth
)
{
$server
->
log
(
LOG_DEBUG
,"
[POLICIES] Error while selecing policy members from database:
"
.
...
...
@@ -238,14 +240,14 @@ sub getPolicyMembers
while
(
my
$row
=
hashifyLCtoMC
(
$sth
->
fetchrow_hashref
(),
qw( Name Priority PolicyDisabled ID PolicyID Source Destination MemberDisabled )
))
{
# Log what we see
my
$debugTxt
=
sprintf
('
[PolicyID:%s/MemberID:%s/Priority:%s/Name:%s]
',
$row
->
{'
PolicyID
'},
$row
->
{'
ID
'},
$row
->
{'
Priority
'},
$row
->
{'
Name
'});
if
(
$row
->
{'
PolicyDisabled
'}
eq
"
1
")
{
$server
->
log
(
LOG_DEBUG
,"
[POLICIES]
Policy '
"
.
$row
->
{'
Name
'}
.
"
' is disabl
ed
")
if
(
$log
);
$server
->
log
(
LOG_DEBUG
,"
[POLICIES]
$debugTxt
: getPolicyMembers - Policy disabled, policy member not return
ed
")
if
(
$log
);
}
elsif
(
$row
->
{'
MemberDisabled
'}
eq
"
1
")
{
$server
->
log
(
LOG_DEBUG
,"
[POLICIES]
Policy member item with ID '
"
.
$row
->
{'
ID
'}
.
"
' is disabl
ed
")
if
(
$log
);
$server
->
log
(
LOG_DEBUG
,"
[POLICIES]
$debugTxt
: getPOlicyMembers - Policy member disabled, policy member not return
ed
")
if
(
$log
);
}
else
{
$server
->
log
(
LOG_DEBUG
,"
[POLICIES]
Found p
olicy
m
ember
with ID '
"
.
$row
->
{'
ID
'}
.
"
' in policy '
"
.
$row
->
{'
Name
'}
.
"
'
")
if
(
$log
);
$server
->
log
(
LOG_DEBUG
,"
[POLICIES]
$debugTxt
: getP
olicy
M
ember
s - Policy member returned
")
if
(
$log
);
push
(
@policyMembers
,
$row
);
}
}
...
...
Lennard Klein
@lennard
mentioned in issue
#13 (closed)
·
Aug 14, 2017
mentioned in issue
#13 (closed)
mentioned in issue #13
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment