From 9dd762b29b0cf54638ae88cf17a7d2c559cc9614 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2014 15:32:00 +0200 Subject: check existence of leaes file --- dyndhcpd.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'dyndhcpd.c') 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 */ -- cgit v1.2.3-54-g00ecf