aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-06-07 06:45:19 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-06-07 06:45:19 +0200
commit1edcee2141c48a6bd767e9400b0883e6de9d14e5 (patch)
tree1807e7cbc54f009a717ab28b7e87fcddf09cda41
parent318a07de90bd855c41e568e7a2451832448be677 (diff)
downloaddyndhcpd-1edcee2141c48a6bd767e9400b0883e6de9d14e5.tar.gz
dyndhcpd-1edcee2141c48a6bd767e9400b0883e6de9d14e5.tar.zst
check if dhcpd exists and is executable
-rw-r--r--config.def.h3
-rw-r--r--dyndhcpd.c8
2 files changed, 10 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h
index 8f6e7ec..2e822fd 100644
--- a/config.def.h
+++ b/config.def.h
@@ -15,6 +15,9 @@
#define CONFIG_TEMPLATE "/etc/dyndhcpd/dhcpd.conf"
#define CONFIG_OUTPUT "/run/dhcpd-%s.conf"
+/* dhcpd executable */
+#define DHCPDFILE "/usr/bin/dhcpd"
+
/* 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"
diff --git a/dyndhcpd.c b/dyndhcpd.c
index 993b3ed..dde769b 100644
--- a/dyndhcpd.c
+++ b/dyndhcpd.c
@@ -108,6 +108,12 @@ int main(int argc, char ** argv) {
goto out;
}
+ /* check if dhcpd exists and is executable */
+ if (access(DHCPDFILE, X_OK) == -1) {
+ fprintf(stderr, "The dhcp daemon is not execatable!\n");
+ goto out;
+ }
+
/* get the domainname */
gethostname(hostname, 254);
hp = gethostbyname(hostname);
@@ -268,7 +274,7 @@ int main(int argc, char ** argv) {
if (verbose > 1)
printf("Running: dhcpd -f -d -q -4 -pf %s -lf %s -cf %s %s\n",
pidfile, leasesfile, filename, interface);
- execlp("/usr/bin/dhcpd", "dhcpd", "-f", "-d", "-q", "-4",
+ execlp(DHCPDFILE, "dhcpd", "-f", "-d", "-q", "-4",
"-pf", pidfile, "-lf", leasesfile, "-cf", filename, interface, NULL);
rc = EXIT_SUCCESS;