--- djbdns-1.05/tinydns-data.c.orig Sun Feb 11 16:11:45 2001 +++ djbdns-1.05/tinydns-data.c Wed Feb 20 16:56:06 2002 @@ -1,5 +1,6 @@ #include #include +#include #include #include #include "uint16.h" @@ -159,11 +160,7 @@ die_datatmp(); } -buffer b; -char bspace[1024]; - static stralloc line; -int match = 1; unsigned long linenum = 0; #define NUMFIELDS 15 @@ -181,7 +178,7 @@ strerr_die4x(111,FATAL,"unable to parse data line ",strnum,why); } -int main() +int load(const char *fname) { int fddata; int i; @@ -196,20 +193,43 @@ char type[2]; char soa[20]; char buf[4]; - - umask(022); - - fddata = open_read("data"); + int match; + buffer b; + char bspace[1024]; + struct stat datastat; + + if ((stat(fname,&datastat))==-1) + strerr_die4sys(111,FATAL,"unable to stat ",fname,": "); + if (S_ISDIR(datastat.st_mode)) { + stralloc datadir = {0}, datafile = {0}; + struct dirent *dire; + DIR *dir; + + if (!stralloc_ready(&datadir,128)) nomem(); + if (!stralloc_ready(&datafile,128)) nomem(); + if (!stralloc_copys(&datadir,fname)) nomem(); + if (!stralloc_append(&datadir,"/")) nomem(); + dir=opendir(fname); + if (dir==NULL) + strerr_die4sys(111,FATAL,"unable to open directory ",fname,": "); + while ( (dire=readdir(dir)) != NULL ) { + if (dire->d_name[0] == '.') continue; + if (!stralloc_copy(&datafile,&datadir)) nomem(); + if (!stralloc_cats(&datafile,dire->d_name)) nomem(); + if (!stralloc_0(&datafile)) nomem(); + load(datafile.s); + } + return 0; + } + + fddata = open_read(fname); if (fddata == -1) - strerr_die2sys(111,FATAL,"unable to open data: "); + strerr_die4sys(111,FATAL,"unable to open ",fname,": "); defaultsoa_init(fddata); buffer_init(&b,buffer_unixread,fddata,bspace,sizeof bspace); - fdcdb = open_trunc("data.tmp"); - if (fdcdb == -1) die_datatmp(); - if (cdb_make_start(&cdb,fdcdb) == -1) die_datatmp(); - + match = 1; while (match) { ++linenum; if (getln(&b,&line,&match,'\n') == -1) @@ -445,6 +465,17 @@ syntaxerror(": unrecognized leading character"); } } + close(fddata); +} + +main(int argc, char **argv) +{ + umask(022); + fdcdb = open_trunc("data.tmp"); + if (fdcdb == -1) die_datatmp(); + if (cdb_make_start(&cdb,fdcdb) == -1) die_datatmp(); + + load("data"); if (cdb_make_finish(&cdb) == -1) die_datatmp(); if (fsync(fdcdb) == -1) die_datatmp(); --- djbdns-1.05/tinydns-conf.c.orig Sun Feb 11 16:11:45 2001 +++ djbdns-1.05/tinydns-conf.c Wed Feb 20 16:55:43 2002 @@ -89,7 +89,8 @@ perm(0755); start("root/Makefile"); - outs("data.cdb: data\n"); + outs("data = $(shell find data -type f \\! -name .\\*)\n"); + outs("data.cdb: $(data)\n"); outs("\t"); outs(auto_home); outs("/bin/tinydns-data\n"); finish(); perm(0644);