From: Wouter Wijngaards Date: Fri, 9 Nov 2007 13:52:13 +0000 (+0000) Subject: default config file location, example conf installed. X-Git-Tag: release-0.6~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=518e7511d76583344f5e46f4aa03ff6f0983bb1c;p=thirdparty%2Funbound.git default config file location, example conf installed. git-svn-id: file:///svn/unbound/trunk@736 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/Makefile.in b/Makefile.in index a6475fef6..c44640c5c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -28,6 +28,7 @@ doxygen=@doxygen@ libtool=@libtool@ ldnsdir=@ldnsdir@ staticexe=@staticexe@ +configfile=@ub_conf_file@ YACC=@YACC@ LEX=@LEX@ @@ -212,10 +213,13 @@ install: $(INSTALL) -c -m 644 $(srcdir)/doc/unbound.8 $(mandir)/man8 $(INSTALL) -c -m 644 $(srcdir)/doc/unbound-checkconf.8 $(mandir)/man8 $(INSTALL) -c -m 644 $(srcdir)/doc/unbound.conf.5 $(mandir)/man5 + if test ! -e $(configfile); then $(INSTALL) -d `dirname $(configfile)`; $(INSTALL) -c -m 644 $(srcdir)/doc/example.conf $(configfile); fi uninstall: rm -f -- $(bindir)/unbound $(bindir)/unbound-checkconf rm -f -- $(mandir)/man8/unbound.8 $(mandir)/man8/unbound-checkconf.8 $(mandir)/man5/unbound.conf.5 + @echo + @echo "You still need to remove `dirname $(configfile)` , $(configfile) by hand" download_ldns: svn export https://www.nlnetlabs.nl/ldns/svn/trunk/makedist.sh ldns_makedist.sh diff --git a/checkconf/unbound-checkconf.c b/checkconf/unbound-checkconf.c index 3a58aa759..2aaaaec7f 100644 --- a/checkconf/unbound-checkconf.c +++ b/checkconf/unbound-checkconf.c @@ -56,8 +56,9 @@ static void usage() { - printf("Usage: unbound-checkconf [options] file\n"); + printf("Usage: unbound-checkconf [file]\n"); printf(" Checks unbound configuration file for errors.\n"); + printf("file if omitted %s is used.\n", CONFIGFILE); printf("-h show this usage help.\n"); printf("Version %s\n", PACKAGE_VERSION); printf("BSD licensed, see LICENSE in source package for details.\n"); @@ -171,6 +172,7 @@ extern char* optarg; int main(int argc, char* argv[]) { int c; + char* f; log_ident_set("unbound-checkconf"); log_init(NULL, 0, NULL); checklock_start(); @@ -185,9 +187,12 @@ int main(int argc, char* argv[]) } argc -= optind; argv += optind; - if(argc != 1) + if(argc != 0 && argc != 1) usage(); - checkconf(argv[0]); + if(argc == 1) + f = argv[0]; + else f = CONFIGFILE; + checkconf(f); checklock_stop(); return 0; } diff --git a/config.h.in b/config.h.in index 5f169c811..8d92639d5 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Pathname to the Unbound configuration file */ +#undef CONFIGFILE + /* Define if you want to use debug lock checking (slow). */ #undef ENABLE_LOCK_CHECKS diff --git a/configure b/configure index 6e9a11f5b..62a3ee779 100755 --- a/configure +++ b/configure @@ -811,6 +811,7 @@ OBJEXT CPP GREP EGREP +ub_conf_file libtool AR doxygen @@ -1446,6 +1447,7 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-conf-file=path Pathname to the Unbound configuration file --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-pic try to use only PIC/non-PIC objects [default=use both] @@ -3254,6 +3256,40 @@ rm -f conftest* +case "$prefix" in + NONE) + case "$sysconfdir" in + '${prefix}/etc') + sysconfdir=/etc + ;; + esac + case "$localstatedir" in + '${prefix}/var') + localstatedir=/var + ;; + esac + ;; +esac + +# +# Determine configuration file +ub_conf_file=${sysconfdir}/unbound/unbound.conf + +# Check whether --with-conf_file was given. +if test "${with_conf_file+set}" = set; then + withval=$with_conf_file; ub_conf_file=$withval +fi + + +# the eval is to evaluate shell expansion twice, once +# for $nsd_conf_file and once for the ${prefix} within it. + +cat >>confdefs.h <<_ACEOF +#define CONFIGFILE "`eval echo $ub_conf_file`" +_ACEOF + +echo $ub_conf_file + # if the given code compiles without the flag, execute argument 4 @@ -5593,7 +5629,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5596 "configure"' > conftest.$ac_ext + echo '#line 5632 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6895,11 +6931,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6898: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6934: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6902: \$? = $ac_status" >&5 + echo "$as_me:6938: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7163,11 +7199,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7166: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7202: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7170: \$? = $ac_status" >&5 + echo "$as_me:7206: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7267,11 +7303,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7270: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7306: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7274: \$? = $ac_status" >&5 + echo "$as_me:7310: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8732,7 +8768,7 @@ linux*) libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) - echo '#line 8735 "configure"' > conftest.$ac_ext + echo '#line 8771 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -9596,7 +9632,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:12071: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12039: \$? = $ac_status" >&5 + echo "$as_me:12075: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12136,11 +12172,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12139: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12175: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12143: \$? = $ac_status" >&5 + echo "$as_me:12179: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12672,7 +12708,7 @@ linux*) libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) - echo '#line 12675 "configure"' > conftest.$ac_ext + echo '#line 12711 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -13727,11 +13763,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13730: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13766: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13734: \$? = $ac_status" >&5 + echo "$as_me:13770: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -13831,11 +13867,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13834: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13870: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13838: \$? = $ac_status" >&5 + echo "$as_me:13874: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15276,7 +15312,7 @@ linux*) libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) - echo '#line 15279 "configure"' > conftest.$ac_ext + echo '#line 15315 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -16050,11 +16086,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16053: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16089: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16057: \$? = $ac_status" >&5 + echo "$as_me:16093: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16318,11 +16354,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16321: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16357: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16325: \$? = $ac_status" >&5 + echo "$as_me:16361: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16422,11 +16458,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16425: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16461: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16429: \$? = $ac_status" >&5 + echo "$as_me:16465: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17887,7 +17923,7 @@ linux*) libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) - echo '#line 17890 "configure"' > conftest.$ac_ext + echo '#line 17926 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -25205,6 +25241,7 @@ OBJEXT!$OBJEXT$ac_delim CPP!$CPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim +ub_conf_file!$ub_conf_file$ac_delim libtool!$libtool$ac_delim AR!$AR$ac_delim doxygen!$doxygen$ac_delim @@ -25239,7 +25276,7 @@ ldnsdir!$ldnsdir$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 79; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 80; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.ac b/configure.ac index 4bdf63ddb..454c4ee4c 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,36 @@ AC_INIT(unbound, 0.6, wouter@nlnetlabs.nl, unbound) CFLAGS= AC_AIX +dnl +dnl By default set $sysconfdir to /etc and $localstatedir to /var +dnl +case "$prefix" in + NONE) + case "$sysconfdir" in + '${prefix}/etc') + sysconfdir=/etc + ;; + esac + case "$localstatedir" in + '${prefix}/var') + localstatedir=/var + ;; + esac + ;; +esac + +# +# Determine configuration file +ub_conf_file=${sysconfdir}/unbound/unbound.conf +AC_ARG_WITH([conf_file], + AC_HELP_STRING([--with-conf-file=path], [Pathname to the Unbound configuration file]), + [ub_conf_file=$withval]) +AC_SUBST(ub_conf_file) +# the eval is to evaluate shell expansion twice, once +# for $nsd_conf_file and once for the ${prefix} within it. +AC_DEFINE_UNQUOTED(CONFIGFILE, ["`eval echo $ub_conf_file`"], [Pathname to the Unbound configuration file]) +echo $ub_conf_file + dnl routine to help check for compiler flags. AC_DEFUN([CHECK_COMPILER_FLAG], [ diff --git a/daemon/unbound.c b/daemon/unbound.c index 41bb53de3..ccdb15611 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -61,10 +61,11 @@ void* unbound_start_brk = 0; /** print usage. */ static void usage() { - printf("usage: unbound [options]\n"); + printf("usage: unbound [options]\n"); printf(" start unbound daemon DNS resolver.\n"); printf("-h this help\n"); - printf("-c file config file to read, unbound.conf(5).\n"); + printf("-c file config file to read instead of %s\n", CONFIGFILE); + printf(" file format is described in unbound.conf(5).\n"); printf("-d do not fork into the background.\n"); printf("-v verbose (multiple times increase verbosity)\n"); printf("Version %s\n", PACKAGE_VERSION); @@ -382,7 +383,7 @@ int main(int argc, char* argv[]) { int c; - char* cfgfile = NULL; + char* cfgfile = CONFIGFILE; int cmdline_verbose = 0; int debug_mode = 0; diff --git a/doc/Changelog b/doc/Changelog index 0fb74ca13..ee7c160b5 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,9 @@ +9 November 2007: Wouter + - took ldns snapshot in repo. + - default config file is /etc/unbound/unbound.conf. + If it doesn't exist, it is installed with the doc/example.conf file. + The file is not deleted on uninstall. + 8 November 2007: Wouter - Fixup chroot and drop user privileges. - new L root ip address in default hints. diff --git a/doc/example.conf b/doc/example.conf index df51d8647..1c9b8a4a1 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -13,8 +13,8 @@ server: # whitespace is not necessary, but looks cleaner. # verbosity number, 0 is least verbose. 1 is default. - verbosity: 2 - + verbosity: 1 + # number of threads to create. 1 disables threading. # num-threads: 1 diff --git a/doc/unbound-checkconf.8 b/doc/unbound-checkconf.8 index 2275af43f..d65934bbd 100644 --- a/doc/unbound-checkconf.8 +++ b/doc/unbound-checkconf.8 @@ -14,7 +14,7 @@ unbound-checkconf .Sh SYNOPSIS .Nm unbound-checkconf .Op Fl h -cfgfile +.Op cfgfile .Sh DESCRIPTION .Ic Unbound-checkconf checks the configuration file for the @@ -30,10 +30,16 @@ The available options are: Show the version and commandline option help. .It cfgfile The config file to read with settings for unbound. It is checked. +If omitted, the config file at the default location is checked. .Sh EXIT CODE The unbound-checkconf program exits with status code 1 on error, 0 for a correct config file. .El +.Sh FILES +.Bl -tag -width indent +.It Pa /etc/unbound/unbound.conf +unbound configuration file. +.El .Sh SEE ALSO .Xr unbound.conf 5 , .Xr unbound 8 . diff --git a/doc/unbound.8 b/doc/unbound.8 index c89378874..48e90454c 100644 --- a/doc/unbound.8 +++ b/doc/unbound.8 @@ -27,7 +27,8 @@ The available options are: .It Fl h Show the version and commandline option help. .It Fl c Ar cfgfile -Set the config file to read with settings for unbound. The syntax is +Set the config file with settings for unbound to read instead of the +file at default location /etc/unbound/unbound.conf. The syntax is described in .Xr unbound.conf 5 . .It Fl d