From b27eae53e9115c750dab2cb31dd60c166fccc7ac Mon Sep 17 00:00:00 2001 From: Jacques Vidrine Date: Fri, 29 Sep 2000 12:56:33 +0000 Subject: [PATCH] Ignore HESIOD_CONFIG and HES_DOMAIN environmental variables for set-user-ID and set-group-ID programs. Suggested by: Danny Braniss --- lib/libc/net/hesiod.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c index f36757be05cb..220244c5d947 100644 --- a/lib/libc/net/hesiod.c +++ b/lib/libc/net/hesiod.c @@ -62,6 +62,7 @@ static char *rcsid = "$FreeBSD$"; #include #include #include +#include struct hesiod_p { char *lhs; /* normally ".ns" */ @@ -87,11 +88,17 @@ hesiod_init(context) { struct hesiod_p *ctx; const char *p, *configname; + int trust; + + trust = geteuid() == getuid() && getegid() == getgid(); ctx = malloc(sizeof(struct hesiod_p)); if (ctx) { *context = ctx; - configname = getenv("HESIOD_CONFIG"); + if (trust) + configname = getenv("HESIOD_CONFIG"); + else + configname = NULL; if (!configname) configname = _PATH_HESIOD_CONF; if (read_config_file(ctx, configname) >= 0) { @@ -99,7 +106,10 @@ hesiod_init(context) * The default rhs can be overridden by an * environment variable. */ - p = getenv("HES_DOMAIN"); + if (trust) + p = getenv("HES_DOMAIN"); + else + p = NULL; if (p) { if (ctx->rhs) free(ctx->rhs);