diff options
author | Andrew Bartlett <abartlet@samba.org> | 2009-06-08 19:06:16 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2009-06-12 07:45:48 +1000 |
commit | 9b261c008a395a323e0516f4cd3f3134aa050577 (patch) | |
tree | 91cf543ba7ccd560313bea52fa8678f0456e8485 /source4/heimdal/lib/roken | |
parent | 5cef57ff7d899773a084d23838b7f18a83f6e79d (diff) | |
download | samba-9b261c008a395a323e0516f4cd3f3134aa050577.tar.gz samba-9b261c008a395a323e0516f4cd3f3134aa050577.tar.bz2 samba-9b261c008a395a323e0516f4cd3f3134aa050577.zip |
s4:heimdal: import lorikeet-heimdal-200906080040 (commit 904d0124b46eed7a8ad6e5b73e892ff34b6865ba)
Also including the supporting changes required to pass make test
A number of heimdal functions and constants have changed since we last
imported a tree (for the better, but inconvenient for us).
Andrew Bartlett
Diffstat (limited to 'source4/heimdal/lib/roken')
51 files changed, 442 insertions, 344 deletions
diff --git a/source4/heimdal/lib/roken/base64.c b/source4/heimdal/lib/roken/base64.c index d0096447b3..5e720eb6d4 100644 --- a/source4/heimdal/lib/roken/base64.c +++ b/source4/heimdal/lib/roken/base64.c @@ -31,10 +31,8 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif + #include <stdlib.h> #include <string.h> #include "base64.h" @@ -61,8 +59,10 @@ base64_encode(const void *data, int size, char **str) const unsigned char *q; p = s = (char *) malloc(size * 4 / 3 + 4); - if (p == NULL) + if (p == NULL) { + *str = NULL; return -1; + } q = (const unsigned char *) data; for (i = 0; i < size;) { diff --git a/source4/heimdal/lib/roken/bswap.c b/source4/heimdal/lib/roken/bswap.c index a87345be3f..67d240c231 100644 --- a/source4/heimdal/lib/roken/bswap.c +++ b/source4/heimdal/lib/roken/bswap.c @@ -31,13 +31,9 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -#endif #include "roken.h" -RCSID("$Id$"); - #ifndef HAVE_BSWAP32 unsigned int ROKEN_LIB_FUNCTION diff --git a/source4/heimdal/lib/roken/cloexec.c b/source4/heimdal/lib/roken/cloexec.c index 7a64233309..c015b1d8fa 100644 --- a/source4/heimdal/lib/roken/cloexec.c +++ b/source4/heimdal/lib/roken/cloexec.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <unistd.h> #include <fcntl.h> diff --git a/source4/heimdal/lib/roken/closefrom.c b/source4/heimdal/lib/roken/closefrom.c index 9198c05e26..7aa0ef7372 100644 --- a/source4/heimdal/lib/roken/closefrom.c +++ b/source4/heimdal/lib/roken/closefrom.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> diff --git a/source4/heimdal/lib/roken/copyhostent.c b/source4/heimdal/lib/roken/copyhostent.c index 58f5a112f2..69c1ba40ff 100644 --- a/source4/heimdal/lib/roken/copyhostent.c +++ b/source4/heimdal/lib/roken/copyhostent.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/dumpdata.c b/source4/heimdal/lib/roken/dumpdata.c index 88a86815ef..c5513c323d 100644 --- a/source4/heimdal/lib/roken/dumpdata.c +++ b/source4/heimdal/lib/roken/dumpdata.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <unistd.h> diff --git a/source4/heimdal/lib/roken/ecalloc.c b/source4/heimdal/lib/roken/ecalloc.c index 6c579e99f3..c8e6504030 100644 --- a/source4/heimdal/lib/roken/ecalloc.c +++ b/source4/heimdal/lib/roken/ecalloc.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdlib.h> #include <err.h> diff --git a/source4/heimdal/lib/roken/emalloc.c b/source4/heimdal/lib/roken/emalloc.c index d033e16a07..c937e6d707 100644 --- a/source4/heimdal/lib/roken/emalloc.c +++ b/source4/heimdal/lib/roken/emalloc.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdlib.h> #include <err.h> diff --git a/source4/heimdal/lib/roken/erealloc.c b/source4/heimdal/lib/roken/erealloc.c index 239d6a0eab..f77c8ec733 100644 --- a/source4/heimdal/lib/roken/erealloc.c +++ b/source4/heimdal/lib/roken/erealloc.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdlib.h> #include <err.h> diff --git a/source4/heimdal/lib/roken/estrdup.c b/source4/heimdal/lib/roken/estrdup.c index fb353d0d85..ab7f26550b 100644 --- a/source4/heimdal/lib/roken/estrdup.c +++ b/source4/heimdal/lib/roken/estrdup.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdlib.h> #include <err.h> diff --git a/source4/heimdal/lib/roken/freeaddrinfo.c b/source4/heimdal/lib/roken/freeaddrinfo.c index 1721d20aaf..434e49e888 100644 --- a/source4/heimdal/lib/roken/freeaddrinfo.c +++ b/source4/heimdal/lib/roken/freeaddrinfo.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/freehostent.c b/source4/heimdal/lib/roken/freehostent.c index 38c27d3380..335504300a 100644 --- a/source4/heimdal/lib/roken/freehostent.c +++ b/source4/heimdal/lib/roken/freehostent.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/gai_strerror.c b/source4/heimdal/lib/roken/gai_strerror.c index 084900a58a..10beac05ea 100644 --- a/source4/heimdal/lib/roken/gai_strerror.c +++ b/source4/heimdal/lib/roken/gai_strerror.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/get_window_size.c b/source4/heimdal/lib/roken/get_window_size.c index 9b200c1159..60fb1764fa 100644 --- a/source4/heimdal/lib/roken/get_window_size.c +++ b/source4/heimdal/lib/roken/get_window_size.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdlib.h> #ifdef HAVE_UNISTD_H diff --git a/source4/heimdal/lib/roken/getaddrinfo.c b/source4/heimdal/lib/roken/getaddrinfo.c index a8fc029c32..8c61299763 100644 --- a/source4/heimdal/lib/roken/getaddrinfo.c +++ b/source4/heimdal/lib/roken/getaddrinfo.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/getarg.c b/source4/heimdal/lib/roken/getarg.c index 3168ccc53d..60b0f645af 100644 --- a/source4/heimdal/lib/roken/getarg.c +++ b/source4/heimdal/lib/roken/getarg.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdio.h> #include <stdlib.h> diff --git a/source4/heimdal/lib/roken/getdtablesize.c b/source4/heimdal/lib/roken/getdtablesize.c new file mode 100644 index 0000000000..a515af3454 --- /dev/null +++ b/source4/heimdal/lib/roken/getdtablesize.c @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1995-2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +#include "roken.h" + +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef TIME_WITH_SYS_TIME +#include <sys/time.h> +#include <time.h> +#elif defined(HAVE_SYS_TIME_H) +#include <sys/time.h> +#else +#include <time.h> +#endif +#ifdef HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif + +#ifdef HAVE_SYS_SYSCTL_H +#include <sys/sysctl.h> +#endif + +int ROKEN_LIB_FUNCTION +getdtablesize(void) +{ + int files = -1; +#if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX) + files = sysconf(_SC_OPEN_MAX); +#else /* !defined(HAVE_SYSCONF) */ +#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE) + struct rlimit res; + if (getrlimit(RLIMIT_NOFILE, &res) == 0) + files = res.rlim_cur; +#else /* !definded(HAVE_GETRLIMIT) */ +#if defined(HAVE_SYSCTL) && defined(CTL_KERN) && defined(KERN_MAXFILES) + int mib[2]; + size_t len; + + mib[0] = CTL_KERN; + mib[1] = KERN_MAXFILES; + len = sizeof(files); + sysctl(&mib, 2, &files, sizeof(files), NULL, 0); +#endif /* defined(HAVE_SYSCTL) */ +#endif /* !definded(HAVE_GETRLIMIT) */ +#endif /* !defined(HAVE_SYSCONF) */ + +#ifdef OPEN_MAX + if (files < 0) + files = OPEN_MAX; +#endif + +#ifdef NOFILE + if (files < 0) + files = NOFILE; +#endif + + return files; +} diff --git a/source4/heimdal/lib/roken/getipnodebyaddr.c b/source4/heimdal/lib/roken/getipnodebyaddr.c index e3c2b50e32..ddaec03a89 100644 --- a/source4/heimdal/lib/roken/getipnodebyaddr.c +++ b/source4/heimdal/lib/roken/getipnodebyaddr.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/getipnodebyname.c b/source4/heimdal/lib/roken/getipnodebyname.c index ec578937b7..16fdbdd24a 100644 --- a/source4/heimdal/lib/roken/getipnodebyname.c +++ b/source4/heimdal/lib/roken/getipnodebyname.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/getnameinfo.c b/source4/heimdal/lib/roken/getnameinfo.c index 865cc09dc8..0621cfeee1 100644 --- a/source4/heimdal/lib/roken/getnameinfo.c +++ b/source4/heimdal/lib/roken/getnameinfo.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/getprogname.c b/source4/heimdal/lib/roken/getprogname.c index b01a3d7e45..933b6dec79 100644 --- a/source4/heimdal/lib/roken/getprogname.c +++ b/source4/heimdal/lib/roken/getprogname.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/h_errno.c b/source4/heimdal/lib/roken/h_errno.c index 0cee02d472..7e49f8008f 100644 --- a/source4/heimdal/lib/roken/h_errno.c +++ b/source4/heimdal/lib/roken/h_errno.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #ifndef HAVE_H_ERRNO int h_errno = -17; /* Some magic number */ diff --git a/source4/heimdal/lib/roken/hex.c b/source4/heimdal/lib/roken/hex.c index 2167172f9f..95488af5c7 100644 --- a/source4/heimdal/lib/roken/hex.c +++ b/source4/heimdal/lib/roken/hex.c @@ -31,10 +31,8 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H + #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" #include <ctype.h> #include "hex.h" @@ -60,12 +58,16 @@ hex_encode(const void *data, size_t size, char **str) char *p; /* check for overflow */ - if (size * 2 < size) + if (size * 2 < size) { + *str = NULL; return -1; + } p = malloc(size * 2 + 1); - if (p == NULL) + if (p == NULL) { + *str = NULL; return -1; + } for (i = 0; i < size; i++) { p[i * 2] = hexchar[(*q >> 4) & 0xf]; diff --git a/source4/heimdal/lib/roken/hostent_find_fqdn.c b/source4/heimdal/lib/roken/hostent_find_fqdn.c index 9376c1da36..b5f2b42f60 100644 --- a/source4/heimdal/lib/roken/hostent_find_fqdn.c +++ b/source4/heimdal/lib/roken/hostent_find_fqdn.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/inet_aton.c b/source4/heimdal/lib/roken/inet_aton.c index c42697c63c..c9b21e00f8 100644 --- a/source4/heimdal/lib/roken/inet_aton.c +++ b/source4/heimdal/lib/roken/inet_aton.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/inet_ntop.c b/source4/heimdal/lib/roken/inet_ntop.c index 5e4e4f9dc7..daf3e926dd 100644 --- a/source4/heimdal/lib/roken/inet_ntop.c +++ b/source4/heimdal/lib/roken/inet_ntop.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/inet_pton.c b/source4/heimdal/lib/roken/inet_pton.c index f2a9af3aa3..ad60824f4a 100644 --- a/source4/heimdal/lib/roken/inet_pton.c +++ b/source4/heimdal/lib/roken/inet_pton.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/issuid.c b/source4/heimdal/lib/roken/issuid.c index 257481cffb..2999e8249c 100644 --- a/source4/heimdal/lib/roken/issuid.c +++ b/source4/heimdal/lib/roken/issuid.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/net_read.c b/source4/heimdal/lib/roken/net_read.c index ae025ffc71..9d055d0068 100644 --- a/source4/heimdal/lib/roken/net_read.c +++ b/source4/heimdal/lib/roken/net_read.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <sys/types.h> #include <unistd.h> diff --git a/source4/heimdal/lib/roken/net_write.c b/source4/heimdal/lib/roken/net_write.c index 11f5b8d7be..515f210973 100644 --- a/source4/heimdal/lib/roken/net_write.c +++ b/source4/heimdal/lib/roken/net_write.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <sys/types.h> #include <unistd.h> diff --git a/source4/heimdal/lib/roken/parse_time.c b/source4/heimdal/lib/roken/parse_time.c index 6065eeb425..b581970bd7 100644 --- a/source4/heimdal/lib/roken/parse_time.c +++ b/source4/heimdal/lib/roken/parse_time.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <parse_units.h> #include "parse_time.h" diff --git a/source4/heimdal/lib/roken/parse_units.c b/source4/heimdal/lib/roken/parse_units.c index 4dbd7b489b..a848298c57 100644 --- a/source4/heimdal/lib/roken/parse_units.c +++ b/source4/heimdal/lib/roken/parse_units.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdio.h> #include <ctype.h> diff --git a/source4/heimdal/lib/roken/resolve.c b/source4/heimdal/lib/roken/resolve.c index f358a5b266..a74e438cf8 100644 --- a/source4/heimdal/lib/roken/resolve.c +++ b/source4/heimdal/lib/roken/resolve.c @@ -31,9 +31,9 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H + #include <config.h> -#endif + #include "roken.h" #ifdef HAVE_ARPA_NAMESER_H #include <arpa/nameser.h> @@ -41,6 +41,9 @@ #ifdef HAVE_RESOLV_H #include <resolv.h> #endif +#ifdef HAVE_DNS_H +#include <dns.h> +#endif #include "resolve.h" #include <assert.h> @@ -78,7 +81,7 @@ static struct stot{ int _resolve_debug = 0; int ROKEN_LIB_FUNCTION -dns_string_to_type(const char *name) +rk_dns_string_to_type(const char *name) { struct stot *p = stot; for(p = stot; p->name; p++) @@ -88,7 +91,7 @@ dns_string_to_type(const char *name) } const char * ROKEN_LIB_FUNCTION -dns_type_to_string(int type) +rk_dns_type_to_string(int type) { struct stot *p = stot; for(p = stot; p->name; p++) @@ -100,7 +103,7 @@ dns_type_to_string(int type) #if (defined(HAVE_RES_SEARCH) || defined(HAVE_RES_NSEARCH)) && defined(HAVE_DN_EXPAND) static void -dns_free_rr(struct resource_record *rr) +dns_free_rr(struct rk_resource_record *rr) { if(rr->domain) free(rr->domain); @@ -110,13 +113,13 @@ dns_free_rr(struct resource_record *rr) } void ROKEN_LIB_FUNCTION -dns_free_data(struct dns_reply *r) +rk_dns_free_data(struct rk_dns_reply *r) { - struct resource_record *rr; + struct rk_resource_record *rr; if(r->q.domain) free(r->q.domain); for(rr = r->head; rr;){ - struct resource_record *tmp = rr; + struct rk_resource_record *tmp = rr; rr = rr->next; dns_free_rr(tmp); } @@ -125,9 +128,9 @@ dns_free_data(struct dns_reply *r) static int parse_record(const unsigned char *data, const unsigned char *end_data, - const unsigned char **pp, struct resource_record **ret_rr) + const unsigned char **pp, struct rk_resource_record **ret_rr) { - struct resource_record *rr; + struct rk_resource_record *rr; int type, class, ttl; unsigned size; int status; @@ -401,7 +404,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data, #ifndef TEST_RESOLVE static #endif -struct dns_reply* +struct rk_dns_reply* parse_reply(const unsigned char *data, size_t len) { const unsigned char *p; @@ -409,8 +412,8 @@ parse_reply(const unsigned char *data, size_t len) int i; char host[MAXDNAME]; const unsigned char *end_data = data + len; - struct dns_reply *r; - struct resource_record **rr; + struct rk_dns_reply *r; + struct rk_resource_record **rr; r = calloc(1, sizeof(*r)); if (r == NULL) @@ -449,16 +452,16 @@ parse_reply(const unsigned char *data, size_t len) } status = dn_expand(data, end_data, p, host, sizeof(host)); if(status < 0){ - dns_free_data(r); + rk_dns_free_data(r); return NULL; } r->q.domain = strdup(host); if(r->q.domain == NULL) { - dns_free_data(r); + rk_dns_free_data(r); return NULL; } if (p + status + 4 > end_data) { - dns_free_data(r); + rk_dns_free_data(r); return NULL; } p += status; @@ -470,21 +473,21 @@ parse_reply(const unsigned char *data, size_t len) rr = &r->head; for(i = 0; i < r->h.ancount; i++) { if(parse_record(data, end_data, &p, rr) != 0) { - dns_free_data(r); + rk_dns_free_data(r); return NULL; } rr = &(*rr)->next; } for(i = 0; i < r->h.nscount; i++) { if(parse_record(data, end_data, &p, rr) != 0) { - dns_free_data(r); + rk_dns_free_data(r); return NULL; } rr = &(*rr)->next; } for(i = 0; i < r->h.arcount; i++) { if(parse_record(data, end_data, &p, rr) != 0) { - dns_free_data(r); + rk_dns_free_data(r); return NULL; } rr = &(*rr)->next; @@ -501,20 +504,42 @@ parse_reply(const unsigned char *data, size_t len) #endif #endif -static struct dns_reply * +#if defined(HAVE_DNS_SEARCH) +#define resolve_search(h,n,c,t,r,l) \ + ((int)dns_search(h,n,c,t,r,l,(struct sockaddr *)&from,&fromsize)) +#define resolve_free_handle(h) dns_free(h) +#elif defined(HAVE_RES_NSEARCH) +#define resolve_search(h,n,c,t,r,l) res_nsearch(h,n,c,t,r,l) +#define resolve_free_handle(h) rk_res_free(h); +#else +#define resolve_search(h,n,c,t,r,l) res_search(n,c,t,r,l) +#define handle 0 +#define resolve_free_handle(h) +#endif + + +static struct rk_dns_reply * dns_lookup_int(const char *domain, int rr_class, int rr_type) { - struct dns_reply *r; - unsigned char *reply = NULL; + struct rk_dns_reply *r; + void *reply = NULL; int size; int len; -#ifdef HAVE_RES_NSEARCH +#if defined(HAVE_DNS_SEARCH) + struct sockaddr_storage from; + uint32_t fromsize = sizeof(from); + dns_handle_t handle; + + handle = dns_open(NULL); + if (handle == NULL) + return NULL; +#elif defined(HAVE_RES_NSEARCH) struct __res_state state; + struct __res_state *handle = &state; + memset(&state, 0, sizeof(state)); - if(res_ninit(&state)) + if(res_ninit(handle)) return NULL; /* is this the best we can do? */ -#elif defined(HAVE__RES) - u_long old_options = 0; #endif size = 0; @@ -527,45 +552,33 @@ dns_lookup_int(const char *domain, int rr_class, int rr_type) if (size <= len) size = len; if (_resolve_debug) { -#ifdef HAVE_RES_NSEARCH +#if defined(HAVE_DNS_SEARCH) + dns_set_debug(handle, 1); +#elif defined(HAVE_RES_NSEARCH) state.options |= RES_DEBUG; -#elif defined(HAVE__RES) - old_options = _res.options; - _res.options |= RES_DEBUG; #endif fprintf(stderr, "dns_lookup(%s, %d, %s), buffer size %d\n", domain, - rr_class, dns_type_to_string(rr_type), size); + rr_class, rk_dns_type_to_string(rr_type), size); } reply = malloc(size); if (reply == NULL) { -#ifdef HAVE_RES_NSEARCH - rk_res_free(&state); -#endif + resolve_free_handle(handle); return NULL; } -#ifdef HAVE_RES_NSEARCH - len = res_nsearch(&state, domain, rr_class, rr_type, reply, size); -#else - len = res_search(domain, rr_class, rr_type, reply, size); -#endif + + len = resolve_search(handle, domain, rr_class, rr_type, reply, size); + if (_resolve_debug) { -#if defined(HAVE__RES) && !defined(HAVE_RES_NSEARCH) - _res.options = old_options; -#endif fprintf(stderr, "dns_lookup(%s, %d, %s) --> %d\n", - domain, rr_class, dns_type_to_string(rr_type), len); + domain, rr_class, rk_dns_type_to_string(rr_type), len); } - if (len < 0) { -#ifdef HAVE_RES_NSEARCH - rk_res_free(&state); -#endif + if (len <= 0) { + resolve_free_handle(handle); free(reply); return NULL; } } while (size < len && len < rk_DNS_MAX_PACKET_SIZE); -#ifdef HAVE_RES_NSEARCH - rk_res_free(&state); -#endif + resolve_free_handle(handle); len = min(len, size); r = parse_reply(reply, len); @@ -573,25 +586,25 @@ dns_lookup_int(const char *domain, int rr_class, int rr_type) return r; } -struct dns_reply * ROKEN_LIB_FUNCTION -dns_lookup(const char *domain, const char *type_name) +struct rk_dns_reply * ROKEN_LIB_FUNCTION +rk_dns_lookup(const char *domain, const char *type_name) { int type; - type = dns_string_to_type(type_name); + type = rk_dns_string_to_type(type_name); if(type == -1) { if(_resolve_debug) fprintf(stderr, "dns_lookup: unknown resource type: `%s'\n", type_name); return NULL; } - return dns_lookup_int(domain, C_IN, type); + return dns_lookup_int(domain, rk_ns_c_in, type); } static int compare_srv(const void *a, const void *b) { - const struct resource_record *const* aa = a, *const* bb = b; + const struct rk_resource_record *const* aa = a, *const* bb = b; if((*aa)->u.srv->priority == (*bb)->u.srv->priority) return ((*aa)->u.srv->weight - (*bb)->u.srv->weight); @@ -604,10 +617,10 @@ compare_srv(const void *a, const void *b) /* try to rearrange the srv-records by the algorithm in RFC2782 */ void ROKEN_LIB_FUNCTION -dns_srv_order(struct dns_reply *r) +rk_dns_srv_order(struct rk_dns_reply *r) { - struct resource_record **srvs, **ss, **headp; - struct resource_record *rr; + struct rk_resource_record **srvs, **ss, **headp; + struct rk_resource_record *rr; int num_srv = 0; #if defined(HAVE_INITSTATE) && defined(HAVE_SETSTATE) @@ -648,7 +661,7 @@ dns_srv_order(struct dns_reply *r) for(ss = srvs; ss < srvs + num_srv; ) { int sum, rnd, count; - struct resource_record **ee, **tt; + struct rk_resource_record **ee, **tt; /* find the last record with the same priority and count the sum of all weights */ for(sum = 0, tt = ss; tt < srvs + num_srv; tt++) { @@ -693,19 +706,19 @@ dns_srv_order(struct dns_reply *r) #else /* NOT defined(HAVE_RES_SEARCH) && defined(HAVE_DN_EXPAND) */ -struct dns_reply * ROKEN_LIB_FUNCTION -dns_lookup(const char *domain, const char *type_name) +struct rk_dns_reply * ROKEN_LIB_FUNCTION +rk_dns_lookup(const char *domain, const char *type_name) { return NULL; } void ROKEN_LIB_FUNCTION -dns_free_data(struct dns_reply *r) +rk_dns_free_data(struct rk_dns_reply *r) { } void ROKEN_LIB_FUNCTION -dns_srv_order(struct dns_reply *r) +rk_dns_srv_order(struct rk_dns_reply *r) { } diff --git a/source4/heimdal/lib/roken/resolve.h b/source4/heimdal/lib/roken/resolve.h index d181dfa070..91b2afefe7 100644 --- a/source4/heimdal/lib/roken/resolve.h +++ b/source4/heimdal/lib/roken/resolve.h @@ -44,7 +44,11 @@ #endif #endif -typedef enum { +enum { + rk_ns_c_in = 1 +}; + +enum { rk_ns_t_invalid = 0, /* Cookie. */ rk_ns_t_a = 1, /* Host address. */ rk_ns_t_ns = 2, /* Authoritative server. */ @@ -99,99 +103,38 @@ typedef enum { rk_ns_t_any = 255, /* Wildcard match. */ rk_ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ rk_ns_t_max = 65536 -} rk_ns_type; - -/* We use these, but they are not always present in <arpa/nameser.h> */ - -#ifndef C_IN -#define C_IN 1 -#endif - -#ifndef T_A -#define T_A 1 -#endif -#ifndef T_NS -#define T_NS 2 -#endif -#ifndef T_CNAME -#define T_CNAME 5 -#endif -#ifndef T_SOA -#define T_SOA 5 -#endif -#ifndef T_PTR -#define T_PTR 12 -#endif -#ifndef T_MX -#define T_MX 15 -#endif -#ifndef T_TXT -#define T_TXT 16 -#endif -#ifndef T_AFSDB -#define T_AFSDB 18 -#endif -#ifndef T_SIG -#define T_SIG 24 -#endif -#ifndef T_KEY -#define T_KEY 25 -#endif -#ifndef T_AAAA -#define T_AAAA 28 -#endif -#ifndef T_SRV -#define T_SRV 33 -#endif -#ifndef T_NAPTR -#define T_NAPTR 35 -#endif -#ifndef T_CERT -#define T_CERT 37 -#endif -#ifndef T_SSHFP -#define T_SSHFP 44 -#endif +}; #ifndef MAXDNAME #define MAXDNAME 1025 #endif -#define dns_query rk_dns_query #define mx_record rk_mx_record #define srv_record rk_srv_record #define key_record rk_key_record #define sig_record rk_sig_record #define cert_record rk_cert_record #define sshfp_record rk_sshfp_record -#define resource_record rk_resource_record -#define dns_reply rk_dns_reply - -#define dns_lookup rk_dns_lookup -#define dns_free_data rk_dns_free_data -#define dns_string_to_type rk_dns_string_to_type -#define dns_type_to_string rk_dns_type_to_string -#define dns_srv_order rk_dns_srv_order -struct dns_query{ +struct rk_dns_query{ char *domain; unsigned type; unsigned class; }; -struct mx_record{ +struct rk_mx_record{ unsigned preference; char domain[1]; }; -struct srv_record{ +struct rk_srv_record{ unsigned priority; unsigned weight; unsigned port; char target[1]; }; -struct key_record { +struct rk_key_record { unsigned flags; unsigned protocol; unsigned algorithm; @@ -199,7 +142,7 @@ struct key_record { u_char key_data[1]; }; -struct sig_record { +struct rk_sig_record { unsigned type; unsigned algorithm; unsigned labels; @@ -212,7 +155,7 @@ struct sig_record { char sig_data[1]; /* also includes signer */ }; -struct cert_record { +struct rk_cert_record { unsigned type; unsigned tag; unsigned algorithm; @@ -220,14 +163,14 @@ struct cert_record { u_char cert_data[1]; }; -struct sshfp_record { +struct rk_sshfp_record { unsigned algorithm; unsigned type; size_t sshfp_len; u_char sshfp_data[1]; }; -struct ds_record { +struct rk_ds_record { unsigned key_tag; unsigned algorithm; unsigned digest_type; @@ -235,7 +178,7 @@ struct ds_record { u_char digest_data[1]; }; -struct resource_record{ +struct rk_resource_record{ char *domain; unsigned type; unsigned class; @@ -243,23 +186,23 @@ struct resource_record{ unsigned size; union { void *data; - struct mx_record *mx; - struct mx_record *afsdb; /* mx and afsdb are identical */ - struct srv_record *srv; + struct rk_mx_record *mx; + struct rk_mx_record *afsdb; /* mx and afsdb are identical */ + struct rk_srv_record *srv; struct in_addr *a; char *txt; - struct key_record *key; - struct cert_record *cert; - struct sig_record *sig; - struct sshfp_record *sshfp; - struct ds_record *ds; + struct rk_key_record *key; + struct rk_cert_record *cert; + struct rk_sig_record *sig; + struct rk_sshfp_record *sshfp; + struct rk_ds_record *ds; }u; - struct resource_record *next; + struct rk_resource_record *next; }; #define rk_DNS_MAX_PACKET_SIZE 0xffff -struct dns_header { +struct rk_dns_header { unsigned id; unsigned flags; #define rk_DNS_HEADER_RESPONSE_FLAG 1 @@ -277,22 +220,30 @@ struct dns_header { unsigned arcount; }; -struct dns_reply{ - struct dns_header h; - struct dns_query q; - struct resource_record *head; +struct rk_dns_reply{ + struct rk_dns_header h; + struct rk_dns_query q; + struct rk_resource_record *head; }; -struct dns_reply* ROKEN_LIB_FUNCTION - dns_lookup(const char *, const char *); +#ifdef __cplusplus +extern "C" { +#endif + +struct rk_dns_reply* ROKEN_LIB_FUNCTION + rk_dns_lookup(const char *, const char *); void ROKEN_LIB_FUNCTION - dns_free_data(struct dns_reply *); + rk_dns_free_data(struct rk_dns_reply *); int ROKEN_LIB_FUNCTION - dns_string_to_type(const char *name); + rk_dns_string_to_type(const char *name); const char *ROKEN_LIB_FUNCTION - dns_type_to_string(int type); + rk_dns_type_to_string(int type); void ROKEN_LIB_FUNCTION - dns_srv_order(struct dns_reply*); + rk_dns_srv_order(struct rk_dns_reply*); + +#ifdef __cplusplus +} +#endif #endif /* __RESOLVE_H__ */ diff --git a/source4/heimdal/lib/roken/rkpty.c b/source4/heimdal/lib/roken/rkpty.c index ebc3a5d208..bff632f0f1 100644 --- a/source4/heimdal/lib/roken/rkpty.c +++ b/source4/heimdal/lib/roken/rkpty.c @@ -52,6 +52,10 @@ #include <libutil.h> #endif +#ifdef STREAMSPTY +#include <stropts.h> +#endif /* STREAMPTY */ + #include "roken.h" #include <getarg.h> @@ -93,6 +97,39 @@ open_pty(void) if(openpty(&master, &slave, line, 0, 0) == 0) return; #endif /* HAVE_OPENPTY .... */ +#ifdef STREAMSPTY + { + char *clone[] = { + "/dev/ptc", + "/dev/ptmx", + "/dev/ptm", + "/dev/ptym/clone", + NULL + }; + char **q; + + for(q = clone; *q; q++){ + master = open(*q, O_RDWR); + if(master >= 0){ +#ifdef HAVE_GRANTPT + grantpt(master); +#endif +#ifdef HAVE_UNLOCKPT + unlockpt(master); +#endif + strlcpy(line, ptsname(master), sizeof(line)); + slave = open(line, O_RDWR); + if (slave < 0) + errx(1, "failed to open slave when using %s", q); + ioctl(slave, I_PUSH, "ptem"); + ioctl(slave, I_PUSH, "ldterm"); + + return; + } + } + } +#endif /* STREAMSPTY */ + /* more cases, like open /dev/ptmx, etc */ exit(77); @@ -302,7 +339,6 @@ main(int argc, char **argv) parse_configuration(argv[0]); argv += 1; - argc -= 1; open_pty(); diff --git a/source4/heimdal/lib/roken/roken-common.h b/source4/heimdal/lib/roken/roken-common.h index 1d341258fe..1713b6609e 100644 --- a/source4/heimdal/lib/roken/roken-common.h +++ b/source4/heimdal/lib/roken/roken-common.h @@ -267,119 +267,154 @@ SigAction signal(int iSig, SigAction pAction); /* BSD compatible */ #endif #endif +#define simple_execve rk_simple_execve int ROKEN_LIB_FUNCTION simple_execve(const char*, char*const[], char*const[]); +#define simple_execve_timed rk_simple_execve_timed int ROKEN_LIB_FUNCTION simple_execve_timed(const char *, char *const[], char *const [], time_t (*)(void *), void *, time_t); + +#define simple_execvp rk_simple_execvp int ROKEN_LIB_FUNCTION simple_execvp(const char*, char *const[]); +#define simple_execvp_timed rk_simple_execvp_timed int ROKEN_LIB_FUNCTION simple_execvp_timed(const char *, char *const[], time_t (*)(void *), void *, time_t); + +#define simple_execlp rk_simple_execlp int ROKEN_LIB_FUNCTION simple_execlp(const char*, ...); +#define simple_execle rk_simple_execle int ROKEN_LIB_FUNCTION simple_execle(const char*, ...); -int ROKEN_LIB_FUNCTION -simple_execl(const char *file, ...); - +#define wait_for_process rk_wait_for_process int ROKEN_LIB_FUNCTION wait_for_process(pid_t); +#define wait_for_process_timed rk_wait_for_process_timed int ROKEN_LIB_FUNCTION wait_for_process_timed(pid_t, time_t (*)(void *), void *, time_t); +#define pipe_execv rk_pipe_execv int ROKEN_LIB_FUNCTION pipe_execv(FILE**, FILE**, FILE**, const char*, ...); +#define print_version rk_print_version void ROKEN_LIB_FUNCTION print_version(const char *); +#define eread rk_eread ssize_t ROKEN_LIB_FUNCTION eread (int fd, void *buf, size_t nbytes); +#define ewrite rk_ewrite ssize_t ROKEN_LIB_FUNCTION ewrite (int fd, const void *buf, size_t nbytes); struct hostent; +#define hostent_find_fqdn rk_hostent_find_fqdn const char * ROKEN_LIB_FUNCTION hostent_find_fqdn (const struct hostent *); +#define esetenv rk_esetenv void ROKEN_LIB_FUNCTION esetenv(const char *, const char *, int); +#define socket_set_address_and_port rk_socket_set_address_and_port void ROKEN_LIB_FUNCTION socket_set_address_and_port (struct sockaddr *, const void *, int); +#define socket_addr_size rk_socket_addr_size size_t ROKEN_LIB_FUNCTION socket_addr_size (const struct sockaddr *); +#define socket_set_any rk_socket_set_any void ROKEN_LIB_FUNCTION socket_set_any (struct sockaddr *, int); +#define socket_sockaddr_size rk_socket_sockaddr_size size_t ROKEN_LIB_FUNCTION socket_sockaddr_size (const struct sockaddr *); +#define socket_get_address rk_socket_get_address void * ROKEN_LIB_FUNCTION -socket_get_address (struct sockaddr *); +socket_get_address (const struct sockaddr *); +#define socket_get_port rk_socket_get_port int ROKEN_LIB_FUNCTION socket_get_port (const struct sockaddr *); +#define socket_set_port rk_socket_set_port void ROKEN_LIB_FUNCTION socket_set_port (struct sockaddr *, int); +#define socket_set_portrange rk_socket_set_portrange void ROKEN_LIB_FUNCTION socket_set_portrange (int, int, int); +#define socket_set_debug rk_socket_set_debug void ROKEN_LIB_FUNCTION socket_set_debug (int); +#define socket_set_tos rk_socket_set_tos void ROKEN_LIB_FUNCTION socket_set_tos (int, int); +#define socket_set_reuseaddr rk_socket_set_reuseaddr void ROKEN_LIB_FUNCTION socket_set_reuseaddr (int, int); +#define socket_set_ipv6only rk_socket_set_ipv6only void ROKEN_LIB_FUNCTION socket_set_ipv6only (int, int); +#define vstrcollect rk_vstrcollect char ** ROKEN_LIB_FUNCTION vstrcollect(va_list *ap); +#define strcollect rk_strcollect char ** ROKEN_LIB_FUNCTION strcollect(char *first, ...); +#define timevalfix rk_timevalfix void ROKEN_LIB_FUNCTION timevalfix(struct timeval *t1); +#define timevaladd rk_timevaladd void ROKEN_LIB_FUNCTION timevaladd(struct timeval *t1, const struct timeval *t2); +#define timevalsub rk_timevalsub void ROKEN_LIB_FUNCTION timevalsub(struct timeval *t1, const struct timeval *t2); +#define pid_file_write rk_pid_file_write char *ROKEN_LIB_FUNCTION pid_file_write (const char *progname); +#define pid_file_delete rk_pid_file_delete void ROKEN_LIB_FUNCTION pid_file_delete (char **); +#define read_environment rk_read_environment int ROKEN_LIB_FUNCTION read_environment(const char *file, char ***env); +#define free_environment rk_free_environment void ROKEN_LIB_FUNCTION free_environment(char **); +#define warnerr rk_warnerr void ROKEN_LIB_FUNCTION -warnerr(int doerrno, const char *fmt, va_list ap) +rk_warnerr(int doerrno, const char *fmt, va_list ap) __attribute__ ((format (printf, 2, 0))); void * ROKEN_LIB_FUNCTION diff --git a/source4/heimdal/lib/roken/roken.h.in b/source4/heimdal/lib/roken/roken.h.in index d71bee7b46..3fce136875 100644 --- a/source4/heimdal/lib/roken/roken.h.in +++ b/source4/heimdal/lib/roken/roken.h.in @@ -125,9 +125,6 @@ struct sockaddr_dl; #else #include <time.h> #endif -#ifdef HAVE_STRINGS_H -#include <strings.h> -#endif #ifdef HAVE_PATHS_H #include <paths.h> @@ -152,82 +149,125 @@ ROKEN_CPP_START #endif #ifndef HAVE_PUTENV +#define putenv rk_putenv int ROKEN_LIB_FUNCTION putenv(const char *); #endif #if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO) +#ifndef HAVE_SETENV +#define setenv rk_setenv +#endif int ROKEN_LIB_FUNCTION setenv(const char *, const char *, int); #endif #if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO) +#ifndef HAVE_UNSETENV +#define unsetenv rk_unsetenv +#endif void ROKEN_LIB_FUNCTION unsetenv(const char *); #endif #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO) +#ifndef HAVE_GETUSERSHELL +#define getusershell rk_getusershell +#define endusershell rk_endusershell +#endif char * ROKEN_LIB_FUNCTION getusershell(void); void ROKEN_LIB_FUNCTION endusershell(void); #endif #if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO) -int ROKEN_LIB_FUNCTION snprintf (char *, size_t, const char *, ...) +#ifndef HAVE_SNPRINTF +#define snprintf rk_snprintf +#endif +int ROKEN_LIB_FUNCTION + rk_snprintf (char *, size_t, const char *, ...) __attribute__ ((format (printf, 3, 4))); #endif #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO) +#ifndef HAVE_VSNPRINTF +#define vsnprintf rk_vsnprintf +#endif int ROKEN_LIB_FUNCTION - vsnprintf (char *, size_t, const char *, va_list) + rk_vsnprintf (char *, size_t, const char *, va_list) __attribute__((format (printf, 3, 0))); #endif #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO) +#ifndef HAVE_ASPRINTF +#define asprintf rk_asprintf +#endif int ROKEN_LIB_FUNCTION - asprintf (char **, const char *, ...) + rk_asprintf (char **, const char *, ...) __attribute__ ((format (printf, 2, 3))); #endif #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO) +#ifndef HAVE_VASPRINTF +#define vasprintf rk_vasprintf +#endif int ROKEN_LIB_FUNCTION - vasprintf (char **, const char *, va_list) + rk_vasprintf (char **, const char *, va_list) __attribute__((format (printf, 2, 0))); #endif #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO) +#ifndef HAVE_ASNPRINTF +#define asnprintf rk_asnprintf +#endif int ROKEN_LIB_FUNCTION - asnprintf (char **, size_t, const char *, ...) + rk_asnprintf (char **, size_t, const char *, ...) __attribute__ ((format (printf, 3, 4))); #endif #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO) +#ifndef HAVE_VASNPRINTF +#define vasnprintf rk_vasnprintf +#endif int ROKEN_LIB_FUNCTION vasnprintf (char **, size_t, const char *, va_list) __attribute__((format (printf, 3, 0))); #endif #ifndef HAVE_STRDUP +#define strdup rk_strdup char * ROKEN_LIB_FUNCTION strdup(const char *); #endif #if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO) +#ifndef HAVE_STRNDUP +#define strndup rk_strndup +#endif char * ROKEN_LIB_FUNCTION strndup(const char *, size_t); #endif #ifndef HAVE_STRLWR +#define strlwr rk_strlwr char * ROKEN_LIB_FUNCTION strlwr(char *); #endif #ifndef HAVE_STRNLEN +#define strnlen rk_strnlen size_t ROKEN_LIB_FUNCTION strnlen(const char*, size_t); #endif #if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO) +#ifndef HAVE_STRSEP +#define strsep rk_strsep +#endif char * ROKEN_LIB_FUNCTION strsep(char**, const char*); #endif #if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO) +#ifndef HAVE_STRSEP_COPY +#define strsep_copy rk_strsep_copy +#endif ssize_t ROKEN_LIB_FUNCTION strsep_copy(const char**, const char*, char*, size_t); #endif #ifndef HAVE_STRCASECMP +#define strcasecmp rk_strcasecmp int ROKEN_LIB_FUNCTION strcasecmp(const char *, const char *); #endif @@ -240,26 +280,34 @@ char * ROKEN_LIB_FUNCTION strtok_r(char *, const char *, char **); #endif #ifndef HAVE_STRUPR +#define strupr rk_strupr char * ROKEN_LIB_FUNCTION strupr(char *); #endif #ifndef HAVE_STRLCPY +#define strlcpy rk_strlcpy size_t ROKEN_LIB_FUNCTION strlcpy (char *, const char *, size_t); #endif #ifndef HAVE_STRLCAT +#define strlcat rk_strlcat size_t ROKEN_LIB_FUNCTION strlcat (char *, const char *, size_t); #endif #ifndef HAVE_GETDTABLESIZE +#define getdtablesize rk_getdtablesize int ROKEN_LIB_FUNCTION getdtablesize(void); #endif #if !defined(HAVE_STRERROR) && !defined(strerror) +#define strerror rk_strerror char * ROKEN_LIB_FUNCTION strerror(int); #endif #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO) +#ifndef HAVE_HSTRERROR +#define hstrerror rk_hstrerror +#endif /* This causes a fatal error under Psoriasis */ #if !(defined(SunOS) && (SunOS >= 50)) const char * ROKEN_LIB_FUNCTION hstrerror(int); @@ -271,20 +319,26 @@ extern int h_errno; #endif #if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO) +#ifndef HAVE_INET_ATON +#define inet_aton rk_inet_aton +#endif int ROKEN_LIB_FUNCTION inet_aton(const char *, struct in_addr *); #endif #ifndef HAVE_INET_NTOP +#define inet_ntop rk_inet_ntop const char * ROKEN_LIB_FUNCTION inet_ntop(int af, const void *src, char *dst, size_t size); #endif #ifndef HAVE_INET_PTON +#define inet_pton rk_inet_pton int ROKEN_LIB_FUNCTION inet_pton(int, const char *, void *); #endif #if !defined(HAVE_GETCWD) +#define getcwd rk_getcwd char* ROKEN_LIB_FUNCTION getcwd(char *, size_t); #endif @@ -297,91 +351,108 @@ struct passwd * ROKEN_LIB_FUNCTION k_getpwuid (uid_t); const char * ROKEN_LIB_FUNCTION get_default_username (void); #ifndef HAVE_SETEUID +#define seteuid rk_seteuid int ROKEN_LIB_FUNCTION seteuid(uid_t); #endif #ifndef HAVE_SETEGID +#define setegid rk_setegid int ROKEN_LIB_FUNCTION setegid(gid_t); #endif #ifndef HAVE_LSTAT +#define lstat rk_lstat int ROKEN_LIB_FUNCTION lstat(const char *, struct stat *); #endif #if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO) +#ifndef HAVE_MKSTEMP +#define mkstemp rk_mkstemp +#endif int ROKEN_LIB_FUNCTION mkstemp(char *); #endif #ifndef HAVE_CGETENT +#define cgetent rk_cgetent +#define cgetstr rk_cgetstr int ROKEN_LIB_FUNCTION cgetent(char **, char **, const char *); int ROKEN_LIB_FUNCTION cgetstr(char *, const char *, char **); #endif #ifndef HAVE_INITGROUPS +#define initgroups rk_initgroups int ROKEN_LIB_FUNCTION initgroups(const char *, gid_t); #endif #ifndef HAVE_FCHOWN +#define fchown rk_fchown int ROKEN_LIB_FUNCTION fchown(int, uid_t, gid_t); #endif #if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO) -int ROKEN_LIB_FUNCTION daemon(int, int); +#ifndef HAVE_DAEMON +#define daemon rk_daemon #endif - -#ifndef HAVE_INNETGR -int ROKEN_LIB_FUNCTION innetgr(const char *, const char *, - const char *, const char *); +int ROKEN_LIB_FUNCTION daemon(int, int); #endif #ifndef HAVE_CHOWN +#define chown rk_chown int ROKEN_LIB_FUNCTION chown(const char *, uid_t, gid_t); #endif #ifndef HAVE_RCMD +#define rcmd rk_rcmd int ROKEN_LIB_FUNCTION rcmd(char **, unsigned short, const char *, const char *, const char *, int *); #endif #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO) +#ifndef HAVE_INNETGR +#define innetgr rk_innetgr +#endif int ROKEN_LIB_FUNCTION innetgr(const char*, const char*, const char*, const char*); #endif #ifndef HAVE_IRUSEROK +#define iruserok rk_iruserok int ROKEN_LIB_FUNCTION iruserok(unsigned, int, const char *, const char *); #endif #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO) +#ifndef HAVE_GETHOSTNAME +#define gethostname rk_gethostname +#endif int ROKEN_LIB_FUNCTION gethostname(char *, int); #endif #ifndef HAVE_WRITEV +#define writev rk_writev ssize_t ROKEN_LIB_FUNCTION writev(int, const struct iovec *, int); #endif #ifndef HAVE_READV +#define readv rk_readv ssize_t ROKEN_LIB_FUNCTION readv(int, const struct iovec *, int); #endif -#ifndef HAVE_MKSTEMP -int ROKEN_LIB_FUNCTION -mkstemp(char *); -#endif - #ifndef HAVE_PIDFILE +#define pidfile rk_pidfile void ROKEN_LIB_FUNCTION pidfile (const char*); #endif #ifndef HAVE_BSWAP32 +#define bswap32 rk_bswap32 unsigned int ROKEN_LIB_FUNCTION bswap32(unsigned int); #endif #ifndef HAVE_BSWAP16 +#define bswap16 rk_bswap16 unsigned short ROKEN_LIB_FUNCTION bswap16(unsigned short); #endif @@ -399,6 +470,7 @@ unsigned short ROKEN_LIB_FUNCTION bswap16(unsigned short); #define LOCK_UN 8 /* Unlock */ #endif +#define flock rk_flock int flock(int fd, int operation); #endif /* HAVE_FLOCK */ @@ -431,6 +503,7 @@ struct winsize { int ROKEN_LIB_FUNCTION get_window_size(int fd, struct winsize *); #ifndef HAVE_VSYSLOG +#define vsyslog rk_vsyslog void ROKEN_LIB_FUNCTION vsyslog(int, const char *, va_list); #endif @@ -445,21 +518,25 @@ extern int opterr; #endif #ifndef HAVE_GETIPNODEBYNAME +#define getipnodebyname rk_getipnodebyname struct hostent * ROKEN_LIB_FUNCTION getipnodebyname (const char *, int, int, int *); #endif #ifndef HAVE_GETIPNODEBYADDR +#define getipnodebyaddr rk_getipnodebyaddr struct hostent * ROKEN_LIB_FUNCTION getipnodebyaddr (const void *, size_t, int, int *); #endif #ifndef HAVE_FREEHOSTENT +#define freehostent rk_freehostent void ROKEN_LIB_FUNCTION freehostent (struct hostent *); #endif #ifndef HAVE_COPYHOSTENT +#define copyhostent rk_copyhostent struct hostent * ROKEN_LIB_FUNCTION copyhostent (const struct hostent *); #endif @@ -527,6 +604,7 @@ struct addrinfo { #endif #ifndef HAVE_GETADDRINFO +#define getaddrinfo rk_getaddrinfo int ROKEN_LIB_FUNCTION getaddrinfo(const char *, const char *, @@ -535,6 +613,7 @@ getaddrinfo(const char *, #endif #ifndef HAVE_GETNAMEINFO +#define getnameinfo rk_getnameinfo int ROKEN_LIB_FUNCTION getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, @@ -543,11 +622,13 @@ getnameinfo(const struct sockaddr *, socklen_t, #endif #ifndef HAVE_FREEADDRINFO +#define freeaddrinfo rk_freeaddrinfo void ROKEN_LIB_FUNCTION freeaddrinfo(struct addrinfo *); #endif #ifndef HAVE_GAI_STRERROR +#define gai_strerror rk_gai_strerror const char * ROKEN_LIB_FUNCTION gai_strerror(int); #endif @@ -564,25 +645,31 @@ int ROKEN_LIB_FUNCTION roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **); #ifndef HAVE_STRFTIME +#define strftime rk_strftime size_t ROKEN_LIB_FUNCTION strftime (char *, size_t, const char *, const struct tm *); #endif #ifndef HAVE_STRPTIME +#define strptime rk_strptime char * ROKEN_LIB_FUNCTION strptime (const char *, const char *, struct tm *); #endif #ifndef HAVE_EMALLOC +#define emalloc rk_emalloc void * ROKEN_LIB_FUNCTION emalloc (size_t); #endif #ifndef HAVE_ECALLOC +#define ecalloc rk_ecalloc void * ROKEN_LIB_FUNCTION ecalloc(size_t, size_t); #endif #ifndef HAVE_EREALLOC +#define erealloc rk_erealloc void * ROKEN_LIB_FUNCTION erealloc (void *, size_t); #endif #ifndef HAVE_ESTRDUP +#define estrdup rk_estrdup char * ROKEN_LIB_FUNCTION estrdup (const char *); #endif @@ -630,10 +717,12 @@ roken_gethostbyaddr(const void*, size_t, int); #endif #ifndef HAVE_SETPROGNAME +#define setprogname rk_setprogname void ROKEN_LIB_FUNCTION setprogname(const char *); #endif #ifndef HAVE_GETPROGNAME +#define getprogname rk_getprogname const char * ROKEN_LIB_FUNCTION getprogname(void); #endif @@ -645,46 +734,69 @@ void ROKEN_LIB_FUNCTION mini_inetd_addrinfo (struct addrinfo*); void ROKEN_LIB_FUNCTION mini_inetd (int); #ifndef HAVE_LOCALTIME_R +#define localtime_r rk_localtime_r struct tm * ROKEN_LIB_FUNCTION localtime_r(const time_t *, struct tm *); #endif #if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO) +#ifndef HAVE_STRSVIS +#define strsvis rk_strsvis +#endif int ROKEN_LIB_FUNCTION strsvis(char *, const char *, int, const char *); #endif #if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO) +#ifndef HAVE_STRUNVIS +#define strunvis rk_strunvis +#endif int ROKEN_LIB_FUNCTION strunvis(char *, const char *); #endif #if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO) +#ifndef HAVE_STRVIS +#define strvis rk_strvis +#endif int ROKEN_LIB_FUNCTION strvis(char *, const char *, int); #endif #if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO) +#ifndef HAVE_STRVISX +#define strvisx rk_strvisx +#endif int ROKEN_LIB_FUNCTION strvisx(char *, const char *, size_t, int); #endif #if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO) +#ifndef HAVE_SVIS +#define svis rk_svis +#endif char * ROKEN_LIB_FUNCTION svis(char *, int, int, int, const char *); #endif #if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO) +#ifndef HAVE_UNVIS +#define unvis rk_unvis +#endif int ROKEN_LIB_FUNCTION unvis(char *, int, int *, int); #endif #if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO) +#ifndef HAVE_VIS +#define vis rk_vis +#endif char * ROKEN_LIB_FUNCTION vis(char *, int, int, int); #endif #if !defined(HAVE_CLOSEFROM) +#define closefrom rk_closefrom int ROKEN_LIB_FUNCTION closefrom(int); #endif diff --git a/source4/heimdal/lib/roken/roken_gethostby.c b/source4/heimdal/lib/roken/roken_gethostby.c index 12760456a4..d87a49a04b 100644 --- a/source4/heimdal/lib/roken/roken_gethostby.c +++ b/source4/heimdal/lib/roken/roken_gethostby.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/rtbl.c b/source4/heimdal/lib/roken/rtbl.c index cfb7657091..7d11a487cf 100644 --- a/source4/heimdal/lib/roken/rtbl.c +++ b/source4/heimdal/lib/roken/rtbl.c @@ -31,10 +31,8 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID ("$Id$"); -#endif + #include "roken.h" #include "rtbl.h" diff --git a/source4/heimdal/lib/roken/setprogname.c b/source4/heimdal/lib/roken/setprogname.c index 9beb07afe9..225e6ae092 100644 --- a/source4/heimdal/lib/roken/setprogname.c +++ b/source4/heimdal/lib/roken/setprogname.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" diff --git a/source4/heimdal/lib/roken/signal.c b/source4/heimdal/lib/roken/signal.c index 9141ca2bb1..19a4845435 100644 --- a/source4/heimdal/lib/roken/signal.c +++ b/source4/heimdal/lib/roken/signal.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <signal.h> #include "roken.h" diff --git a/source4/heimdal/lib/roken/simple_exec.c b/source4/heimdal/lib/roken/simple_exec.c index 7060cb8d37..86dde1bad2 100644 --- a/source4/heimdal/lib/roken/simple_exec.c +++ b/source4/heimdal/lib/roken/simple_exec.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdarg.h> #include <stdlib.h> @@ -51,10 +48,6 @@ RCSID("$Id$"); #include "roken.h" -#if !HAVE_DECL_ENVIRON -extern char **environ; -#endif - #define EX_NOEXEC 126 #define EX_NOTFOUND 127 @@ -316,20 +309,3 @@ simple_execle(const char *file, ... /* ,char *const envp[] */) free(argv); return ret; } - -int ROKEN_LIB_FUNCTION -simple_execl(const char *file, ...) -{ - va_list ap; - char **argv; - int ret; - - va_start(ap, file); - argv = vstrcollect(&ap); - va_end(ap); - if(argv == NULL) - return -1; - ret = simple_execve(file, argv, environ); - free(argv); - return ret; -} diff --git a/source4/heimdal/lib/roken/socket.c b/source4/heimdal/lib/roken/socket.c index a373eb7ed2..ab1b7ff344 100644 --- a/source4/heimdal/lib/roken/socket.c +++ b/source4/heimdal/lib/roken/socket.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" #include <err.h> @@ -152,17 +149,17 @@ socket_sockaddr_size (const struct sockaddr *sa) */ void * ROKEN_LIB_FUNCTION -socket_get_address (struct sockaddr *sa) +socket_get_address (const struct sockaddr *sa) { switch (sa->sa_family) { case AF_INET : { - struct sockaddr_in *sin4 = (struct sockaddr_in *)sa; - return &sin4->sin_addr; + const struct sockaddr_in *sin4 = (const struct sockaddr_in *)sa; + return rk_UNCONST(&sin4->sin_addr); } #ifdef HAVE_IPV6 case AF_INET6 : { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; - return &sin6->sin6_addr; + const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sa; + return rk_UNCONST(&sin6->sin6_addr); } #endif default : diff --git a/source4/heimdal/lib/roken/strcollect.c b/source4/heimdal/lib/roken/strcollect.c index a33d52134a..f444d05e25 100644 --- a/source4/heimdal/lib/roken/strcollect.c +++ b/source4/heimdal/lib/roken/strcollect.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdarg.h> #include <stdlib.h> diff --git a/source4/heimdal/lib/roken/strlwr.c b/source4/heimdal/lib/roken/strlwr.c index ea787d8184..1a6634b736 100644 --- a/source4/heimdal/lib/roken/strlwr.c +++ b/source4/heimdal/lib/roken/strlwr.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <string.h> #include <ctype.h> diff --git a/source4/heimdal/lib/roken/strpool.c b/source4/heimdal/lib/roken/strpool.c index aa80996946..dc56892144 100644 --- a/source4/heimdal/lib/roken/strpool.c +++ b/source4/heimdal/lib/roken/strpool.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <stdarg.h> #include <stdlib.h> diff --git a/source4/heimdal/lib/roken/strsep.c b/source4/heimdal/lib/roken/strsep.c index 7a93fb17aa..5cbf8557a5 100644 --- a/source4/heimdal/lib/roken/strsep.c +++ b/source4/heimdal/lib/roken/strsep.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <string.h> diff --git a/source4/heimdal/lib/roken/strsep_copy.c b/source4/heimdal/lib/roken/strsep_copy.c index 61b7d39c57..908e37ca40 100644 --- a/source4/heimdal/lib/roken/strsep_copy.c +++ b/source4/heimdal/lib/roken/strsep_copy.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <string.h> diff --git a/source4/heimdal/lib/roken/strupr.c b/source4/heimdal/lib/roken/strupr.c index d67dd20dd0..db2d987f9f 100644 --- a/source4/heimdal/lib/roken/strupr.c +++ b/source4/heimdal/lib/roken/strupr.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <string.h> #include <ctype.h> diff --git a/source4/heimdal/lib/roken/vis.c b/source4/heimdal/lib/roken/vis.c index 43705e4d50..c8d19a4455 100644 --- a/source4/heimdal/lib/roken/vis.c +++ b/source4/heimdal/lib/roken/vis.c @@ -56,10 +56,7 @@ */ #if 1 -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include "roken.h" #ifndef _DIAGASSERT #define _DIAGASSERT(X) diff --git a/source4/heimdal/lib/roken/xfree.c b/source4/heimdal/lib/roken/xfree.c index 5f6d86ee56..13366ce132 100644 --- a/source4/heimdal/lib/roken/xfree.c +++ b/source4/heimdal/lib/roken/xfree.c @@ -31,10 +31,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id$"); -#endif #include <unistd.h> |