Skip to content

Commit 362b76d

Browse files
committed
Remove hard-coded default for RHS
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
1 parent 39b21da commit 362b76d

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/lib/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ noinst_PROGRAMS = hestest
1515
hestest_SOURCES = hestest.c
1616
hestest_LDADD = libhesiod.la
1717

18-
TESTS_ENVIRONMENT = ./hestest
18+
TESTS_ENVIRONMENT = HES_DOMAIN=athena.mit.edu ./hestest
1919
TESTS = hestest.conf
2020

2121
EXTRA_DIST = hesiod.conf.sample hestest.conf

src/lib/hesiod.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ static const char rcsid[] = "$Id: hesiod.c,v 1.30 2002-04-03 21:40:55 ghudson Ex
8282
#endif
8383

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

8887
/* Maximum size of a Hesiod response from the DNS. */
@@ -141,6 +140,12 @@ int hesiod_init(void **context)
141140
else
142141
errno = ENOMEM;
143142
}
143+
/* Make sure that the rhs is set. */
144+
if (!ctx->rhs)
145+
{
146+
errno = ENOEXEC;
147+
return -1;
148+
}
144149
else
145150
return 0;
146151
}
@@ -302,13 +307,12 @@ static int read_config_file(struct hesiod_p *ctx, const char *filename)
302307
fp = fopen(filename, "r");
303308
if (!fp)
304309
{
305-
/* Use compiled in default domain names. */
310+
/* Use compiled in default LHS. */
306311
ctx->lhs = malloc(strlen(DEF_LHS) + 1);
307-
ctx->rhs = malloc(strlen(DEF_RHS) + 1);
308-
if (ctx->lhs && ctx->rhs)
312+
ctx->rhs = NULL;
313+
if (ctx->lhs)
309314
{
310315
strcpy(ctx->lhs, DEF_LHS);
311-
strcpy(ctx->rhs, DEF_RHS);
312316
return 0;
313317
}
314318
else

src/lib/hestest.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,18 @@ int main(int argc, char **argv)
6060
{
6161
FILE *fp;
6262
char buf[1024], *p, *q, name[128], type[128], proto[128], **list;
63+
const char *config = "hestest.conf";
6364
int line, errval;
6465
struct passwd *pw;
6566
struct servent *serv;
6667
struct hesiod_postoffice *po;
6768
struct hes_postoffice *compatpo;
6869
void *context;
6970

70-
if (argc != 2)
71-
{
72-
fprintf(stderr, "Usage: %s filename\n", argv[0]);
73-
return 1;
74-
}
71+
if (argc > 1)
72+
config = argv[1];
7573

76-
fp = fopen(argv[1], "r");
74+
fp = fopen(config, "r");
7775
if (!fp)
7876
{
7977
fprintf(stderr, "Couldn't open %s for reading.\n", argv[1]);

0 commit comments

Comments
 (0)