Problem: dnsmasq.init / dhcp-user-script not executed

Daniel Golle daniel at makrotopia.org
Thu Nov 11 06:29:50 PST 2021


On Thu, Nov 11, 2021 at 07:36:46AM +0000, Bastian Bittorf wrote:
> Introduced with:
> 
> ---
> commit 8b486ec2b52056b737a4ce64a2040a9a27a6bd60
> Author: Hans Dedecker <dedeckeh at gmail.com>
> Date:   Fri Jun 9 16:24:12 2017 +0200
> 
>     dnsmasq: add dhcp-script hook conditionally
> ---
> 
> breaks parsing of user provided dhcp-script for me:
> 
> uci set dhcp. at dnsmasq[0].dhcpscript='/etc/dhcp-script.d/10dhcpscript'
> /etc/init.d/dnsmasq restart
> 
> but in generated configfile we always have the default:
> /usr/lib/dnsmasq/dhcp-script.sh
> 
> A fix in line 994 of package/network/services/dnsmasq/files/dnsmasq.init can be:
> 
> config_get user_dhcpscript $cfg dhcpscript
>   if has_handler || [ -n "$user_dhcpscript" ]; then
>   xappend "--dhcp-script=$DHCPSCRIPT"
> 
> TO:
> 
> config_get user_dhcpscript $cfg dhcpscript
>   if has_handler || [ -n "$user_dhcpscript" ]; then
>   xappend "--dhcp-script=$user_dhcpscript"
> 
> but maybe this breaks the default script?!

The default script should call the user-script, however, that depends
on the USER_SCRIPT environment variable which until now wasn't passed
down from ujail to the process environment.
I've fixed that with commit 9224ddf72d ("procd: update to git HEAD").

However, you may still need to give your user-defined script access
to what ever it needs to touch, ie. add paths using
procd_add_jail_mount{,_rw}.

Note that alternatively you can also use the hotplug interface which
allows your script to run as root and outside of the jail.

Simply create the folder /etc/hotplug.d/dhcp/ (or /etc/hotplug.d/neigh/
or /etc/hotplug.d/tftp, depending on which event your script is
handling) and place your script there, that will do the trick.
You will find the environment variables set by dnsmasq being
passed-through, so your script doesn't need to be modified.



More information about the openwrt-devel mailing list