This patch makes MPD 5.2 to execute "up-scripts" and "down-scripts"
with execve mechanism.
New command:
set iface enable execenv
If the command is set, MPD executes script with ExecCmdEnv function.
This function sets a list of environmental variables to child proccess:
MPD_SELF_IFACE # self iface name (e.g. ng0)
MPD_SELF_IP # self address range
MPD_PEER_IP # real IP
MPD_PEER_AUTH_IP # given after authentication
MPD_PEER_NAME # auth name
MPD_PEER_MAC # MAC address of the peer (formatted)
MPD_PEER_IFACE # Peer iface name
MPD_PEER_PORT # Number of peer's port
MPD_CALLING_NUM # with pppoe - unformatted peer MAC
MPD_CALLED_NUM # don't know)
MPD_PEER_NS0 # if peer uses DNS - ns #1
MPD_PEER_NS1 # ns #2
If some of this information is unavailable, the variables are set to "N/A".
This method seems to be more secure, and it provides more information
to user scripts increasing their usability.
We tested this patch on pptp and pppoe connections. Everything works just fine
but other types of connections remain untested.
We'd appriciate, this patch to be included to the next release of MPD.
While idea is good, it needs some work. These scrips supposed to be called for every protocol up/down, while here it is called only for IPv4. Obviously that IPv6 require different set of arguments. That's really nice that list of arguments is extendable there.