Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
483980c6
Commit
483980c6
authored
Mar 30, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(unbound_dhcpd) style fixes
parent
b34f61cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
unbound_dhcpd.py
src/opnsense/scripts/dns/unbound_dhcpd.py
+11
-6
No files found.
src/opnsense/scripts/dns/unbound_dhcpd.py
View file @
483980c6
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
"""
"""
import
os
import
os
import
sys
import
sys
sys
.
path
.
insert
(
0
,
"/usr/local/opnsense/site-python"
)
sys
.
path
.
insert
(
0
,
"/usr/local/opnsense/site-python"
)
import
subprocess
import
subprocess
import
time
import
time
...
@@ -38,6 +39,7 @@ from daemonize import Daemonize
...
@@ -38,6 +39,7 @@ from daemonize import Daemonize
import
watchers.dhcpd
import
watchers.dhcpd
import
params
import
params
def
unbound_control
(
commands
,
output_stream
=
None
):
def
unbound_control
(
commands
,
output_stream
=
None
):
""" execute (chrooted) unbound-control command
""" execute (chrooted) unbound-control command
:param commands: command list (parameters)
:param commands: command list (parameters)
...
@@ -45,8 +47,8 @@ def unbound_control(commands, output_stream=None):
...
@@ -45,8 +47,8 @@ def unbound_control(commands, output_stream=None):
:return: None
:return: None
"""
"""
output_stream
=
open
(
os
.
devnull
,
'w'
)
output_stream
=
open
(
os
.
devnull
,
'w'
)
subprocess
.
check_call
([
'/usr/sbin/chroot'
,
'-u'
,
'unbound'
,
'-g'
,
'unbound'
,
'/'
,
subprocess
.
check_call
([
'/usr/sbin/chroot'
,
'-u'
,
'unbound'
,
'-g'
,
'unbound'
,
'/'
,
'/usr/local/sbin/unbound-control'
,
'-c'
,
'/var/unbound/unbound.conf'
]
+
commands
,
'/usr/local/sbin/unbound-control'
,
'-c'
,
'/var/unbound/unbound.conf'
]
+
commands
,
stdout
=
output_stream
,
stderr
=
subprocess
.
STDOUT
)
stdout
=
output_stream
,
stderr
=
subprocess
.
STDOUT
)
output_stream
.
seek
(
0
)
output_stream
.
seek
(
0
)
...
@@ -64,13 +66,15 @@ def unbound_known_addresses():
...
@@ -64,13 +66,15 @@ def unbound_known_addresses():
result
.
append
(
parts
[
4
])
result
.
append
(
parts
[
4
])
return
result
return
result
# parse input params
# parse input params
app_params
=
{
'pid'
:
'/var/run/unbound_dhcpd.pid'
,
app_params
=
{
'pid'
:
'/var/run/unbound_dhcpd.pid'
,
'domain'
:
'local'
,
'domain'
:
'local'
,
'target'
:
'/var/unbound/dhcpleases.conf'
,
'target'
:
'/var/unbound/dhcpleases.conf'
,
'background'
:
'1'
}
'background'
:
'1'
}
params
.
update_params
(
app_params
)
params
.
update_params
(
app_params
)
def
main
():
def
main
():
# cleanup interval (seconds)
# cleanup interval (seconds)
cleanup_interval
=
60
cleanup_interval
=
60
...
@@ -118,6 +122,7 @@ def main():
...
@@ -118,6 +122,7 @@ def main():
# wait for next cycle
# wait for next cycle
time
.
sleep
(
1
)
time
.
sleep
(
1
)
# startup
# startup
if
app_params
[
'background'
]
==
'1'
:
if
app_params
[
'background'
]
==
'1'
:
daemon
=
Daemonize
(
app
=
"unbound_dhcpd"
,
pid
=
app_params
[
'pid'
],
action
=
main
)
daemon
=
Daemonize
(
app
=
"unbound_dhcpd"
,
pid
=
app_params
[
'pid'
],
action
=
main
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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