From cba94922e4bd799b9d9feba1338b38c13a664499 Mon Sep 17 00:00:00 2001 From: Dan Church Date: Tue, 11 Sep 2018 10:21:26 -0500 Subject: [PATCH] Pass in location of conf file Define the name of the porkbind.conf file once, then pass it in at compile time. --- Makefile | 3 ++- report.c | 4 ++-- usage.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7e9065f..89a1636 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ CC = cc -FLAGS = -O2 -Wall +PORKBIND_CONF = porkbind.conf +FLAGS = -O2 -Wall -DPORKBIND_CONF=\"$(PORKBIND_CONF)\" OFLAGS = -c -pthread # -DDEBUG # You may have to add -lpthread here LIBS = -pthread diff --git a/report.c b/report.c index 353305c..07147f8 100644 --- a/report.c +++ b/report.c @@ -41,9 +41,9 @@ report(struct servers *llp, const char *config) vexit("fopen"); } } - else if (!(cf = fopen("porkbind.conf", "r"))) + else if (!(cf = fopen(PORKBIND_CONF, "r"))) { - fprintf(stderr,"Unable to open: porkbind.conf!\n"); + fprintf(stderr,"Unable to open: " PORKBIND_CONF "!\n"); vexit("fopen"); } diff --git a/usage.c b/usage.c index c782a24..0af00d5 100644 --- a/usage.c +++ b/usage.c @@ -8,7 +8,7 @@ usage(char **argv) printf("-*- PorkBind v1.3 by Derek Callaway (http://innu.org/~super) -*-\n\n"); printf("%s [-c file] [-s server] [-ri] domain\n", *argv); printf("\tfile is configuration file to use\n"); - printf("\t(default is porkbind.conf)\n"); + printf("\t(default is " PORKBIND_CONF ")\n"); printf("\tserver is the nameserver to forward queries through\n"); printf("\t(default is /etc/resolv.conf nameservers)\n"); printf("\t-r recursively scans subdomains (i.e. sub.host.dom then host.dom)\n");