Remove legacy support for forking to background.
This commit is contained in:
parent
58067200d6
commit
ade4e988af
19
src/cfg.rl
19
src/cfg.rl
@ -46,19 +46,6 @@ struct cfgparse {
|
|||||||
action falsval { ccfg.ternary = -1; }
|
action falsval { ccfg.ternary = -1; }
|
||||||
|
|
||||||
action clientid { get_clientid_string(ccfg.buf, ccfg.buflen); }
|
action clientid { get_clientid_string(ccfg.buf, ccfg.buflen); }
|
||||||
action background {
|
|
||||||
switch (ccfg.ternary) {
|
|
||||||
case 1:
|
|
||||||
client_config.background_if_no_lease = true;
|
|
||||||
gflags_detach = 1;
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
client_config.background_if_no_lease = false;
|
|
||||||
gflags_detach = 0;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
action hostname {
|
action hostname {
|
||||||
copy_cmdarg(client_config.hostname, ccfg.buf,
|
copy_cmdarg(client_config.hostname, ccfg.buf,
|
||||||
sizeof client_config.hostname, "hostname");
|
sizeof client_config.hostname, "hostname");
|
||||||
@ -187,7 +174,6 @@ struct cfgparse {
|
|||||||
blankline = term;
|
blankline = term;
|
||||||
|
|
||||||
clientid = 'clientid' value @clientid;
|
clientid = 'clientid' value @clientid;
|
||||||
background = 'background' boolval @background;
|
|
||||||
hostname = 'hostname' value @hostname;
|
hostname = 'hostname' value @hostname;
|
||||||
interface = 'interface' value @interface;
|
interface = 'interface' value @interface;
|
||||||
now = 'now' boolval @now;
|
now = 'now' boolval @now;
|
||||||
@ -211,7 +197,7 @@ struct cfgparse {
|
|||||||
rfkill_idx = 'rfkill-idx' value @rfkill_idx;
|
rfkill_idx = 'rfkill-idx' value @rfkill_idx;
|
||||||
|
|
||||||
main := blankline |
|
main := blankline |
|
||||||
clientid | background | hostname | interface | now | quit |
|
clientid | hostname | interface | now | quit |
|
||||||
request | vendorid | user | ifch_user | sockd_user | chroot |
|
request | vendorid | user | ifch_user | sockd_user | chroot |
|
||||||
state_dir | seccomp_enforce | relentless_defense | arp_probe_wait |
|
state_dir | seccomp_enforce | relentless_defense | arp_probe_wait |
|
||||||
arp_probe_num | arp_probe_min | arp_probe_max | gw_metric |
|
arp_probe_num | arp_probe_min | arp_probe_max | gw_metric |
|
||||||
@ -291,7 +277,6 @@ static void parse_cfgfile(const char fname[static 1])
|
|||||||
|
|
||||||
cfgfile = ('-c'|'--config') argval @cfgfile;
|
cfgfile = ('-c'|'--config') argval @cfgfile;
|
||||||
clientid = ('-I'|'--clientid') argval @clientid;
|
clientid = ('-I'|'--clientid') argval @clientid;
|
||||||
background = ('-b'|'--background') tbv @background;
|
|
||||||
hostname = ('-h'|'--hostname') argval @hostname;
|
hostname = ('-h'|'--hostname') argval @hostname;
|
||||||
interface = ('-i'|'--interface') argval @interface;
|
interface = ('-i'|'--interface') argval @interface;
|
||||||
now = ('-n'|'--now') tbv @now;
|
now = ('-n'|'--now') tbv @now;
|
||||||
@ -317,7 +302,7 @@ static void parse_cfgfile(const char fname[static 1])
|
|||||||
help = ('-?'|'--help') 0 @help;
|
help = ('-?'|'--help') 0 @help;
|
||||||
|
|
||||||
main := (
|
main := (
|
||||||
cfgfile | clientid | background | hostname | interface |
|
cfgfile | clientid | hostname | interface |
|
||||||
now | quit | request | vendorid | user | ifch_user | sockd_user |
|
now | quit | request | vendorid | user | ifch_user | sockd_user |
|
||||||
chroot | state_dir | seccomp_enforce | relentless_defense |
|
chroot | state_dir | seccomp_enforce | relentless_defense |
|
||||||
arp_probe_wait | arp_probe_num | arp_probe_min | arp_probe_max |
|
arp_probe_wait | arp_probe_num | arp_probe_min | arp_probe_max |
|
||||||
|
@ -37,9 +37,6 @@ This option should not be necessary in most instances, but may perhaps be
|
|||||||
useful for odd DHCP servers that perform some kind of authentication against
|
useful for odd DHCP servers that perform some kind of authentication against
|
||||||
the vendor id option field. The default is to send the string 'ndhc'.
|
the vendor id option field. The default is to send the string 'ndhc'.
|
||||||
.TP
|
.TP
|
||||||
.BI \-b ,\ \-\-background
|
|
||||||
Immediately fork into the background, even before obtaining a lease.
|
|
||||||
.TP
|
|
||||||
.BI \-s\ STATEDIR ,\ \-\-state\-dir= STATEDIR
|
.BI \-s\ STATEDIR ,\ \-\-state\-dir= STATEDIR
|
||||||
Specifies the directory where the DHCP state associated with the given
|
Specifies the directory where the DHCP state associated with the given
|
||||||
interface will be stored. Such state will include the leased IP, the
|
interface will be stored. Such state will include the leased IP, the
|
||||||
|
14
src/ndhc.c
14
src/ndhc.c
@ -149,8 +149,6 @@ void show_usage(void)
|
|||||||
" -I, --clientid=CLIENTID Client identifier\n"
|
" -I, --clientid=CLIENTID Client identifier\n"
|
||||||
" -h, --hostname=HOSTNAME Client hostname\n"
|
" -h, --hostname=HOSTNAME Client hostname\n"
|
||||||
" -V, --vendorid=VENDORID Client vendor identification string\n"
|
" -V, --vendorid=VENDORID Client vendor identification string\n"
|
||||||
" -b, --background Fork to background if lease cannot be\n"
|
|
||||||
" immediately negotiated.\n"
|
|
||||||
" -i, --interface=INTERFACE Interface to use (default: eth0)\n"
|
" -i, --interface=INTERFACE Interface to use (default: eth0)\n"
|
||||||
" -n, --now Exit with failure if lease cannot be\n"
|
" -n, --now Exit with failure if lease cannot be\n"
|
||||||
" immediately negotiated.\n"
|
" immediately negotiated.\n"
|
||||||
@ -517,18 +515,6 @@ static void ndhc_main(void) {
|
|||||||
do_ndhc_work();
|
do_ndhc_work();
|
||||||
}
|
}
|
||||||
|
|
||||||
void background(void)
|
|
||||||
{
|
|
||||||
static char called;
|
|
||||||
if (!called) {
|
|
||||||
called = 1; // Do not fork again.
|
|
||||||
if (daemon(0, 0) < 0) {
|
|
||||||
perror("fork");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wait_for_rfkill()
|
static void wait_for_rfkill()
|
||||||
{
|
{
|
||||||
cs.rfkillFd = rfkill_open(&client_config.enable_rfkill);
|
cs.rfkillFd = rfkill_open(&client_config.enable_rfkill);
|
||||||
|
@ -71,7 +71,6 @@ struct client_config_t {
|
|||||||
uint8_t clientid_len; // Length of the clientid
|
uint8_t clientid_len; // Length of the clientid
|
||||||
bool quit_after_lease; // Quit after obtaining lease
|
bool quit_after_lease; // Quit after obtaining lease
|
||||||
bool abort_if_no_lease; // Abort if no lease
|
bool abort_if_no_lease; // Abort if no lease
|
||||||
bool background_if_no_lease; // Fork to background if no lease
|
|
||||||
bool enable_rfkill; // Listen for rfkill events
|
bool enable_rfkill; // Listen for rfkill events
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -99,7 +98,6 @@ void set_client_addr(const char v[static 1]);
|
|||||||
void show_usage(void);
|
void show_usage(void);
|
||||||
void signal_exit(int status);
|
void signal_exit(int status);
|
||||||
int get_clientid_string(const char str[static 1], size_t slen);
|
int get_clientid_string(const char str[static 1], size_t slen);
|
||||||
void background(void);
|
|
||||||
void print_version(void);
|
void print_version(void);
|
||||||
|
|
||||||
#endif /* NJK_NDHC_NDHC_H_ */
|
#endif /* NJK_NDHC_NDHC_H_ */
|
||||||
|
@ -332,17 +332,12 @@ static int selecting_packet(struct client_state_t cs[static 1],
|
|||||||
// Triggered after a DHCP discover packet has been sent and no reply has
|
// Triggered after a DHCP discover packet has been sent and no reply has
|
||||||
// been received within the response wait time. If we've not exceeded the
|
// been received within the response wait time. If we've not exceeded the
|
||||||
// maximum number of discover retransmits, then send another packet and wait
|
// maximum number of discover retransmits, then send another packet and wait
|
||||||
// again. Otherwise, background or fail.
|
// again. Otherwise fail.
|
||||||
static int selecting_timeout(struct client_state_t cs[static 1],
|
static int selecting_timeout(struct client_state_t cs[static 1],
|
||||||
long long nowts)
|
long long nowts)
|
||||||
{
|
{
|
||||||
if (cs->program_init && cs->num_dhcp_requests >= 2) {
|
if (cs->program_init && cs->num_dhcp_requests >= 2) {
|
||||||
if (client_config.background_if_no_lease) {
|
if (client_config.abort_if_no_lease)
|
||||||
log_line("%s: No lease; going to background.",
|
|
||||||
client_config.interface);
|
|
||||||
cs->program_init = false;
|
|
||||||
background();
|
|
||||||
} else if (client_config.abort_if_no_lease)
|
|
||||||
suicide("%s: No lease; failing.", client_config.interface);
|
suicide("%s: No lease; failing.", client_config.interface);
|
||||||
}
|
}
|
||||||
if (send_discover(cs) < 0) {
|
if (send_discover(cs) < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user