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 | |
parent | 1bcb85a645e15a1e9e2809e5af7d71f20c4ea2d6 (diff) | |
download | dyndhcpd-70f1aa530fd7953c66248a4002d5ba42f5f5e6e9.tar.gz dyndhcpd-70f1aa530fd7953c66248a4002d5ba42f5f5e6e9.tar.zst |
start dhcpd with different pid and leases file
-rw-r--r-- | config.def.h | 6 | ||||
-rw-r--r-- | dyndhcpd.c | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/config.def.h b/config.def.h index 22216e6..8f6e7ec 100644 --- a/config.def.h +++ b/config.def.h @@ -13,7 +13,11 @@ /* pathes for config file, first is read, second is written */ #define CONFIG_TEMPLATE "/etc/dyndhcpd/dhcpd.conf" -#define CONFIG_OUTPUT "/tmp/dhcpd_%s.conf" +#define CONFIG_OUTPUT "/run/dhcpd-%s.conf" + +/* pathes for pid and leases file, these are passed to dhcpd */ +#define PIDFILE "/run/dhcpd-%s.pid" +#define LEASESFILE "/var/lib/dhcp/dhcp-%s.leases" #endif /* _CONFIG_H */ @@ -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) |