[Dnsmasq-discuss] Execute external commands on DHCP lease
allocation / deallocation
Fabio Muzzi
liste at kurgan.org
Mon Apr 24 22:42:09 BST 2006
Hello Simon,
Monday, April 24, 2006, 10:03:47 PM, you wrote:
SK> This has been asked for before, and I've always said "no", it would be
SK> better to use Dbus for IPC. However, as far as I can see nobody uses
SK> DBus for that, so maybe I'm wrong.
If you think it's better, try using Dbus. I doesn't matter *how*, but I
need this feature, and I have seen that I'm not the only one, it's quite a
common need for people running capitive portals.
SK> Just as an experiment, I tried to implement an external script. It's not
SK> quite as easy as it looks: you need to call "new lease" for every lease
SK> in the database when dnsmasq starts up, and that can be a lot of leases.
SK> If you just fork processes and run them asynchronously, then starting
SK> dnsmasq when it has a few hundred leases generates a flood of hundreds
SK> of child processes running the script. That would swamp a small machine,
SK> and it makes the script much more difficult to write, if it has to lock
SK> against concurrent execution.
Agreed. Actually, on startup you could also ignore the leases that are
already stored in the lease file. I mean, if the gateway reboots, every
client will have to re-autenticate, but this is not a great issue, because
the gateway MUST NOT reboot in normal operation. Or did I miss something?
SK> My second attempt serialises script execution: it waits for the first
SK> child process to die before lauching another one.
This is a nice solution. It's up to the user to write a script that runs
fast and does not make the startup process too slow. You can't make
miracles after all.
SK> That works much better, but it needs more work to use the lease
SK> records to keep information about script execution. (You can't throw
SK> away a lease record when it expires until you've run the script.)
Well, you can execute the "expire" call to the script exactly when you
delete the old record from the lease file, or am I wrong?
SK> The old problem of userid still exists.
Yes, and for the first test I will run as root. Then I'll see if I can
find a better way.
Thanks a lot for your help, I'll try the patched version tomorrow morning
and report back as soon as I can.
--
Fabio "Kurgan" Muzzi
More information about the Dnsmasq-discuss
mailing list