Installing and Administering PPP

68 Chapter 4
Common pppd Options
The exec Option
The exec Option
The exec option invokes a command or shell script when a link is brought
up or taken down. Exec can be used on the link’s calling or answering
end and the command or shell script is executed immediately when the
link changes state.
The first argument of the command or shell script invoked by exec is
either “up” or “down." The second argument is the peer’s IP address.
Exec’s third and subsequent arguments are those with which pppd was
invoked.
NOTE Note: pppd runs suid root and anything specified in the Exec script is
run as root. This can be a risk if mismanaged. Take appropriate security
precautions with the exec script so it cannot be modified by non-root
users.
Parent Environment and Session Variables
The entire parent environment is exported to exec scripts (the
environment when pppd was invoked.) You should attempt to make the
environment as small as possible because the environment will take up
space for each pppd that is running. The exec script may also include
variables that describe the current session. These variables include:
Variable Description
PPPHOME As you would expect, but always set.
PPP_COMMANDLINE All arguments from the original command line.
PPP_LOCALADDR Local address of link while up (negotiated).
PPP_REMOTEADDR Remote address while up.
PPP_NETMASK Netmask while up.
PPP_ORIG_LOCALADDR Original local address (from command line).
PPP_ORIG_REMOTEADDR Original remote address.