diff options
author | Christian Hesse <mail@eworm.de> | 2014-05-06 15:26:41 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2014-05-06 15:26:41 +0200 |
commit | 70f1aa530fd7953c66248a4002d5ba42f5f5e6e9 (patch) | |
tree | b40c9d3d500b75bcf743438037abc5f92ee63e38 /dyndhcpd.c | |
parent | 1bcb85a645e15a1e9e2809e5af7d71f20c4ea2d6 (diff) | |
download | dyndhcpd-70f1aa530fd7953c66248a4002d5ba42f5f5e6e9.tar.gz dyndhcpd-70f1aa530fd7953c66248a4002d5ba42f5f5e6e9.tar.zst |
start dhcpd with different pid and leases file
Diffstat (limited to 'dyndhcpd.c')
-rw-r--r-- | dyndhcpd.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -80,6 +80,7 @@ int main(int argc, char ** argv) { char * config = NULL; char * filename = NULL; FILE * configfile; + char * pidfile = NULL, * leasesfile = NULL; printf("Starting dyndhcpd/" VERSION " (compiled: " __DATE__ ", " __TIME__ ")\n"); @@ -255,10 +256,17 @@ int main(int argc, char ** argv) { fputs(config, configfile); fclose(configfile); + /* get names for pid and leases file */ + pidfile = malloc(strlen(PIDFILE) + strlen(interface) + 1); + sprintf(pidfile, PIDFILE, interface); + leasesfile = malloc(strlen(LEASESFILE) + strlen(interface) + 1); + sprintf(leasesfile, LEASESFILE, interface); + /* execute dhcp daemon, replace the current process * dyndhcpd is cleared from memory here and code below is not execuded if * everything goes well */ - execlp("/usr/bin/dhcpd", "dhcpd", "-f", "-d", "-q", "-4", "-cf", filename, interface, NULL); + execlp("/usr/bin/dhcpd", "dhcpd", "-f", "-d", "-q", "-4", + "-pf", pidfile, "-lf", leasesfile, "-cf", filename, interface, NULL); rc = EXIT_SUCCESS; goto out; @@ -274,6 +282,10 @@ int main(int argc, char ** argv) { out: /* free memory */ + if (leasesfile != NULL) + free(leasesfile); + if (pidfile != NULL) + free(pidfile); if (filename != NULL) free(filename); if (config != NULL) |