Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-26 Thread Simon Kelley
On 25/03/12 17:02, Shantanu Gadgil wrote:
> Hi,
> 
> What I was suggesting in my previous post was ...
> 
> lets consider the following as a possible scenario ...
> --- snip ---
> tftp-script=/path/to/mytftpscript
> dhcp-script=/path/to/mydhcpscript
> dhcp6-script=/path/to/mydhcp6script
> dns-script=/path/to/dnsscript
> dns6-script=/path/to/dns6script
> --- snip ---
> 
> [root@server ~]# ls -l /path/to/mytftpscript
> lrwxrwxrwx.   1 root root   3 Mar 21 00:20 /path/to/mytftpscript -> 
> mycommonscript
> [root@server ~]# ls -l /path/to/mydhcpscript
> lrwxrwxrwx.   1 root root   3 Mar 21 00:20 /path/to/mydhcpscript -> 
> mycommonscript
> [root@server ~]# ls -l /path/to/mydhcp6script
> lrwxrwxrwx.   1 root root   3 Mar 21 00:20 /path/to/mydhcp6script -> 
> mycommonscript
> 
> ... and so on ...
> 
> The "mycommonscript" should have the necessary logic to decide which "script" 
> is actually being called based of the value of "$0" (argv[0] in C speak) (the 
> actual filename)
> 
> Keeping it this way would allow you to separate the "$1" value for the 
> various possibilities, and not have to worry about script breakage during 
> adding more parameters.
> It becomes the script-writer's headache to cater/handle parameters as they 
> appear (!)
> 
> The very attractive part here is that the user has to maintain only a single 
> script.
> 

That's attractive, except that it increases the already vast number of
configuration options in dnsmasq, and it doesn't work correspondingly on
the Lua side, where there can be only one Lua script file, but functions
for each  (dhcp, tftp, dhcp6, etc etc)

I think the way to go is to call dhcp-script with $1 as "tftp"


Cheers,

Simon.

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-25 Thread Shantanu Gadgil
Hi,

What I was suggesting in my previous post was ...

lets consider the following as a possible scenario ...
--- snip ---
tftp-script=/path/to/mytftpscript
dhcp-script=/path/to/mydhcpscript
dhcp6-script=/path/to/mydhcp6script
dns-script=/path/to/dnsscript
dns6-script=/path/to/dns6script
--- snip ---

[root@server ~]# ls -l /path/to/mytftpscript
lrwxrwxrwx.   1 root root   3 Mar 21 00:20 /path/to/mytftpscript -> 
mycommonscript
[root@server ~]# ls -l /path/to/mydhcpscript
lrwxrwxrwx.   1 root root   3 Mar 21 00:20 /path/to/mydhcpscript -> 
mycommonscript
[root@server ~]# ls -l /path/to/mydhcp6script
lrwxrwxrwx.   1 root root   3 Mar 21 00:20 /path/to/mydhcp6script -> 
mycommonscript

... and so on ...

The "mycommonscript" should have the necessary logic to decide which "script" 
is actually being called based of the value of "$0" (argv[0] in C speak) (the 
actual filename)

Keeping it this way would allow you to separate the "$1" value for the various 
possibilities, and not have to worry about script breakage during adding more 
parameters.
It becomes the script-writer's headache to cater/handle parameters as they 
appear (!)

The very attractive part here is that the user has to maintain only a single 
script.

Regards,
Shantanu


--- On Wed, 3/21/12, Simon Kelley  wrote:

> From: Simon Kelley 
> Subject: Re: [Dnsmasq-discuss] Feature Request: tftp-script
> To: dnsmasq-discuss@lists.thekelleys.org.uk
> Date: Wednesday, March 21, 2012, 5:35 PM
> On 21/03/12 11:49, Ed W wrote:
> > On 21/03/2012 09:50, Simon Kelley wrote:
> >> http://www.thekelleys.org.uk/dnsmasq/test-releases/dnsmasq-2.61test7.tar.gz
> >>
> >>
> >> Has the "tftp" action implemented. At the moment
> it's sent to the
> >> --dhcp-script script always. I'm still tending
> towards that solution,
> >> but haven't made the final decision. The bulk of
> the changes are done
> >> anyway.
> >
> > Just from the point of view of longer term plans.
> Recently I actually
> > read the documentation on Nginx perl (I think I put in
> the correct link
> > below?).
> > http://zzzcpan.github.com/nginx-perl/
> >
> > The point of looking is simply that at first sight,
> embedding a
> > relatively slow scripting language looks troublesome
> and a performance
> > issue. However, I was quite surprised at just HOW
> embedded is perl in
> > what is perhaps one of the highest performing network
> server software we
> > have to study at the moment
> >
> > Lua would seem like a better bet for dnsmasq (than
> perl) due to the very
> > low installation size. Also performance is alleged to
> be extremely high
> > (for a scripting language) and the runtime is designed
> with
> > embeddability in mind. Nginx also allows embedded lua,
> although I
> > haven't studied to see if they achieve similar levels
> of integration
> >
> > I have an application (captive portal) where it would
> be quite
> > interesting to "manufacture" answers under some
> conditions, tweak
> > answers under others, and also "cheat" on caching
> timeouts in specific
> > situations (if the user if offline/dialup for
> example).
> >
> > Just trying to put ideas into your head...
> >
> 
> Ed,
> 
> It's not quite clear if you've looked at dnsmasq-2.60+ or
> not. Try
> 
> 
> make COPTS=-DHAVE_LUASCRIPT
> 
> Lua got there first.
> 
> 
> There's an architectural problem with all the scripting (Lua
> and 
> fork/exec) in dnsmasq at the moment; there's no sensible way
> to get 
> information from the script back to dnsmasq. Events in
> dnsmasq get sent 
> asynchronously down a pipe to a distinct the process which
> then runs the 
> script. This achieves 1) privilege separation. 2) Script
> can't block 
> dnsmasq - especially important when dnsmasq is a bit of a
> swiss-army knife.
> 
> There is a back-channel for errors, which could be expanded.
> But there's 
> no sensible way at the moment to make dnsmasq wait whilst
> (eg) a script 
> tweaks a DNS answer.
> 
> Cheers,
> 
> Simon.
> 
> 
> 
> 
> 
> ___
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss@lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
> 

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-21 Thread Simon Kelley

On 21/03/12 11:49, Ed W wrote:

On 21/03/2012 09:50, Simon Kelley wrote:

http://www.thekelleys.org.uk/dnsmasq/test-releases/dnsmasq-2.61test7.tar.gz


Has the "tftp" action implemented. At the moment it's sent to the
--dhcp-script script always. I'm still tending towards that solution,
but haven't made the final decision. The bulk of the changes are done
anyway.


Just from the point of view of longer term plans. Recently I actually
read the documentation on Nginx perl (I think I put in the correct link
below?).
http://zzzcpan.github.com/nginx-perl/

The point of looking is simply that at first sight, embedding a
relatively slow scripting language looks troublesome and a performance
issue. However, I was quite surprised at just HOW embedded is perl in
what is perhaps one of the highest performing network server software we
have to study at the moment

Lua would seem like a better bet for dnsmasq (than perl) due to the very
low installation size. Also performance is alleged to be extremely high
(for a scripting language) and the runtime is designed with
embeddability in mind. Nginx also allows embedded lua, although I
haven't studied to see if they achieve similar levels of integration

I have an application (captive portal) where it would be quite
interesting to "manufacture" answers under some conditions, tweak
answers under others, and also "cheat" on caching timeouts in specific
situations (if the user if offline/dialup for example).

Just trying to put ideas into your head...



Ed,

It's not quite clear if you've looked at dnsmasq-2.60+ or not. Try


make COPTS=-DHAVE_LUASCRIPT

Lua got there first.


There's an architectural problem with all the scripting (Lua and 
fork/exec) in dnsmasq at the moment; there's no sensible way to get 
information from the script back to dnsmasq. Events in dnsmasq get sent 
asynchronously down a pipe to a distinct the process which then runs the 
script. This achieves 1) privilege separation. 2) Script can't block 
dnsmasq - especially important when dnsmasq is a bit of a swiss-army knife.


There is a back-channel for errors, which could be expanded. But there's 
no sensible way at the moment to make dnsmasq wait whilst (eg) a script 
tweaks a DNS answer.


Cheers,

Simon.





___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-21 Thread Ed W

On 21/03/2012 09:50, Simon Kelley wrote:
http://www.thekelleys.org.uk/dnsmasq/test-releases/dnsmasq-2.61test7.tar.gz 



Has the "tftp" action implemented. At the moment it's sent to the 
--dhcp-script script always. I'm still tending towards that solution, 
but haven't made the final decision. The bulk of the changes are done 
anyway.


Just from the point of view of longer term plans.  Recently I actually 
read the documentation on Nginx perl (I think I put in the correct link 
below?).

http://zzzcpan.github.com/nginx-perl/

The point of looking is simply that at first sight, embedding a 
relatively slow scripting language looks troublesome and a performance 
issue.  However, I was quite surprised at just HOW embedded is perl in 
what is perhaps one of the highest performing network server software we 
have to study at the moment


Lua would seem like a better bet for dnsmasq (than perl) due to the very 
low installation size.  Also performance is alleged to be extremely high 
(for a scripting language) and the runtime is designed with 
embeddability in mind.  Nginx also allows embedded lua, although I 
haven't studied to see if they achieve similar levels of integration


I have an application (captive portal) where it would be quite 
interesting to "manufacture" answers under some conditions, tweak 
answers under others, and also "cheat" on caching timeouts in specific 
situations (if the user if offline/dialup for example).


Just trying to put ideas into your head...

All the best

Ed W



___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-21 Thread Simon Kelley

On 21/03/12 07:24, Shantanu Gadgil wrote:

Hi,

I think it would be OK to add different "--*-script" commands. So you can have 
'dhcp6-script', 'tftp-script' ... possibly 'dns-script', etc, etc.

I know that I would like to have a single script to deal with each of these, 
and that IS how I would do it.
The way I would do (and usually is done) is that /each/ of the --*-script command would 
point to a *different* file; each of which is a symlink to the same "real" file!

The "real" script should look at '$0' and figure out which "action" is 
triggering self and take appropriate action.

Regards,
Shantanu




http://www.thekelleys.org.uk/dnsmasq/test-releases/dnsmasq-2.61test7.tar.gz

Has the "tftp" action implemented. At the moment it's sent to the 
--dhcp-script script always. I'm still tending towards that solution, 
but haven't made the final decision. The bulk of the changes are done 
anyway.



Cheers,

Simon.



___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-21 Thread Shantanu Gadgil
Hi,

I think it would be OK to add different "--*-script" commands. So you can have 
'dhcp6-script', 'tftp-script' ... possibly 'dns-script', etc, etc.

I know that I would like to have a single script to deal with each of these, 
and that IS how I would do it.
The way I would do (and usually is done) is that /each/ of the --*-script 
command would point to a *different* file; each of which is a symlink to the 
same "real" file!

The "real" script should look at '$0' and figure out which "action" is 
triggering self and take appropriate action.

Regards,
Shantanu


--- On Tue, 3/20/12, Simon Kelley  wrote:

> From: Simon Kelley 
> Subject: Re: [Dnsmasq-discuss] Feature Request: tftp-script
> To: "richardvo...@gmail.com" 
> Cc: dnsmasq-discuss@lists.thekelleys.org.uk
> Date: Tuesday, March 20, 2012, 5:14 PM
> On 19/03/12 17:51, richardvo...@gmail.com
> wrote:
> > Existing scripts could definitely break, imagine one
> that just logs
> > certain environment variables plus the parameter. 
> The new action values
> > won't have the right environment variable set.
> 
> A good point, but such scripts are already going to suffer
> as soon as DHCPv6 is used: that has the same action values,
> but some environment variables change.
> 
> Adding --tftp-script will work this time, but it will have
> to be repeated with more --*-script options if we ever add
> more functions. That starts to get silly. Biting the bullet
> now, and documenting that the script has to ignore unknown
> actions, fixes the problem once and for all.
> 
> Of course, that should have been the case from the start,
> but it's too late now. Dnsmasq's record on backwards
> compatibility is pretty good, so maybe we're entitled to a
> bit of slack.
> 
> > 
> > How about both?  Give the --tftp-script the same
> action parameter, and
> > keep actions unique, that way both options can be
> pointed to the same
> > script, or separate scripts.
> > 
> 
> If --tftp-script is used, that's the way to go, for sure.
> 
> Cheers,
> 
> Simon.
> 
> ___
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss@lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
> 

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-20 Thread Simon Kelley

On 19/03/12 17:51, richardvo...@gmail.com wrote:

Existing scripts could definitely break, imagine one that just logs
certain environment variables plus the parameter.  The new action values
won't have the right environment variable set.


A good point, but such scripts are already going to suffer as soon as 
DHCPv6 is used: that has the same action values, but some environment 
variables change.


Adding --tftp-script will work this time, but it will have to be 
repeated with more --*-script options if we ever add more functions. 
That starts to get silly. Biting the bullet now, and documenting that 
the script has to ignore unknown actions, fixes the problem once and for 
all.


Of course, that should have been the case from the start, but it's too 
late now. Dnsmasq's record on backwards compatibility is pretty good, so 
maybe we're entitled to a bit of slack.




How about both?  Give the --tftp-script the same action parameter, and
keep actions unique, that way both options can be pointed to the same
script, or separate scripts.



If --tftp-script is used, that's the way to go, for sure.

Cheers,

Simon.

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-19 Thread richardvo...@gmail.com
Existing scripts could definitely break, imagine one that just logs certain
environment variables plus the parameter.  The new action values won't have
the right environment variable set.

How about both?  Give the --tftp-script the same action parameter, and keep
actions unique, that way both options can be pointed to the same script, or
separate scripts.

On Mon, Mar 19, 2012 at 6:18 AM, Simon Kelley wrote:

> On 18/03/12 07:09, Shantanu Gadgil wrote:
>
>> Hi,
>>
>> I was wondering whether it would be possible to have hooks for the TFTP
>> operations, just like the DHCP operations.
>>
>> This is just a rough thought for now ...
>> When a TFTP request is made from the client (or is successful when the
>> file is /actually/ provided), I want to be able to log the IP adress (or
>> maybe send a mail) to collect some data as to how many network based
>> installations actually started, etc.
>>
>> If it could be possible to have the filename as one of the parameters in
>> the hook, it would be even better, as then I can isolate actual
>> installations that started, as opposed to TFTP requests which just loading
>> the PXE menu.
>>
>> Regards,
>> Shantanu
>>
>
> That sounds to me like a very sensible suggestion.
>
> There are two obvious ways to do it: either add an extra hook
> (--tftp-script), or add an extra possible "action" value to the current
> --dhcp-script. I think the later is how I'd do it if starting from scratch,
> but it has the disadvantage of possibly breaking existing script code. On
> the other hand, any sane script should just ignore unrecognised actions;
> the example code supplied with dnsmasq does.
>
> Any script users out there, please check your code, would adding another
> value to {add, old, del, init} break stuff?
>
>
>
> Cheers,
>
> Simon.
>
>
> __**_
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss@lists.**thekelleys.org.uk
> http://lists.thekelleys.org.**uk/mailman/listinfo/dnsmasq-**discuss
>
___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-19 Thread Shantanu Gadgil
As a script writer I can confirm that a well written script should not break if 
a new "first" parameter in added; in place of 'add', 'del' and 'old'

Any code, script or otherwise, should basically follow the same "modular" 
philosophy.

Wrt the actual thought, I have been sitting on this idea for quite some time, 
not sure how to nicely (correctly) minimize the TFTP script invocations.

I do think that some intelligence can be added to dnsamsq itself to trigger the 
TFTP script upon actual file delivery to client (before file send, after file 
send, etc, hooks), rather than any-tftp-request.

Not having used the dhcp-script too much myself, I won't be able to immediately 
create a mental picture whether mixing TFTP and DHCP in the same script would 
be any problem at all.

Thanks for the positive response on the idea though,
Regards,
Shantanu

--- On Mon, 3/19/12, Simon Kelley  wrote:

> From: Simon Kelley 
> Subject: Re: [Dnsmasq-discuss] Feature Request: tftp-script
> To: dnsmasq-discuss@lists.thekelleys.org.uk
> Date: Monday, March 19, 2012, 4:48 PM
> On 18/03/12 07:09, Shantanu Gadgil
> wrote:
> > Hi,
> > 
> > I was wondering whether it would be possible to have
> hooks for the TFTP operations, just like the DHCP
> operations.
> > 
> > This is just a rough thought for now ...
> > When a TFTP request is made from the client (or is
> successful when the file is /actually/ provided), I want to
> be able to log the IP adress (or maybe send a mail) to
> collect some data as to how many network based installations
> actually started, etc.
> > 
> > If it could be possible to have the filename as one of
> the parameters in the hook, it would be even better, as then
> I can isolate actual installations that started, as opposed
> to TFTP requests which just loading the PXE menu.
> > 
> > Regards,
> > Shantanu
> 
> That sounds to me like a very sensible suggestion.
> 
> There are two obvious ways to do it: either add an extra
> hook (--tftp-script), or add an extra possible "action"
> value to the current --dhcp-script. I think the later is how
> I'd do it if starting from scratch, but it has the
> disadvantage of possibly breaking existing script code. On
> the other hand, any sane script should just ignore
> unrecognised actions; the example code supplied with dnsmasq
> does.
> 
> Any script users out there, please check your code, would
> adding another value to {add, old, del, init} break stuff?
> 
> 
> 
> Cheers,
> 
> Simon.
> 
> ___
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss@lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
> 

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] Feature Request: tftp-script

2012-03-19 Thread Simon Kelley

On 18/03/12 07:09, Shantanu Gadgil wrote:

Hi,

I was wondering whether it would be possible to have hooks for the TFTP 
operations, just like the DHCP operations.

This is just a rough thought for now ...
When a TFTP request is made from the client (or is successful when the file is 
/actually/ provided), I want to be able to log the IP adress (or maybe send a 
mail) to collect some data as to how many network based installations actually 
started, etc.

If it could be possible to have the filename as one of the parameters in the 
hook, it would be even better, as then I can isolate actual installations that 
started, as opposed to TFTP requests which just loading the PXE menu.

Regards,
Shantanu


That sounds to me like a very sensible suggestion.

There are two obvious ways to do it: either add an extra hook 
(--tftp-script), or add an extra possible "action" value to the current 
--dhcp-script. I think the later is how I'd do it if starting from 
scratch, but it has the disadvantage of possibly breaking existing 
script code. On the other hand, any sane script should just ignore 
unrecognised actions; the example code supplied with dnsmasq does.


Any script users out there, please check your code, would adding another 
value to {add, old, del, init} break stuff?




Cheers,

Simon.

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


[Dnsmasq-discuss] Feature Request: tftp-script

2012-03-18 Thread Shantanu Gadgil
Hi,

I was wondering whether it would be possible to have hooks for the TFTP 
operations, just like the DHCP operations.

This is just a rough thought for now ...
When a TFTP request is made from the client (or is successful when the file is 
/actually/ provided), I want to be able to log the IP adress (or maybe send a 
mail) to collect some data as to how many network based installations actually 
started, etc.

If it could be possible to have the filename as one of the parameters in the 
hook, it would be even better, as then I can isolate actual installations that 
started, as opposed to TFTP requests which just loading the PXE menu.

Regards,
Shantanu

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss