aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-05-06 15:32:00 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-05-06 15:32:00 +0200
commit9dd762b29b0cf54638ae88cf17a7d2c559cc9614 (patch)
tree720c64ae5c14c04fc1e4670c621cdb2eadb2082b
parent70f1aa530fd7953c66248a4002d5ba42f5f5e6e9 (diff)
downloaddyndhcpd-9dd762b29b0cf54638ae88cf17a7d2c559cc9614.tar.gz
dyndhcpd-9dd762b29b0cf54638ae88cf17a7d2c559cc9614.tar.zst
check existence of leaes file
-rw-r--r--dyndhcpd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/dyndhcpd.c b/dyndhcpd.c
index 8e3a24b..a9c0def 100644
--- a/dyndhcpd.c
+++ b/dyndhcpd.c
@@ -262,6 +262,10 @@ int main(int argc, char ** argv) {
leasesfile = malloc(strlen(LEASESFILE) + strlen(interface) + 1);
sprintf(leasesfile, LEASESFILE, interface);
+ /* check if leases file exists, create it if it does not */
+ if (access(leasesfile, R_OK) == -1)
+ fclose(fopen(leasesfile, "w"));
+
/* execute dhcp daemon, replace the current process
* dyndhcpd is cleared from memory here and code below is not execuded if
* everything goes well */