implement "protocols"
This commit is contained in:
parent
f6f918f7c3
commit
309eefda19
@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: getent.1,v 1.4 2004/11/26 04:52:45 lukem Exp $
|
.\" $NetBSD: getent.1,v 1.5 2004/11/26 05:07:12 lukem Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
|
.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
@ -66,6 +66,7 @@ may be one of:
|
|||||||
.It hosts Ta address hostname [alias ...]
|
.It hosts Ta address hostname [alias ...]
|
||||||
.It networks Ta name network [alias ...]
|
.It networks Ta name network [alias ...]
|
||||||
.It passwd Ta user:passwd:uid:gid:gecos:home_dir_shell
|
.It passwd Ta user:passwd:uid:gid:gecos:home_dir_shell
|
||||||
|
.It protocols Ta name protocol [alias ...]
|
||||||
.It shells Ta /path/to/shell
|
.It shells Ta /path/to/shell
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
@ -102,6 +103,7 @@ or 3 if there is no support for enumeration on
|
|||||||
.Xr networks 5 ,
|
.Xr networks 5 ,
|
||||||
.Xr nsswitch.conf 5 ,
|
.Xr nsswitch.conf 5 ,
|
||||||
.Xr passwd 5 ,
|
.Xr passwd 5 ,
|
||||||
|
.Xr protocols 5 ,
|
||||||
.Xr shells 5 .
|
.Xr shells 5 .
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
A
|
A
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: getent.c,v 1.2 2004/11/26 04:52:45 lukem Exp $ */
|
/* $NetBSD: getent.c,v 1.3 2004/11/26 05:07:12 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||||
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: getent.c,v 1.2 2004/11/26 04:52:45 lukem Exp $");
|
__RCSID("$NetBSD: getent.c,v 1.3 2004/11/26 05:07:12 lukem Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -66,6 +66,7 @@ static int group(int, char *[]);
|
|||||||
static int hosts(int, char *[]);
|
static int hosts(int, char *[]);
|
||||||
static int networks(int, char *[]);
|
static int networks(int, char *[]);
|
||||||
static int passwd(int, char *[]);
|
static int passwd(int, char *[]);
|
||||||
|
static int protocols(int, char *[]);
|
||||||
static int shells(int, char *[]);
|
static int shells(int, char *[]);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -86,6 +87,7 @@ main(int argc, char *argv[])
|
|||||||
{ "hosts", hosts, },
|
{ "hosts", hosts, },
|
||||||
{ "networks", networks, },
|
{ "networks", networks, },
|
||||||
{ "passwd", passwd, },
|
{ "passwd", passwd, },
|
||||||
|
{ "protocols", protocols, },
|
||||||
{ "shells", shells, },
|
{ "shells", shells, },
|
||||||
|
|
||||||
{ NULL, NULL, },
|
{ NULL, NULL, },
|
||||||
@ -193,6 +195,7 @@ group(int argc, char *argv[])
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hosts
|
* hosts
|
||||||
*/
|
*/
|
||||||
@ -310,6 +313,7 @@ networks(int argc, char *argv[])
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* passwd
|
* passwd
|
||||||
*/
|
*/
|
||||||
@ -357,6 +361,58 @@ passwd(int argc, char *argv[])
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* protocols
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
protocolsprint(const struct protoent *pe)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
assert(pe != NULL);
|
||||||
|
printf("%s\t%d", pe->p_name, pe->p_proto);
|
||||||
|
for (i = 0; pe->p_aliases[i] != NULL; i++) {
|
||||||
|
printf(" %s", pe->p_aliases[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
protocols(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct protoent *pe;
|
||||||
|
unsigned long id;
|
||||||
|
int i, rv;
|
||||||
|
|
||||||
|
assert(argc > 1);
|
||||||
|
assert(argv != NULL);
|
||||||
|
|
||||||
|
setprotoent(1);
|
||||||
|
rv = RV_OK;
|
||||||
|
if (argc == 2) {
|
||||||
|
while ((pe = getprotoent()) != NULL)
|
||||||
|
protocolsprint(pe);
|
||||||
|
} else {
|
||||||
|
for (i = 2; i < argc; i++) {
|
||||||
|
if (parsenum(argv[i], &id))
|
||||||
|
pe = getprotobynumber((int)id);
|
||||||
|
else
|
||||||
|
pe = getprotobyname(argv[i]);
|
||||||
|
if (pe != NULL)
|
||||||
|
protocolsprint(pe);
|
||||||
|
else {
|
||||||
|
rv = RV_NOTFOUND;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endprotoent();
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* shells
|
* shells
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user