/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
*
* Copyright 2004, 2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
*/
/*
*/
#include "autoconf.h"
#ifdef KRB5_DNS_LOOKUP
#include "dnsglue.h"
/*
* Only use res_ninit() if there's also a res_ndestroy(), to avoid
* memory leaks (Linux & Solaris) and outright corruption (AIX 4.x,
* 5.x). While we're at it, make sure res_nsearch() is there too.
*
* In any case, it is probable that platforms having broken
* res_ninit() will have thread safety hacks for res_init() and _res.
*/
#endif
/*
* Opaque handle
*/
struct krb5int_dns_state {
int nclass;
int ntype;
void *ansp;
int anslen;
int ansmax;
int cur_ans;
#else
unsigned char *ptr;
unsigned short nanswers;
#endif
};
#if !HAVE_NS_INITPARSE
static int initparse(struct krb5int_dns_state *);
#endif
/*
* krb5int_dns_init()
*
* Initialize an opaque handle. Do name lookup and initial parsing of
* reply, skipping question section. Prepare to iterate over answer
* section. Returns -1 on error, 0 on success.
*/
int
{
#if USE_RES_NINIT
#endif
unsigned char *p;
return -1;
ret = -1;
nextincr = 2048;
#endif
#if USE_RES_NINIT
#else
#endif
if (ret < 0)
return -1;
do {
if (p == NULL) {
ret = -1;
goto errout;
}
#if USE_RES_NINIT
#else
#endif
ret = -1;
goto errout;
}
nextincr *= 2;
ret = -1;
goto errout;
}
#else
#endif
if (ret < 0)
goto errout;
ret = 0;
#if USE_RES_NINIT
#endif
if (ret < 0) {
}
}
return ret;
}
/*
* krb5int_dns_nextans - get next matching answer record
*
* Sets pp to NULL if no more records. Returns -1 on error, 0 on
* success.
*/
int
{
int len;
*lenp = 0;
if (len < 0)
return -1;
return 0;
}
}
return 0;
}
#endif
/*
* krb5int_dns_expand - wrapper for dn_expand()
*/
int
{
#else
#endif
}
/*
* Free stuff.
*/
void
{
return;
}
/*
* Compat routines for BIND 4
*/
#if !HAVE_NS_INITPARSE
/*
* initparse
*
* Skip header and question section of reply. Set a pointer to the
* beginning of the answer section, and prepare to iterate over
* answer records.
*/
static int
{
unsigned char *p;
int len;
#if !HAVE_DN_SKIPNAME
#endif
return -1;
p += sizeof(HEADER);
/*
* Skip query records.
*/
while (nqueries--) {
#if HAVE_DN_SKIPNAME
#else
#endif
return -1;
p += len + 4;
}
return 0;
}
/*
* krb5int_dns_nextans() - get next answer record
*
* Sets pp to NULL if no more records.
*/
int
{
int len;
unsigned char *p;
#if !HAVE_DN_SKIPNAME
#endif
*lenp = 0;
#if HAVE_DN_SKIPNAME
#else
#endif
return -1;
p += len;
/* Also skip 4 bytes of TTL */
return -1;
/* Solaris Kerberos - resync */
#if 0
return -1;
#endif
*pp = p;
return 0;
}
p += rdlen;
}
return 0;
out:
return -1;
}
#endif
/*
* Try to look up a TXT record pointing to a Kerberos realm
*/
{
const unsigned char *p, *base;
/*
* Form our query, and send it via DNS
*/
} else {
/* Realm names don't (normally) end with ".", but if the query
doesn't end with "." and doesn't get an answer as is, the
resolv code will try appending the local domain. Since the
realm names are absolutes, let's stop that.
But only if a name has been specified. If we are performing
a search on the prefix alone then the intention is to allow
the local domain or domain search lists to be expanded.
*/
}
return KRB5_ERR_HOST_REALM_UNKNOWN;
if (ret < 0)
goto errout;
goto errout;
p = base;
goto errout;
len = *p++;
goto errout;
}
/* Avoid a common error. */
retval = 0;
}
return retval;
}
#endif /* KRB5_DNS_LOOKUP */