Remove legacy support for writing a pidfile.

This commit is contained in:
Nicholas J. Kain 2020-10-20 06:48:00 -04:00
parent 4d33c00e04
commit 58067200d6
4 changed files with 2 additions and 22 deletions

View File

@ -59,10 +59,6 @@ struct cfgparse {
break;
}
}
action pidfile {
write_pid_enabled = true;
copy_cmdarg(pidfile, ccfg.buf, sizeof pidfile, "pidfile");
}
action hostname {
copy_cmdarg(client_config.hostname, ccfg.buf,
sizeof client_config.hostname, "hostname");
@ -192,7 +188,6 @@ struct cfgparse {
clientid = 'clientid' value @clientid;
background = 'background' boolval @background;
pidfile = 'pidfile' value @pidfile;
hostname = 'hostname' value @hostname;
interface = 'interface' value @interface;
now = 'now' boolval @now;
@ -216,7 +211,7 @@ struct cfgparse {
rfkill_idx = 'rfkill-idx' value @rfkill_idx;
main := blankline |
clientid | background | pidfile | hostname | interface | now | quit |
clientid | background | hostname | interface | now | quit |
request | vendorid | user | ifch_user | sockd_user | chroot |
state_dir | seccomp_enforce | relentless_defense | arp_probe_wait |
arp_probe_num | arp_probe_min | arp_probe_max | gw_metric |
@ -297,7 +292,6 @@ static void parse_cfgfile(const char fname[static 1])
cfgfile = ('-c'|'--config') argval @cfgfile;
clientid = ('-I'|'--clientid') argval @clientid;
background = ('-b'|'--background') tbv @background;
pidfile = ('-p'|'--pidfile') argval @pidfile;
hostname = ('-h'|'--hostname') argval @hostname;
interface = ('-i'|'--interface') argval @interface;
now = ('-n'|'--now') tbv @now;
@ -323,7 +317,7 @@ static void parse_cfgfile(const char fname[static 1])
help = ('-?'|'--help') 0 @help;
main := (
cfgfile | clientid | background | pidfile | hostname | interface |
cfgfile | clientid | background | hostname | interface |
now | quit | request | vendorid | user | ifch_user | sockd_user |
chroot | state_dir | seccomp_enforce | relentless_defense |
arp_probe_wait | arp_probe_num | arp_probe_min | arp_probe_max |

View File

@ -40,10 +40,6 @@ the vendor id option field. The default is to send the string 'ndhc'.
.BI \-b ,\ \-\-background
Immediately fork into the background, even before obtaining a lease.
.TP
.BI \-p\ PIDFILE ,\ \-\-pidfile= PIDFILE
Write the process id number of the ndhc process into the specified file name.
The default is to not write the process id number into any file at all.
.TP
.BI \-s\ STATEDIR ,\ \-\-state\-dir= STATEDIR
Specifies the directory where the DHCP state associated with the given
interface will be stored. Such state will include the leased IP, the

View File

@ -151,7 +151,6 @@ void show_usage(void)
" -V, --vendorid=VENDORID Client vendor identification string\n"
" -b, --background Fork to background if lease cannot be\n"
" immediately negotiated.\n"
" -p, --pidfile=FILE File where the ndhc pid will be written\n"
" -i, --interface=INTERFACE Interface to use (default: eth0)\n"
" -n, --now Exit with failure if lease cannot be\n"
" immediately negotiated.\n"
@ -439,14 +438,12 @@ static void do_ndhc_work(void)
char state_dir[PATH_MAX] = "/etc/ndhc";
char chroot_dir[PATH_MAX] = "";
char resolv_conf_d[PATH_MAX] = "";
char pidfile[PATH_MAX] = "";
uid_t ndhc_uid = 0;
gid_t ndhc_gid = 0;
int ifchSock[2];
int sockdSock[2];
int ifchStream[2];
int sockdStream[2];
bool write_pid_enabled = false;
static void create_ifch_ipc_sockets(void) {
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, ifchSock) < 0)
@ -506,9 +503,6 @@ static void ndhc_main(void) {
cs.rfkillFd = rfkill_open(&client_config.enable_rfkill);
if (write_pid_enabled && !client_config.background_if_no_lease)
write_pid(pidfile);
open_leasefile();
nk_set_chroot(chroot_dir);
@ -533,8 +527,6 @@ void background(void)
exit(EXIT_SUCCESS);
}
}
if (write_pid_enabled)
write_pid(pidfile);
}
static void wait_for_rfkill()

View File

@ -91,10 +91,8 @@ extern int sockdStream[2];
extern char state_dir[PATH_MAX];
extern char chroot_dir[PATH_MAX];
extern char resolv_conf_d[PATH_MAX];
extern char pidfile[PATH_MAX];
extern uid_t ndhc_uid;
extern gid_t ndhc_gid;
extern bool write_pid_enabled;
int signals_flagged(void);
void set_client_addr(const char v[static 1]);