Support running an executable file when a new lease is acquired.
If no 'script-file = SCRIPTFILE' is specified in the configuration file and if no '-X SCRIPTFILE' or '--script-file SCRIPTFILE' command argument is provided, then this functionality is entirely inactive and no associated subprocess is spawned. Otherwise, ndhc will spawn a subprocess that runs as root that has the sole job of forking off a subprocess that exec's the specified script in a sanitized and fixed-state environment whenever a new DHCPv4 lease is acquired. Note that this script is provided no information about ndhc or the DHCP state in the environment or in any argument fields; it is the responsibility of this script to gather whatever information it needs from either the filesystem or syscalls. This design is intended to avoid the historical problems that are associated with dhcp clients invoking scripts. The path of the scriptfile cannot be changed after ndhc is initially run; ndhc forks off the privsep script subprocess that executes scripts after it has read the configuration file and command arguments, but before it begins processing network data; thus, it is impossible for the network-handling process to modify or influence the script assuming proper OS memory protection. The privsep channel communicates that the script should be run by simply writing a newline; anything else will result in ndhc terminating itself. Before the recommended way to update system state after a change in lease information was to run the fcactus program and watch the associated leasefile for the interface for modification; now no external program is needed for this job.
This commit is contained in:
3
ndhc.h
3
ndhc.h
@ -69,9 +69,12 @@ extern int ifchSock[2];
|
||||
extern int ifchStream[2];
|
||||
extern int sockdSock[2];
|
||||
extern int sockdStream[2];
|
||||
extern int scriptdSock[2];
|
||||
extern int scriptdStream[2];
|
||||
extern char state_dir[PATH_MAX];
|
||||
extern char chroot_dir[PATH_MAX];
|
||||
extern char resolv_conf_d[PATH_MAX];
|
||||
extern char script_file[PATH_MAX];
|
||||
extern uid_t ndhc_uid;
|
||||
extern gid_t ndhc_gid;
|
||||
|
||||
|
Reference in New Issue
Block a user