changeset 1336:d51e260e572a draft

Ensure that DBDIR and RUNDIR exist if defined as /var/db/dhcpcd and/or /var/run/dhcpcd.
author Roy Marples <roy@marples.name>
date Wed, 08 Jul 2009 19:22:31 +0000
parents 591f063c9f7a
children 1c8dffb2d423
files dhcpcd.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dhcpcd.c	Wed Jul 08 17:05:29 2009 +0000
+++ b/dhcpcd.c	Wed Jul 08 19:22:31 2009 +0000
@@ -1677,6 +1677,16 @@
 			exit(EXIT_FAILURE);
 		}
 
+		/* Ensure we have the needed directories */
+		if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST) {
+			syslog(LOG_ERR, "mkdir `%s': %m", RUNDIR);
+			exit(EXIT_FAILURE);
+		}
+		if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST) {
+			syslog(LOG_ERR, "mkdir `%s': %m", DBDIR);
+			exit(EXIT_FAILURE);
+		}
+
 		pidfd = open(pidfile, O_WRONLY | O_CREAT | O_NONBLOCK, 0664);
 		if (pidfd == -1) {
 			syslog(LOG_ERR, "open `%s': %m", pidfile);