Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
configure FreeBSD so that various databases such as passwd and group can be
looked up using flat files, NIS, or Hesiod.
= Hesiod has been added to libc (see hesiod(3)).
= A library routine for parsing nsswitch.conf and invoking callback
functions as specified has been added to libc (see nsdispatch(3)).
= The following C library functions have been modified to use nsdispatch:
. getgrent, getgrnam, getgrgid
. getpwent, getpwnam, getpwuid
. getusershell
. getaddrinfo
. gethostbyname, gethostbyname2, gethostbyaddr
. getnetbyname, getnetbyaddr
. getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr
= host.conf has been removed from src/etc. rc.network has been modified
to warn that host.conf is no longer used at boot time. In addition, if
there is a host.conf but no nsswitch.conf, the latter is created at boot
time from the former.
Obtained from: NetBSD
2000-09-06 19:16:48 +01:00
|
|
|
/* $NetBSD: hesinfo.c,v 1.1 1999/01/25 22:45:55 lukem Exp $ */
|
|
|
|
|
|
|
|
/* Copyright 1988, 1996 by the Massachusetts Institute of Technology.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose and without
|
|
|
|
* fee is hereby granted, provided that the above copyright
|
|
|
|
* notice appear in all copies and that both that copyright
|
|
|
|
* notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of M.I.T. not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the
|
|
|
|
* software without specific, written prior permission.
|
|
|
|
* M.I.T. makes no representations about the suitability of
|
|
|
|
* this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This file is a simple driver for the Hesiod library. */
|
|
|
|
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2002-06-30 06:25:07 +01:00
|
|
|
__FBSDID("$FreeBSD$");
|
Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
configure FreeBSD so that various databases such as passwd and group can be
looked up using flat files, NIS, or Hesiod.
= Hesiod has been added to libc (see hesiod(3)).
= A library routine for parsing nsswitch.conf and invoking callback
functions as specified has been added to libc (see nsdispatch(3)).
= The following C library functions have been modified to use nsdispatch:
. getgrent, getgrnam, getgrgid
. getpwent, getpwnam, getpwuid
. getusershell
. getaddrinfo
. gethostbyname, gethostbyname2, gethostbyaddr
. getnetbyname, getnetbyaddr
. getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr
= host.conf has been removed from src/etc. rc.network has been modified
to warn that host.conf is no longer used at boot time. In addition, if
there is a host.conf but no nsswitch.conf, the latter is created at boot
time from the former.
Obtained from: NetBSD
2000-09-06 19:16:48 +01:00
|
|
|
|
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <hesiod.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
int
|
2002-09-05 00:29:10 +01:00
|
|
|
main(int argc, char **argv)
|
Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
configure FreeBSD so that various databases such as passwd and group can be
looked up using flat files, NIS, or Hesiod.
= Hesiod has been added to libc (see hesiod(3)).
= A library routine for parsing nsswitch.conf and invoking callback
functions as specified has been added to libc (see nsdispatch(3)).
= The following C library functions have been modified to use nsdispatch:
. getgrent, getgrnam, getgrgid
. getpwent, getpwnam, getpwuid
. getusershell
. getaddrinfo
. gethostbyname, gethostbyname2, gethostbyaddr
. getnetbyname, getnetbyaddr
. getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr
= host.conf has been removed from src/etc. rc.network has been modified
to warn that host.conf is no longer used at boot time. In addition, if
there is a host.conf but no nsswitch.conf, the latter is created at boot
time from the former.
Obtained from: NetBSD
2000-09-06 19:16:48 +01:00
|
|
|
{
|
|
|
|
char **list, **p, *bindname, *name, *type;
|
|
|
|
int lflag = 0, errflg = 0, bflag = 0, c;
|
|
|
|
void *context;
|
|
|
|
|
|
|
|
while ((c = getopt(argc, argv, "lb")) != -1) {
|
|
|
|
switch (c) {
|
|
|
|
case 'l':
|
|
|
|
lflag = 1;
|
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
bflag = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
errflg++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (argc - optind != 2 || errflg) {
|
2002-04-22 14:44:47 +01:00
|
|
|
fprintf(stderr, "usage: hesinfo [-bl] name type\n");
|
Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
configure FreeBSD so that various databases such as passwd and group can be
looked up using flat files, NIS, or Hesiod.
= Hesiod has been added to libc (see hesiod(3)).
= A library routine for parsing nsswitch.conf and invoking callback
functions as specified has been added to libc (see nsdispatch(3)).
= The following C library functions have been modified to use nsdispatch:
. getgrent, getgrnam, getgrgid
. getpwent, getpwnam, getpwuid
. getusershell
. getaddrinfo
. gethostbyname, gethostbyname2, gethostbyaddr
. getnetbyname, getnetbyaddr
. getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr
= host.conf has been removed from src/etc. rc.network has been modified
to warn that host.conf is no longer used at boot time. In addition, if
there is a host.conf but no nsswitch.conf, the latter is created at boot
time from the former.
Obtained from: NetBSD
2000-09-06 19:16:48 +01:00
|
|
|
fprintf(stderr, "\t-l selects long format\n");
|
|
|
|
fprintf(stderr, "\t-b also does hes_to_bind conversion\n");
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
name = argv[optind];
|
|
|
|
type = argv[optind + 1];
|
|
|
|
|
|
|
|
if (hesiod_init(&context) < 0) {
|
|
|
|
if (errno == ENOEXEC)
|
|
|
|
warnx(
|
|
|
|
"hesiod_init: Invalid Hesiod configuration file.");
|
|
|
|
else
|
|
|
|
warn("hesiod_init");
|
|
|
|
}
|
|
|
|
/* Display bind name if requested. */
|
|
|
|
if (bflag) {
|
|
|
|
if (lflag)
|
|
|
|
printf("hes_to_bind(%s, %s) expands to\n", name, type);
|
|
|
|
bindname = hesiod_to_bind(context, name, type);
|
|
|
|
if (!bindname) {
|
|
|
|
if (lflag)
|
|
|
|
printf("nothing\n");
|
|
|
|
if (errno == ENOENT)
|
|
|
|
warnx("hesiod_to_bind: Unknown rhs-extension.");
|
|
|
|
else
|
|
|
|
warn("hesiod_to_bind");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
printf("%s\n", bindname);
|
|
|
|
free(bindname);
|
|
|
|
if (lflag)
|
|
|
|
printf("which ");
|
|
|
|
}
|
|
|
|
if (lflag)
|
|
|
|
printf("resolves to\n");
|
|
|
|
|
|
|
|
/* Do the hesiod resolve and check for errors. */
|
|
|
|
list = hesiod_resolve(context, name, type);
|
|
|
|
if (!list) {
|
|
|
|
if (lflag)
|
|
|
|
printf("nothing\n");
|
|
|
|
if (errno == ENOENT)
|
|
|
|
warnx("hesiod_resolve: Hesiod name not found.");
|
|
|
|
else
|
|
|
|
warn("hesiod_resolve");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
/* Display the results. */
|
|
|
|
for (p = list; *p; p++)
|
|
|
|
printf("%s\n", *p);
|
|
|
|
|
|
|
|
hesiod_free_list(context, list);
|
|
|
|
hesiod_end(context);
|
|
|
|
exit(0);
|
|
|
|
}
|