hesiod.c (65532) | hesiod.c (66451) |
---|---|
1/* $NetBSD: hesiod.c,v 1.9 1999/02/11 06:16:38 simonb Exp $ */ 2 3/* Copyright (c) 1996 by Internet Software Consortium. 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * --- 33 unchanged lines hidden (view full) --- 42 * This implementation is not truly thread-safe at the moment because 43 * it uses res_send() and accesses _res. 44 */ 45 46#include <sys/cdefs.h> 47 48#if defined(LIBC_SCCS) && !defined(lint) 49static char *orig_rcsid = "$NetBSD: hesiod.c,v 1.9 1999/02/11 06:16:38 simonb Exp $"; | 1/* $NetBSD: hesiod.c,v 1.9 1999/02/11 06:16:38 simonb Exp $ */ 2 3/* Copyright (c) 1996 by Internet Software Consortium. 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * --- 33 unchanged lines hidden (view full) --- 42 * This implementation is not truly thread-safe at the moment because 43 * it uses res_send() and accesses _res. 44 */ 45 46#include <sys/cdefs.h> 47 48#if defined(LIBC_SCCS) && !defined(lint) 49static char *orig_rcsid = "$NetBSD: hesiod.c,v 1.9 1999/02/11 06:16:38 simonb Exp $"; |
50static char *rcsid = "$FreeBSD: head/lib/libc/net/hesiod.c 65532 2000-09-06 18:16:48Z nectar $"; | 50static char *rcsid = "$FreeBSD: head/lib/libc/net/hesiod.c 66451 2000-09-29 12:56:33Z nectar $"; |
51#endif /* LIBC_SCCS and not lint */ 52 53#include <sys/types.h> 54#include <sys/param.h> 55#include <netinet/in.h> 56#include <arpa/nameser.h> 57 58#include <ctype.h> 59#include <errno.h> 60#include <hesiod.h> 61#include <resolv.h> 62#include <stdio.h> 63#include <stdlib.h> 64#include <string.h> | 51#endif /* LIBC_SCCS and not lint */ 52 53#include <sys/types.h> 54#include <sys/param.h> 55#include <netinet/in.h> 56#include <arpa/nameser.h> 57 58#include <ctype.h> 59#include <errno.h> 60#include <hesiod.h> 61#include <resolv.h> 62#include <stdio.h> 63#include <stdlib.h> 64#include <string.h> |
65#include <unistd.h> |
|
65 66struct hesiod_p { 67 char *lhs; /* normally ".ns" */ 68 char *rhs; /* AKA the default hesiod domain */ 69 int classes[2]; /* The class search order. */ 70}; 71 72#define MAX_HESRESP 1024 --- 9 unchanged lines hidden (view full) --- 82 * initialize a hesiod_p. 83 */ 84int 85hesiod_init(context) 86 void **context; 87{ 88 struct hesiod_p *ctx; 89 const char *p, *configname; | 66 67struct hesiod_p { 68 char *lhs; /* normally ".ns" */ 69 char *rhs; /* AKA the default hesiod domain */ 70 int classes[2]; /* The class search order. */ 71}; 72 73#define MAX_HESRESP 1024 --- 9 unchanged lines hidden (view full) --- 83 * initialize a hesiod_p. 84 */ 85int 86hesiod_init(context) 87 void **context; 88{ 89 struct hesiod_p *ctx; 90 const char *p, *configname; |
91 int trust; |
|
90 | 92 |
93 trust = geteuid() == getuid() && getegid() == getgid(); 94 |
|
91 ctx = malloc(sizeof(struct hesiod_p)); 92 if (ctx) { 93 *context = ctx; | 95 ctx = malloc(sizeof(struct hesiod_p)); 96 if (ctx) { 97 *context = ctx; |
94 configname = getenv("HESIOD_CONFIG"); | 98 if (trust) 99 configname = getenv("HESIOD_CONFIG"); 100 else 101 configname = NULL; |
95 if (!configname) 96 configname = _PATH_HESIOD_CONF; 97 if (read_config_file(ctx, configname) >= 0) { 98 /* 99 * The default rhs can be overridden by an 100 * environment variable. 101 */ | 102 if (!configname) 103 configname = _PATH_HESIOD_CONF; 104 if (read_config_file(ctx, configname) >= 0) { 105 /* 106 * The default rhs can be overridden by an 107 * environment variable. 108 */ |
102 p = getenv("HES_DOMAIN"); | 109 if (trust) 110 p = getenv("HES_DOMAIN"); 111 else 112 p = NULL; |
103 if (p) { 104 if (ctx->rhs) 105 free(ctx->rhs); 106 ctx->rhs = malloc(strlen(p) + 2); 107 if (ctx->rhs) { 108 *ctx->rhs = '.'; 109 strcpy(ctx->rhs + 1, 110 (*p == '.') ? p + 1 : p); --- 462 unchanged lines hidden --- | 113 if (p) { 114 if (ctx->rhs) 115 free(ctx->rhs); 116 ctx->rhs = malloc(strlen(p) + 2); 117 if (ctx->rhs) { 118 *ctx->rhs = '.'; 119 strcpy(ctx->rhs + 1, 120 (*p == '.') ? p + 1 : p); --- 462 unchanged lines hidden --- |