Commit 21cf68ee authored by Dmitry Bogatov's avatar Dmitry Bogatov

Import Upstream version 2.04+dfsg

parent 9563899b
Version 2.03 of bglibs is now available at:
Version 2.04 of bglibs is now available at:
http://untroubled.org/bglibs/
------------------------------------------------------------------------------
Changes in version 2.03
Changes in version 2.04
- Reverted libbg-cli back to static linkage (for now) to fix problem
with cli-generate generated code.
- Fixed DNS self-tests relying on external data.
- Added support for DNS queries on an alternate port.
- Added support for $MSG_NO_PROGRAM to suppress the "program: " prefix.
- Fixed problem with struct ucred not being pulled in properly.
- Fixed several problems with dns_qualify.
Development of this version has been sponsored by FutureQuest, Inc.
ossi@FutureQuest.net http://www.FutureQuest.net/
......@@ -12,8 +19,8 @@ ossi@FutureQuest.net http://www.FutureQuest.net/
bglibs
One stop library package
Bruce Guenter <bruce@untroubled.org>
Version 2.03
2015-02-06
Version 2.04
2018-02-23
This package contains a collection of libraries written by myself and
put in use in various packages.
......@@ -33,7 +40,7 @@ Installation:
- After the package has been compiled, run the following command as root:
make install
Copyright(C) 2015 Bruce Guenter <bruce@untroubled.org>
Copyright(C) 2018 Bruce Guenter <bruce@untroubled.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
......
commit 7dfd12522ec6496470ac381fe568721e45c42975
Author: Bruce Guenter <bruce@untroubled.org>
Date: Wed Mar 2 15:33:15 2016 -0600
net/resolve: Use dns_qualify to provide qualification for IPv4 lookups
dns-responder.c | 11 ++++++-----
include/resolve.h | 2 ++
net/resolve_calldns.c | 18 ++++++++++++++++++
net/resolve_ipv4name.c | 22 ++++++++++++++++++----
4 files changed, 44 insertions(+), 9 deletions(-)
commit 458970d769df5cc0ee66d6c1129647887f10a5fa
Author: Bruce Guenter <bruce@untroubled.org>
Date: Wed Mar 2 16:19:17 2016 -0600
Bump version to 2.04
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 40d99382080ad4c7fce7f4256f5f85a6b9c3dd27
Author: Bruce Guenter <bruce@untroubled.org>
Date: Wed Mar 2 15:32:25 2016 -0600
dns-responder: Add support for multiple-packet DNS sequences
dns-responder.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
commit 7c18a1adbf058f2f9a755620db67ee7d231ccbd4
Author: Bruce Guenter <bruce@untroubled.org>
Date: Wed Mar 2 19:45:52 2016 -0600
net/dns: Fix handling of multiple + additions in dns_qualify
NEWS | 5 +----
net/dns_qualify.c | 35 +++++++++++++++++++++++++++++------
2 files changed, 30 insertions(+), 10 deletions(-)
commit d9e0bfdfcae3bce627e43730efb318059f2c3558
Author: Bruce Guenter <bruce@untroubled.org>
Date: Wed Mar 2 19:18:15 2016 -0600
net/dns: Move dns_qualify tests into dns_qualify.c
net/dns_qualify.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
net/dns_resolvconfrewrite.c | 28 ----------------------------
2 files changed, 44 insertions(+), 28 deletions(-)
commit 234376375ef0b5e9b69030d7067c446408508a7c
Author: Bruce Guenter <bruce@untroubled.org>
Date: Wed Mar 2 19:11:34 2016 -0600
net/dns: Test output of dns_resolvconfrewrite
net/dns_resolvconfrewrite.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
commit d6b5534e3fc9c12f74466b50abb5e5d9167975ad
Author: Bruce Guenter <bruce@untroubled.org>
Date: Wed Mar 2 17:22:56 2016 -0600
net/dns: Add selftests for fromdot/todot
net/dns_domain_fromdot.c | 39 +++++++++++++++++++++++++++++++++++++++
net/dns_domain_todot.c | 21 +++++++++++++++++++++
2 files changed, 60 insertions(+)
commit 48f83d871bd0562dfa83506aa1ccdc290c8cb924
Author: Bruce Guenter <bruce@untroubled.org>
Date: Wed Mar 2 14:57:47 2016 -0600
net/dns: Fix prototype for (unused) dns_qualify
The dns_qualify function is supposed to call one of the dns_* functions
(like dns_ip4). It was providing a str* for the output, but those
functions output via struct dns_result*.
NEWS | 2 ++
include/dns.h | 8 ++++----
net/dns_qualify.c | 10 +++++-----
net/dns_resolvconfrewrite.c | 4 ++--
4 files changed, 13 insertions(+), 11 deletions(-)
commit 742731135b2862b74ec3cbc9d13152ae7762fa08
Author: Bruce Guenter <bruce@untroubled.org>
Date: Wed Mar 2 13:21:28 2016 -0600
Fix INCLUDES setting in (not used) automake files
cdb++/Makefile.am | 2 +-
cgi/Makefile.am | 2 +-
cli++/Makefile.am | 2 +-
fdbuf/Makefile.am | 2 +-
mystring/Makefile.am | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
commit 87a72571d72563f566f6ad2e6beda6754a0d883d
Author: Bruce Guenter <bruce@untroubled.org>
Date: Thu Aug 13 21:54:45 2015 -0600
include: Remove obsolete cloexec.h and nonblock.h
include/cloexec.h | 7 -------
include/nonblock.h | 7 -------
2 files changed, 14 deletions(-)
delete mode 100644 include/cloexec.h
delete mode 100644 include/nonblock.h
commit 9cc6039a7d32a7d5439d9057ba24200714801205
Author: Bruce Guenter <bruce@untroubled.org>
Date: Sun May 17 13:57:15 2015 -0600
net/dns: Slight simplification of declarations
dns-responder.c | 17 ++++++++---------
net/dns_ip4.c | 12 ++++++------
net/dns_ip6.c | 8 ++++----
net/dns_mx.c | 4 ++--
net/dns_txt.c | 10 +++++-----
5 files changed, 25 insertions(+), 26 deletions(-)
commit 6b2e99762a99435f57e222aa655958ff92bddfad
Author: Bruce Guenter <bruce@untroubled.org>
Date: Sun May 17 13:49:42 2015 -0600
net/dns: Use captive data test for dns_mx
dns-responder.c | 6 +++++-
net/dns_mx.c | 43 ++++++++++++++++++++++++++++++-------------
2 files changed, 35 insertions(+), 14 deletions(-)
commit ee11fdc1af957af4daa8e424e9f6f770208b0ec2
Author: Bruce Guenter <bruce@untroubled.org>
Date: Sun May 17 12:13:55 2015 -0600
net/dns: Use captive test data for dns_ip[46]
dns-responder.c | 11 +++++++++--
net/dns_ip4.c | 43 ++++++++++++++++++++++++++++++++-----------
net/dns_ip6.c | 28 ++++++++++++++++++----------
net/dns_txt.c | 4 ++--
4 files changed, 61 insertions(+), 25 deletions(-)
commit 4b60936011db10521b5d12198927d6a3ff4a55dd
Author: Bruce Guenter <bruce@untroubled.org>
Date: Sun May 17 11:36:29 2015 -0600
net/dns: Modify selftest for dns_txt to use captive data
net/dns_txt.c | 39 +++++++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 12 deletions(-)
commit 0b833be320670b76ec6aa98a15f892ed85417595
Author: Bruce Guenter <bruce@untroubled.org>
Date: Sun May 17 11:36:05 2015 -0600
Add DNS test responder framework
dns-responder.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 135 insertions(+)
create mode 100644 dns-responder.c
commit 5d2747a60ebb9ccfcd4ddf4aa074a932a1532afe
Author: Bruce Guenter <bruce@untroubled.org>
Date: Sun May 17 11:53:24 2015 -0600
net/dns: Break out DNS RR union
include/dns.h | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
commit 0e2e1788a29cd1f4ec494513f5744dbbc1e6ac6e
Author: Bruce Guenter <bruce@untroubled.org>
Date: Sat May 16 13:47:12 2015 -0600
net/dns: Support dns queries on alternate port with $DNSCACHEPORT
NEWS | 2 ++
net/dns_resolvconfip.c | 10 ++++++++++
net/dns_transmit.c | 6 +++---
3 files changed, 15 insertions(+), 3 deletions(-)
commit 3477ae73bb4d774d095122e1515549f1ac53b509
Author: Bruce Guenter <bruce@untroubled.org>
Date: Sat May 16 13:38:48 2015 -0600
net/dns_transmit.c: Add define for DNS port number
net/dns_transmit.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
commit 501725b9dbdca2c20f913f87039594955614df6e
Author: Bruce Guenter <bruce@untroubled.org>
Date: Fri May 15 14:26:47 2015 -0600
sys: Need #define _GNU_SOURCE 1 for definition of struct ucred
NEWS | 2 ++
sys/haspeercred.h1 | 1 +
sys/trypeercred.c | 1 +
sysdeps-head.h | 1 +
4 files changed, 5 insertions(+)
commit 90478c13cb819d378e0dcab8aeba07b9ed6a5dd0
Author: Bruce Guenter <bruce@untroubled.org>
Date: Fri May 15 13:54:17 2015 -0600
net/dns_qualify: Use memmove instead of memcpy since the areas overlap
NEWS | 3 +++
net/dns_qualify.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
commit 92c0d51c7dba96715db2ff2e37bafb7385cda1ac
Author: Bruce Guenter <bruce@untroubled.org>
Date: Fri Feb 6 17:56:11 2015 -0600
Bump version to 2.03
NEWS | 5 +++++
VERSION | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
commit f6131aa9345616bd2b4e78915f44ef4627879f13
Author: Bruce Guenter <bruce@untroubled.org>
Date: Fri Feb 6 17:54:35 2015 -0600
config.dxy: Fix list of INPUT subdirectories
config.dxy | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 4aa02e459c289c183e89045091a3879fed5d4485
Author: Bruce Guenter <bruce@untroubled.org>
Date: Fri Feb 6 15:30:45 2015 -0600
Revert installed libbg-cli back to static linkage.
The CLI lib calls cli_show_help when it needs to show help text. The
library includes an implementation that dynamically generates the help
text from the options structure, but cli-generate also builds its own
function that has pre-generated text. In the dynamic .so file, this
doesn't work, since it's all pre-linked internally.
I could change cli_show_help to a weak symbol, but that adds a gcc
dependancy, and the CLI library is small and doesn't change much, so
just revert to static linkage.
INSTHIER | 2 +-
NEWS | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
commit 5ae53d7e9f6cc50f6fc46c3a4e42e51fdfe601fd
Author: Bruce Guenter <bruce@untroubled.org>
Date: Tue Feb 3 16:23:15 2015 -0600
......
......@@ -44,7 +44,7 @@ bg-installer-cli.h
bg-installer.1
bg-installer.c
bg-installer.cli
bglibs-2.03.spec
bglibs-2.04.spec
cdb/cdb.c
cdb/cdbhash.c
cdb/find.c
......@@ -97,6 +97,7 @@ dict/init.c
dict/load_list.c
dict/load_map.c
dict/str_free.c
dns-responder.c
doc/html/adt_2ghash_test_8c-example.html
doc/html/adt_2gqueue_test_8c-example.html
doc/html/adt_2gstack_test_8c-example.html
......@@ -108,7 +109,6 @@ doc/html/bdwn.png
doc/html/cdb_8h_source.html
doc/html/classes.html
doc/html/cli_8h_source.html
doc/html/cloexec_8h_source.html
doc/html/closed.png
doc/html/cmsg_8h_source.html
doc/html/crc16__arc_8h_source.html
......@@ -130,6 +130,7 @@ doc/html/dir_c882bb6fa009938b7b09c7ff2cbfbf0e.html
doc/html/dir_d44c64559bbebec7f509842c48db8b23.html
doc/html/dir_f8ab57e0d469b48445b5dfd63bafd7af.html
doc/html/dns_8h_source.html
doc/html/doc.png
doc/html/doxygen.css
doc/html/doxygen.png
doc/html/dynsections.js
......@@ -137,22 +138,8 @@ doc/html/envstr_8h_source.html
doc/html/examples.html
doc/html/files.html
doc/html/fmt_8h_source.html
doc/html/ftv2blank.png
doc/html/ftv2cl.png
doc/html/ftv2doc.png
doc/html/ftv2folderclosed.png
doc/html/ftv2folderopen.png
doc/html/ftv2lastnode.png
doc/html/ftv2link.png
doc/html/ftv2mlastnode.png
doc/html/ftv2mnode.png
doc/html/ftv2mo.png
doc/html/ftv2node.png
doc/html/ftv2ns.png
doc/html/ftv2plastnode.png
doc/html/ftv2pnode.png
doc/html/ftv2splitbar.png
doc/html/ftv2vertline.png
doc/html/folderclosed.png
doc/html/folderopen.png
doc/html/functions.html
doc/html/functions_vars.html
doc/html/gcrc_8h_source.html
......@@ -191,13 +178,14 @@ doc/html/ipv6_8h_source.html
doc/html/jquery.js
doc/html/md4_8h_source.html
doc/html/md5_8h_source.html
doc/html/menu.js
doc/html/menudata.js
doc/html/misc_8h_source.html
doc/html/modules.html
doc/html/msg_8h_source.html
doc/html/nav_f.png
doc/html/nav_g.png
doc/html/nav_h.png
doc/html/nonblock_8h_source.html
doc/html/obuf_8h_source.html
doc/html/open.png
doc/html/pages.html
......@@ -211,6 +199,7 @@ doc/html/sha512_8h_source.html
doc/html/sig_8h_source.html
doc/html/signalfd_8h_source.html
doc/html/socket_8h_source.html
doc/html/splitbar.png
doc/html/str_8h_source.html
doc/html/striter_8h_source.html
doc/html/structSHA1__CTX.html
......@@ -254,6 +243,7 @@ doc/html/tab_s.png
doc/html/tabs.css
doc/html/trigger_8h_source.html
doc/html/ucspi_8h_source.html
doc/html/uniondns__result__rrs.html
doc/html/unix_8h_source.html
doc/html/wrap_8h_source.html
doc/latex/Makefile
......@@ -327,6 +317,9 @@ doc/latex/structstr.tex
doc/latex/structstr__sortentry.tex
doc/latex/structstriter.tex
doc/latex/structsurfrand.tex
doc/latex/uniondns__result__rrs.tex
doc/qualify.html
doc/qualify.txt
doc/template.cli
fmt/char.c
fmt/chars.c
......
This diff is collapsed.
-------------------------------------------------------------------------------
Changes in version 2.04
- Fixed DNS self-tests relying on external data.
- Added support for DNS queries on an alternate port.
- Added support for $MSG_NO_PROGRAM to suppress the "program: " prefix.
- Fixed problem with struct ucred not being pulled in properly.
- Fixed several problems with dns_qualify.
Development of this version has been sponsored by FutureQuest, Inc.
ossi@FutureQuest.net http://www.FutureQuest.net/
-------------------------------------------------------------------------------
Changes in version 2.03
- Reverted libbg-cli back to static linkage (for now) to fix problem
......
bglibs
One stop library package
Bruce Guenter <bruce@untroubled.org>
Version 2.03
2015-02-06
Version 2.04
2018-02-23
This package contains a collection of libraries written by myself and
put in use in various packages.
......@@ -22,7 +22,7 @@ Installation:
- After the package has been compiled, run the following command as root:
make install
Copyright(C) 2015 Bruce Guenter <bruce@untroubled.org>
Copyright(C) 2018 Bruce Guenter <bruce@untroubled.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
......
......@@ -71,6 +71,7 @@ dict/init.c
dict/load_list.c
dict/load_map.c
dict/str_free.c
dns-responder.c
fmt/char.c
fmt/chars.c
fmt/lcase.c
......
bglibs 2.03
bglibs 2.04
Name: bglibs
Summary: BG Libraries Collection
Version: 2.03
Version: 2.04
Release: 1
License: GPL
Group: Development/Libraries
......
#include "fmt.h"
#include "iobuf.h"
#include "ipv4.h"
#include "msg.h"
#include "socket.h"
#include "uint16.h"
#include "uint32.h"
#include <sys/wait.h>
#define DUMP void dump_rrs(int count, const union dns_result_rrs* rr)
#define NODUMP DUMP { (void)count; (void)rr; }
#define RESPONSE static const struct dns_response
extern DUMP;
static int dns_responder_pid = 0;
extern ipv4port dns_use_port;
struct dns_response_rr
{
const char* name;
uint16 namelen;
uint16 type;
uint16 class;
uint32 ttl;
const char* rdata;
uint16 rdatalen;
};
struct dns_response
{
uint16 ancount, nscount, arcount;
struct dns_response_rr rr[8];
};
static long dump_name(const unsigned char* data)
{
long o = 0;
unsigned char l;
while ((l = data[o++]) > 0) {
obuf_write(&outbuf, (const char*)data+o, l);
obuf_putc(&outbuf, '.');
o += l;
};
return o;
}
static long dump_request(const unsigned char* packet, long len)
{
uint16 first = uint16_get_msb(packet+2);
uint16 qdcount = uint16_get_msb(packet+4);
uint16 ancount = uint16_get_msb(packet+6);
uint16 nscount = uint16_get_msb(packet+8);
uint16 arcount = uint16_get_msb(packet+10);
long o = 12;
obuf_putf(&outbuf, "d{: ID=XX QR=}d{ opcode=}d{ AA=}d{ TC=}d{ RD=}d{ RA=}d{ Z=}d{ RCODE=}d{ QDCOUNT=}d{ ANCOUNT=}d{ NSCOUNT=}d{ ARCOUNT=}d{\n}",
len,
first >> 15, /* QR */
(first >> 11) & 0xf, /* Opcode */
(first >> 10) & 1, /* AA */
(first >> 9) & 1, /* TC */
(first >> 8) & 1, /* RD */
(first >> 7) & 1, /* RA */
(first >> 4) & 7, /* Z */
first & 0xf, /* RCODE */
qdcount, ancount, nscount, arcount);
for (; qdcount > 0; qdcount--) {
obuf_puts(&outbuf, "Question: ");
o += dump_name(packet+o);
obuf_putf(&outbuf, "{ QTYPE=}d{ QCLASS=}d{\n}", uint16_get_msb(packet+o), uint16_get_msb(packet+o+2));
o += 4;
}
obuf_flush(&outbuf);
return o;
}
static int make_response(unsigned char* buf, int offset, const struct dns_response* response)
{
int r;
uint16_pack_msb(response->ancount, buf+6);
uint16_pack_msb(response->nscount, buf+8);
uint16_pack_msb(response->arcount, buf+10);
for (r = 0; r < response->ancount + response->nscount + response->arcount; r++) {
const struct dns_response_rr* rr = &response->rr[r];
memcpy((char*)buf+offset, rr->name, rr->namelen);
offset += rr->namelen;
uint16_pack_msb(rr->type, buf+offset);
uint16_pack_msb(rr->class, buf+offset+2);
uint32_pack_msb(rr->ttl, buf+offset+4);
uint16_pack_msb(rr->rdatalen, buf+offset+8);
offset += 10;
memcpy((char*)buf+offset, rr->rdata, rr->rdatalen);
offset += rr->rdatalen;
}
return offset;
}
static void start_dns_responder(const struct dns_response* response, int count)
{
int sockfd;
ipv4addr addr;
ipv4port port;
unsigned char buf[512];
long r;
long offset;
if ((sockfd = socket_udp()) < 0)
die1sys(111, "Could not create DNS socket");
ipv4_scan("127.0.0.1", &addr);
if (!socket_bind4(sockfd, &addr, 0))
die1sys(111, "Could not bind DNS socket");
if (!socket_getaddr4(sockfd, &addr, &port))
die1sys(111, "Could not get DNS socket address");
if (0 && !socket_listen(sockfd, 0))
die1sys(111, "Could not listen to DNS socket");
dns_use_port = port;
buf[fmt_sdec((char*)buf, port)] = 0;
if (setenv("DNSCACHEIP", "127.0.0.1", 1) < 0
|| setenv("DNSCACHEPORT", (char*)buf, 1) < 0)
die1sys(111, "Could not set up DNS responder environment variables");
if ((dns_responder_pid = fork()) < 0)
die1sys(111, "Could not fork");
if (dns_responder_pid != 0)
return;
for (; count > 0; ++response, --count) {
if ((r = socket_recv4(sockfd, (char*)buf, sizeof buf, &addr, &port)) < 0)
die1sys(111, "Could not receive DNS packet");
offset = dump_request(buf, r);
offset = make_response(buf, offset, response);
if ((r = socket_send4(sockfd, (char*)buf, offset, &addr, port)) != offset)
die1sys(111, "Could not send DNS response");
}
exit(0);
}
static void wait_dns_responder(void)
{
waitpid(dns_responder_pid, NULL, 0);
}
void do_dns_test(const char* fqdn, int (*fn)(struct dns_result*, const char*))
{
struct dns_result out = {0};
debugfn(fn(&out, fqdn));
obuf_putf(&outbuf, "s{: count=}d{\n}", fqdn, out.count);
dump_rrs(out.count, &out.rr);
}
void do_dns_respond_tests(int (*fn)(struct dns_result*, const char*),
const char** fqdn,
const struct dns_response* responses, int count)
{
start_dns_responder(responses, count);
while (*fqdn) {
do_dns_test(*fqdn++, fn);
obuf_flush(&outbuf);
}
wait_dns_responder();
}
<html>
<body>
<a href="../djb.html">D. J. Bernstein</a>
<br><a href="../web.html">Internet publication</a>
<br><a href="../djbdns.html">djbdns</a>
<h1>User's guide to name qualification</h1>
<b>Qualification</b> means conversion
of a short host name that you type, such as <tt>cheetah</tt>,
into a complete (``fully qualified'') domain name,
such as <tt>cheetah.heaven.af.mil</tt>.
<p>
This page explains the djbdns qualification procedure.
These rules are followed by the
<tt>dns_ip4_qualify</tt>
library routine in djbdns,
and by programs that use the <tt>dns_ip4_qualify</tt> routine.
<h2>Rewriting instructions</h2>
Normally the djbdns qualification procedure
follows instructions listed in <tt>/etc/dnsrewrite</tt>,
a file created by your system administrator.
You can override <tt>/etc/dnsrewrite</tt>
by creating your own file
and setting the <tt>$DNSREWRITEFILE</tt> environment variable
to the name of that file.
<p>
Sample instructions:
<pre>
# anything.local -&gt; me
-.local:me
# me -&gt; 127.0.0.1
=me:127.0.0.1
# any.name.a -&gt; any.name.af.mil
*.a:.af.mil
# any-name-without-dots -&gt; any-name-without-dots.heaven.af.mil
?:.heaven.af.mil
# remove trailing dot
*.:
</pre>
<p>
Instructions are followed in order, each at most once.
There are four types of instructions:
<ul>
<li><tt>=<i>post</i>:<i>new</i></tt>
means that the host name <tt><i>post</i></tt> is replaced by <tt><i>new</i></tt>.
<li><tt>*<i>post</i>:<i>new</i></tt>
means that any name of the form <tt><i>prepost</i></tt>
is replaced by <tt><i>prenew</i></tt>.
<li><tt>?<i>post</i>:<i>new</i></tt>
means that any name of the form <tt><i>prepost</i></tt>,
where <tt><i>pre</i></tt> does not contain dots or brackets,
is replaced by <tt><i>prenew</i></tt>.
<li><tt>-<i>post</i>:<i>new</i></tt>
means that any name of the form <tt><i>prepost</i></tt>
is replaced by <tt><i>new</i></tt>.
</ul>
<h2>Searching</h2>
The djbdns qualification procedure
can search through DNS for several possible qualifications of a name.
For example, the name
<pre>
cheetah+.heaven.af.mil+.af.mil
</pre>
is qualified as <tt>cheetah.heaven.af.mil</tt>
if that name has IP addresses listed in DNS,
or <tt>cheetah.af.mil</tt> otherwise.
<p>
In general,
<tt><i>x</i>+<i>y1</i>+<i>y2</i>+<i>y3</i></tt>
is qualified as <tt><i>xy1</i></tt>
if <tt><i>xy1</i></tt> has IP addresses listed in DNS;
otherwise, as <tt><i>xy2</i></tt>
if <tt><i>xy2</i></tt> has IP addresses listed in DNS;
otherwise, as <tt><i>xy3</i></tt>.
You can list any number of +'s.
<p>
Searching is applied after rewriting,
so you can use a rewriting instruction such as
<pre>
?:+.heaven.af.mil+.af.mil
</pre>
to have
<tt>lion</tt> qualified as <tt>lion.heaven.af.mil</tt> or <tt>lion.af.mil</tt>,
and
<tt>tiger</tt> qualified as <tt>tiger.heaven.af.mil</tt> or <tt>tiger.af.mil</tt>,
and so on.
<p>
Searching is generally not a recommended feature.
If you rely on <tt>gw</tt> being qualified as <tt>gw.af.mil</tt>,
and someone suddenly adds a new <tt>gw.heaven.af.mil</tt>,
you'll end up talking to the wrong host.
It's better to rely on syntactic rules that you control.
<h2>Compatibility mechanisms</h2>
If the rewriting-instructions file does not exist,
the djbdns qualification procedure looks for a local domain name in three places:
<ol>
<li>the <tt>$LOCALDOMAIN</tt> environment variable, if it is set; or
<li>the first <tt>domain</tt> or <tt>search</tt> line
in <tt>/etc/resolv.conf</tt>,
if <tt>/etc/resolv.conf</tt> exists and has such a line; or
<li>everything after the first dot in the system's hostname.
</ol>
It then creates rewriting instructions of the form
<pre>
?:.<i>domain</i>
*.:
</pre>
so that <tt>.<i>domain</i></tt> is added to any name without dots or brackets.
<p>
You can specify searching in <tt>$LOCALDOMAIN</tt>
by using several domain names separated by spaces.
Your system administrator can specify searching in <tt>/etc/resolv.conf</tt>
by putting several domains on a <tt>search</tt> line.
<h2>Compatibility notes</h2>
Different DNS client programs use different qualification procedures.
Two major differences between the djbdns qualification procedure
and other qualification procedures:
<ul>
<li>Most programs use only <tt>/etc/resolv.conf</tt>.
They don't know anything about
<tt>/etc/dnsrewrite</tt> and <tt>$DNSREWRITEFILE</tt>.
<li>Most long-running programs
don't notice changes in <tt>/etc/resolv.conf</tt>;
they read <tt>/etc/resolv.conf</tt> when they start,
and they don't reread it until they are restarted.
In contrast, the djbdns qualification procedure
checks for changes every 10 minutes or 10000 uses.
</ul>
Two minor differences:
<ul>
<li>Some programs interpret
a <tt>domain</tt> line in <tt>/etc/resolv.conf</tt>
as specifying a search list consisting of various suffixes of the domain.
<li>Many programs will search the local domain
for names <i>with</i> dots.
</ul>
If you want the local domain searched for names with dots,
you can set it up with rewriting:
<pre>
# aol.com -&gt; aol.com or aol.com.heaven.af.mil
*:++.heaven.af.mil
# but skip directly to heaven.af.mil if no dots
?++.heaven.af.mil:.heaven.af.mil
</pre>
</ul>
</body>
</html>
[1]D. J. Bernstein
[2]Internet publication
[3]djbdns
User's guide to name qualification
Qualification means conversion of a short host name that you type, such
as cheetah, into a complete (``fully qualified'') domain name, such as
cheetah.heaven.af.mil.
This page explains the djbdns qualification procedure. These rules are