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