Skip to content

Commit

Permalink
Remove hard-coded default for RHS
Browse files Browse the repository at this point in the history
Don't fall back to using a default RHS when the configuration file can't
be read.  Original report from
https://bugzilla.redhat.com/show_bug.cgi?id=1332493
  • Loading branch information
nalind committed May 3, 2016
1 parent 39b21da commit 362b76d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/lib/Makefile.am
Expand Up @@ -15,7 +15,7 @@ noinst_PROGRAMS = hestest
hestest_SOURCES = hestest.c
hestest_LDADD = libhesiod.la

TESTS_ENVIRONMENT = ./hestest
TESTS_ENVIRONMENT = HES_DOMAIN=athena.mit.edu ./hestest
TESTS = hestest.conf

EXTRA_DIST = hesiod.conf.sample hestest.conf
14 changes: 9 additions & 5 deletions src/lib/hesiod.c
Expand Up @@ -82,7 +82,6 @@ static const char rcsid[] = "$Id: hesiod.c,v 1.30 2002-04-03 21:40:55 ghudson Ex
#endif

/* Defaults if the configuration file is not present. */
#define DEF_RHS ".athena.mit.edu"
#define DEF_LHS ".ns"

/* Maximum size of a Hesiod response from the DNS. */
Expand Down Expand Up @@ -141,6 +140,12 @@ int hesiod_init(void **context)
else
errno = ENOMEM;
}
/* Make sure that the rhs is set. */
if (!ctx->rhs)
{
errno = ENOEXEC;
return -1;
}
else
return 0;
}
Expand Down Expand Up @@ -302,13 +307,12 @@ static int read_config_file(struct hesiod_p *ctx, const char *filename)
fp = fopen(filename, "r");
if (!fp)
{
/* Use compiled in default domain names. */
/* Use compiled in default LHS. */
ctx->lhs = malloc(strlen(DEF_LHS) + 1);
ctx->rhs = malloc(strlen(DEF_RHS) + 1);
if (ctx->lhs && ctx->rhs)
ctx->rhs = NULL;
if (ctx->lhs)
{
strcpy(ctx->lhs, DEF_LHS);
strcpy(ctx->rhs, DEF_RHS);
return 0;
}
else
Expand Down
10 changes: 4 additions & 6 deletions src/lib/hestest.c
Expand Up @@ -60,20 +60,18 @@ int main(int argc, char **argv)
{
FILE *fp;
char buf[1024], *p, *q, name[128], type[128], proto[128], **list;
const char *config = "hestest.conf";
int line, errval;
struct passwd *pw;
struct servent *serv;
struct hesiod_postoffice *po;
struct hes_postoffice *compatpo;
void *context;

if (argc != 2)
{
fprintf(stderr, "Usage: %s filename\n", argv[0]);
return 1;
}
if (argc > 1)
config = argv[1];

fp = fopen(argv[1], "r");
fp = fopen(config, "r");
if (!fp)
{
fprintf(stderr, "Couldn't open %s for reading.\n", argv[1]);
Expand Down

0 comments on commit 362b76d

Please sign in to comment.