* Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
*
* It is part of adns, which is
- * Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
- * Copyright (C) 1999 Tony Finch <dot@dotat.at>
+ * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
+ * Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "internal.h"
-static void readconfig(adns_state ads, const char *filename);
+static void readconfig(adns_state ads, const char *filename, int warnmissing);
static void addserver(adns_state ads, struct in_addr addr) {
int i;
configparseerr(ads,fn,lno,"`include' directive with no filename");
return;
}
- readconfig(ads,buf);
+ readconfig(ads,buf,1);
+}
+
+static void ccf_lookup(adns_state ads, const char *fn, int lno,
+ const char *buf) {
+ int found_bind=0;
+ const char *word;
+ int l;
+
+ if (!*buf) {
+ configparseerr(ads,fn,lno,"`lookup' directive with no databases");
+ return;
+ }
+
+ while (nextword(&buf,&word,&l)) {
+ if (l==4 && !memcmp(word,"bind",4)) {
+ found_bind=1;
+ } else if (l==4 && !memcmp(word,"file",4)) {
+ /* ignore this and hope /etc/hosts is not essential */
+ } else if (l==2 && !memcmp(word,"yp",2)) {
+ adns__diag(ads,-1,0,"%s:%d: yp lookups not supported by adns", fn,lno);
+ found_bind=-1;
+ } else {
+ adns__diag(ads,-1,0,"%s:%d: unknown `lookup' database `%.*s'",
+ fn,lno, l,word);
+ found_bind=-1;
+ }
+ }
+ if (!found_bind)
+ adns__diag(ads,-1,0,"%s:%d: `lookup' specified, but not `bind'", fn,lno);
}
static const struct configcommandinfo {
{ "options", ccf_options },
{ "clearnameservers", ccf_clearnss },
{ "include", ccf_include },
+ { "lookup", ccf_lookup }, /* OpenBSD */
{ 0 }
};
return value;
}
-static void readconfig(adns_state ads, const char *filename) {
+static void readconfig(adns_state ads, const char *filename, int warnmissing) {
getline_ctx gl_ctx;
gl_ctx.file= fopen(filename,"r");
if (!gl_ctx.file) {
if (errno == ENOENT) {
- adns__debug(ads,-1,0,"configuration file `%s' does not exist",filename);
+ if (warnmissing)
+ adns__debug(ads,-1,0,"configuration file `%s' does not exist",filename);
return;
}
saveerr(ads,errno);
return;
}
filename= instrum_getenv(ads,envvar);
- if (filename) readconfig(ads,filename);
+ if (filename) readconfig(ads,filename,1);
}
static void readconfigenvtext(adns_state ads, const char *envvar) {
ccf_options(ads,"RES_OPTIONS",-1,res_options);
ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
- readconfig(ads,"/etc/resolv.conf");
+ readconfig(ads,"/etc/resolv.conf",1);
+ readconfig(ads,"/etc/resolv-adns.conf",0);
readconfigenv(ads,"RES_CONF");
readconfigenv(ads,"ADNS_RES_CONF");