Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Dnsmasq
Commits
57f460de
Commit
57f460de
authored
Feb 16, 2012
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweak Lua script argument passing and add --dhcp-luascript sectino to manpage.
parent
6caacacf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
+42
-5
man/dnsmasq.8
man/dnsmasq.8
+37
-2
src/helper.c
src/helper.c
+4
-2
src/rfc2131.c
src/rfc2131.c
+1
-1
No files found.
man/dnsmasq.8
View file @
57f460de
...
@@ -1082,7 +1082,7 @@ If the client provides vendor-class, DNSMASQ_VENDOR_CLASS_ID,
...
@@ -1082,7 +1082,7 @@ If the client provides vendor-class, DNSMASQ_VENDOR_CLASS_ID,
containing the IANA enterprise id for the class, and
containing the IANA enterprise id for the class, and
DNSMASQ_VENDOR_CLASS0..DNSMASQ_VENDOR_CLASSn for the data.
DNSMASQ_VENDOR_CLASS0..DNSMASQ_VENDOR_CLASSn for the data.
DNSMASQ_DUID containing the DUID of the server: this is the same for
DNSMASQ_
SERVER_
DUID containing the DUID of the server: this is the same for
every call to the script.
every call to the script.
DNSMASQ_IAID containing the IAID for the lease. If the lease is a
DNSMASQ_IAID containing the IAID for the lease. If the lease is a
...
@@ -1115,8 +1115,43 @@ leases will be called with "del" and others with "old". When dnsmasq
...
@@ -1115,8 +1115,43 @@ leases will be called with "del" and others with "old". When dnsmasq
receives a HUP signal, the script will be invoked for existing leases
receives a HUP signal, the script will be invoked for existing leases
with an "old " event.
with an "old " event.
.TP
.TP
.B --dhcp-luascript=<path>
Specify a script written in Lua, to be run when leases are created,
destroyed or changed. To use this option, dnsmasq must be compiled
with the correct support. The Lua interpreter is intialised once, when
dnsmasq starts, so that global variables persist between lease
events. The Lua code must define a
.B lease
function, and may provide
.B init
and
.B shutdown
functions, which are called, without arguments when dnsmasq starts up
and terminates.
The
.B lease
method receives the information detailed in
.B --dhcp-script.
It gets two arguments, firstly the action, which is a string
containing, "add", "old" or "del", and secondly a table of tag value
pairs. The tags mostly correspond to the environment variables
detailed above, for instance the tag "domain" holds the same data as
the environment variable DNSMASQ_DOMAIN. There are a few extra tags
which hold the data supplied as arguments to
.B --dhcp-script.
These are
.B mac_address, ip_address
and
.B hostname
for IPv4, and
.B client_duid, ip_address
and
.B hostname
for IPv6.
.TP
.B --dhcp-scriptuser
.B --dhcp-scriptuser
Specify the user as which to run the lease-change script. This defaults to root, but can be changed to another user using this flag.
Specify the user as which to run the lease-change script
or Lua script
. This defaults to root, but can be changed to another user using this flag.
.TP
.TP
.B \-9, --leasefile-ro
.B \-9, --leasefile-ro
Completely suppress use of the lease database file. The file will not
Completely suppress use of the lease database file. The file will not
...
...
src/helper.c
View file @
57f460de
...
@@ -298,8 +298,10 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
...
@@ -298,8 +298,10 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
if
(
is6
)
if
(
is6
)
{
{
lua_pushstring
(
lua
,
daemon
->
dhcp_buff
);
lua_setfield
(
lua
,
-
2
,
"client_duid"
);
lua_pushstring
(
lua
,
daemon
->
packet
);
lua_pushstring
(
lua
,
daemon
->
packet
);
lua_setfield
(
lua
,
-
2
,
"duid"
);
lua_setfield
(
lua
,
-
2
,
"
server_
duid"
);
lua_pushstring
(
lua
,
daemon
->
dhcp_buff3
);
lua_pushstring
(
lua
,
daemon
->
dhcp_buff3
);
lua_setfield
(
lua
,
-
2
,
"iaid"
);
lua_setfield
(
lua
,
-
2
,
"iaid"
);
}
}
...
@@ -440,7 +442,7 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
...
@@ -440,7 +442,7 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
if
(
is6
)
if
(
is6
)
{
{
my_setenv
(
"DNSMASQ_IAID"
,
daemon
->
dhcp_buff3
,
&
err
);
my_setenv
(
"DNSMASQ_IAID"
,
daemon
->
dhcp_buff3
,
&
err
);
my_setenv
(
"DNSMASQ_DUID"
,
daemon
->
packet
,
&
err
);
my_setenv
(
"DNSMASQ_
SERVER_
DUID"
,
daemon
->
packet
,
&
err
);
}
}
if
(
!
is6
&&
data
.
clid_len
!=
0
)
if
(
!
is6
&&
data
.
clid_len
!=
0
)
...
...
src/rfc2131.c
View file @
57f460de
...
@@ -2096,7 +2096,7 @@ static void do_options(struct dhcp_context *context,
...
@@ -2096,7 +2096,7 @@ static void do_options(struct dhcp_context *context,
/* filter options based on tags, those we want get DHOPT_TAGOK bit set */
/* filter options based on tags, those we want get DHOPT_TAGOK bit set */
context
->
netid
.
next
=
NULL
;
context
->
netid
.
next
=
NULL
;
tagif
=
option_filter
(
netid
,
context
->
netid
.
net
?
&
context
->
netid
:
NULL
,
config_opts
);
tagif
=
option_filter
(
netid
,
context
&&
context
->
netid
.
net
?
&
context
->
netid
:
NULL
,
config_opts
);
/* logging */
/* logging */
if
(
option_bool
(
OPT_LOG_OPTS
)
&&
req_options
)
if
(
option_bool
(
OPT_LOG_OPTS
)
&&
req_options
)
...
...
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