convert from hes_*() -> hesiod_*()
This commit is contained in:
parent
456a96e766
commit
147dea105a
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getgrent.c,v 1.32 1999/01/20 02:59:37 lukem Exp $ */
|
||||
/* $NetBSD: getgrent.c,v 1.33 1999/01/25 01:09:34 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -39,12 +39,15 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)getgrent.c 8.2 (Berkeley) 3/21/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: getgrent.c,v 1.32 1999/01/20 02:59:37 lukem Exp $");
|
||||
__RCSID("$NetBSD: getgrent.c,v 1.33 1999/01/25 01:09:34 lukem Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <limits.h>
|
||||
#include <nsswitch.h>
|
||||
@ -52,6 +55,7 @@ __RCSID("$NetBSD: getgrent.c,v 1.32 1999/01/20 02:59:37 lukem Exp $");
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#ifdef HESIOD
|
||||
#include <hesiod.h>
|
||||
#endif
|
||||
@ -237,6 +241,12 @@ _dns_grscan(rv, cb_data, ap)
|
||||
const char *name = va_arg(ap, const char *);
|
||||
|
||||
char **hp;
|
||||
void *context;
|
||||
int r;
|
||||
|
||||
r = NS_UNAVAIL;
|
||||
if (hesiod_init(&context) == -1)
|
||||
return (r);
|
||||
|
||||
for (;;) {
|
||||
if (search) {
|
||||
@ -251,33 +261,33 @@ _dns_grscan(rv, cb_data, ap)
|
||||
}
|
||||
|
||||
line[sizeof(line) - 1] = '\0';
|
||||
hp = hes_resolve(line, "group");
|
||||
hp = hesiod_resolve(context, line, "group");
|
||||
if (hp == NULL) {
|
||||
switch (hes_error()) {
|
||||
case HES_ER_NOTFOUND:
|
||||
if (errno == ENOENT) {
|
||||
if (!search) {
|
||||
__gr_hesnum = 0;
|
||||
_gr_nomore = 1;
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
return NS_NOTFOUND;
|
||||
case HES_ER_OK:
|
||||
abort();
|
||||
break;
|
||||
default:
|
||||
return NS_UNAVAIL;
|
||||
r = NS_SUCCESS;
|
||||
} else
|
||||
r = NS_NOTFOUND;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* only check first elem */
|
||||
strncpy(line, hp[0], sizeof(line));
|
||||
line[sizeof(line) - 1] = '\0';
|
||||
hes_free(hp);
|
||||
if (matchline(search, gid, name))
|
||||
return NS_SUCCESS;
|
||||
else if (search)
|
||||
return NS_NOTFOUND;
|
||||
hesiod_free_list(context, hp);
|
||||
if (matchline(search, gid, name)) {
|
||||
r = NS_SUCCESS;
|
||||
break;
|
||||
} else if (search) {
|
||||
r = NS_NOTFOUND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
hesiod_end(context);
|
||||
return (r);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getpwent.c,v 1.38 1999/01/21 12:42:06 mycroft Exp $ */
|
||||
/* $NetBSD: getpwent.c,v 1.39 1999/01/25 01:09:34 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@ -39,7 +39,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: getpwent.c,v 1.38 1999/01/21 12:42:06 mycroft Exp $");
|
||||
__RCSID("$NetBSD: getpwent.c,v 1.39 1999/01/25 01:09:34 lukem Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@ -445,9 +445,11 @@ _dns_getpw(rv, cb_data, ap)
|
||||
const char *name;
|
||||
uid_t uid;
|
||||
int search;
|
||||
|
||||
char *map;
|
||||
char **hp;
|
||||
|
||||
void *context;
|
||||
int r;
|
||||
|
||||
search = va_arg(ap, int);
|
||||
switch (search) {
|
||||
@ -471,30 +473,33 @@ _dns_getpw(rv, cb_data, ap)
|
||||
}
|
||||
line[sizeof(line) - 1] = '\0';
|
||||
|
||||
hp = hes_resolve(line, map);
|
||||
r = NS_UNAVAIL;
|
||||
if (hesiod_init(&context) == -1)
|
||||
return (r);
|
||||
|
||||
hp = hesiod_resolve(context, line, map);
|
||||
if (hp == NULL) {
|
||||
switch (hes_error()) {
|
||||
case HES_ER_NOTFOUND:
|
||||
if (errno == ENOENT) {
|
||||
if (search == _PW_KEYBYNUM) {
|
||||
_pw_hesnum = 0;
|
||||
_pw_none = 1;
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
return NS_NOTFOUND;
|
||||
case HES_ER_OK:
|
||||
abort();
|
||||
break;
|
||||
default:
|
||||
return NS_UNAVAIL;
|
||||
r = NS_SUCCESS;
|
||||
} else
|
||||
r = NS_NOTFOUND;
|
||||
}
|
||||
goto cleanup_dns_getpw;
|
||||
}
|
||||
|
||||
strncpy(line, hp[0], sizeof(line)); /* only check first elem */
|
||||
line[sizeof(line) - 1] = '\0';
|
||||
hes_free(hp);
|
||||
hesiod_free_list(context, hp);
|
||||
if (__pwparse(&_pw_passwd, line))
|
||||
return NS_UNAVAIL;
|
||||
return NS_SUCCESS;
|
||||
r = NS_UNAVAIL;
|
||||
else
|
||||
r = NS_SUCCESS;
|
||||
cleanup_dns_getpw:
|
||||
hesiod_end(context);
|
||||
return (r);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getusershell.c,v 1.16 1999/01/20 13:11:18 christos Exp $ */
|
||||
/* $NetBSD: getusershell.c,v 1.17 1999/01/25 01:09:34 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1993
|
||||
@ -38,21 +38,24 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)getusershell.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: getusershell.c,v 1.16 1999/01/20 13:11:18 christos Exp $");
|
||||
__RCSID("$NetBSD: getusershell.c,v 1.17 1999/01/25 01:09:34 lukem Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <nsswitch.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stringlist.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HESIOD
|
||||
#include <hesiod.h>
|
||||
#endif
|
||||
@ -160,33 +163,36 @@ _dns_initshells(rv, cb_data, ap)
|
||||
va_list ap;
|
||||
{
|
||||
char shellname[] = "shells-XXXXX";
|
||||
int hsindex, hpi;
|
||||
int hsindex, hpi, r;
|
||||
char **hp;
|
||||
void *context;
|
||||
|
||||
if (sl)
|
||||
sl_free(sl, 1);
|
||||
sl = sl_init();
|
||||
r = NS_UNAVAIL;
|
||||
if (hesiod_init(&context) == -1)
|
||||
return (r);
|
||||
|
||||
for (hsindex = 0; ; hsindex++) {
|
||||
snprintf(shellname, sizeof(shellname)-1, "shells-%d", hsindex);
|
||||
hp = hes_resolve(shellname, "shells");
|
||||
hp = hesiod_resolve(context, shellname, "shells");
|
||||
if (hp == NULL) {
|
||||
switch(hes_error()) {
|
||||
case HES_ER_OK:
|
||||
break;
|
||||
case HES_ER_NOTFOUND:
|
||||
if (errno == ENOENT) {
|
||||
if (hsindex == 0)
|
||||
return NS_NOTFOUND;
|
||||
return NS_SUCCESS;
|
||||
default:
|
||||
return NS_UNAVAIL;
|
||||
r = NS_NOTFOUND;
|
||||
else
|
||||
r = NS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
for (hpi = 0; hp[hpi]; hpi++)
|
||||
sl_add(sl, hp[hpi]);
|
||||
free(hp);
|
||||
}
|
||||
}
|
||||
hesiod_end(context);
|
||||
return (r);
|
||||
}
|
||||
#endif /* HESIOD */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user