[2167] in Release_Engineering
New hesiod.c
daemon@ATHENA.MIT.EDU (marc@ATHENA.MIT.EDU)
Mon Feb 5 15:00:57 1990
From: marc@ATHENA.MIT.EDU
To: rel-eng@ATHENA.MIT.EDU
Cc: mar@ATHENA.MIT.EDU, marc@ATHENA.MIT.EDU, klee@ATHENA.MIT.EDU
Reply-To: marc@MIT.EDU
Date: Mon, 05 Feb 90 15:00:12 EST
I have added code to hesiod.c so that the library will allow the
environment variable HES_DOMAIN to override the value of RHS defined
in /etc/hesiod.conf or the compiled-in value. Patch follows.
Marc
*** /afs/rel-eng.athena.mit.edu/project/release/current/source/athena/athena.lib/hesiod/hesiod.c Thu Nov 16 06:49:52 1989
--- /afs/athena.mit.edu/user/m/marc/src/small/hesiod.c Mon Feb 5 14:52:15 1990
***************
*** 80,116 ****
if ((fp = fopen(HesConfigFile, "r")) == NULL) {
/* use defaults compiled in */
/* no file or no access uses defaults */
/* but poorly formed file returns error */
Hes_LHS = DEF_LHS; Hes_RHS = DEF_RHS;
! Hes_Errno = HES_ER_OK;
! return(Hes_Errno);
! }
! while(fgets(buf, MAXDNAME+7, fp) != NULL) {
! cp = buf;
! if (*cp == '#' || *cp == '\n') continue;
! while(*cp == ' ' || *cp == '\t') cp++;
! key = cp;
! while(*cp != ' ' && *cp != '\t' && *cp != '=') cp++;
! *cp++ = '\0';
! if (strcmp(key, "lhs") == 0) cpp = &Hes_LHS;
! else if (strcmp(key, "rhs") == 0) cpp = &Hes_RHS;
! else continue;
! while(*cp == ' ' || *cp == '\t' || *cp == '=') cp++;
! if (*cp != '.') {
! Hes_Errno = HES_ER_CONFIG;
! return(Hes_Errno);
}
- len = strlen(cp);
- *cpp = calloc((unsigned int) len, sizeof(char));
- (void) strncpy(*cpp, cp, len-1);
}
/* the LHS may be null, the RHS must not be null */
if (Hes_RHS == NULL)
Hes_Errno = HES_ER_CONFIG;
else
! Hes_Errno = HES_ER_OK;
return(Hes_Errno);
}
char *
hes_to_bind(HesiodName, HesiodNameType)
--- 80,118 ----
if ((fp = fopen(HesConfigFile, "r")) == NULL) {
/* use defaults compiled in */
/* no file or no access uses defaults */
/* but poorly formed file returns error */
Hes_LHS = DEF_LHS; Hes_RHS = DEF_RHS;
! } else {
! while(fgets(buf, MAXDNAME+7, fp) != NULL) {
! cp = buf;
! if (*cp == '#' || *cp == '\n') continue;
! while(*cp == ' ' || *cp == '\t') cp++;
! key = cp;
! while(*cp != ' ' && *cp != '\t' && *cp != '=') cp++;
! *cp++ = '\0';
! if (strcmp(key, "lhs") == 0) cpp = &Hes_LHS;
! else if (strcmp(key, "rhs") == 0) cpp = &Hes_RHS;
! else continue;
! while(*cp == ' ' || *cp == '\t' || *cp == '=') cp++;
! if (*cp != '.') {
! Hes_Errno = HES_ER_CONFIG;
! return(Hes_Errno);
! }
! len = strlen(cp);
! *cpp = calloc((unsigned int) len, sizeof(char));
! (void) strncpy(*cpp, cp, len-1);
}
}
+ /* see if the RHS is overridden by environment variable */
+ if ((cp = getenv("HES_DOMAIN")) != NULL)
+ Hes_RHS = strcpy(malloc(strlen(cp)+1),cp);
/* the LHS may be null, the RHS must not be null */
if (Hes_RHS == NULL)
Hes_Errno = HES_ER_CONFIG;
else
! Hes_Errno = HES_ER_OK;
return(Hes_Errno);
}
char *
hes_to_bind(HesiodName, HesiodNameType)