version 1.9, 2015/01/16 06:40:08 |
version 1.10, 2015/10/10 05:26:57 |
|
|
#include <sys/socket.h> |
#include <sys/socket.h> |
|
|
#include <ctype.h> |
#include <ctype.h> |
|
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
#include <grp.h> |
#include <grp.h> |
#include <limits.h> |
#include <limits.h> |
|
|
static struct getentdb { |
static struct getentdb { |
const char *name; |
const char *name; |
int (*fn)(int, char *[]); |
int (*fn)(int, char *[]); |
|
const char *pledge; |
} databases[] = { |
} databases[] = { |
{ "ethers", ethers, }, |
{ "ethers", ethers, "stdio rpath" }, |
{ "group", group, }, |
{ "group", group, "stdio rpath" }, |
{ "hosts", hosts, }, |
{ "hosts", hosts, "stdio dns" }, |
{ "passwd", passwd, }, |
{ "passwd", passwd, "stdio rpath" }, |
{ "protocols", protocols, }, |
{ "protocols", protocols, "stdio rpath" }, |
{ "rpc", rpc, }, |
{ "rpc", rpc, "stdio rpath" }, |
{ "services", services, }, |
{ "services", services, "stdio rpath" }, |
{ "shells", shells, }, |
{ "shells", shells, "stdio rpath" }, |
|
|
{ NULL, NULL, }, |
{ NULL, NULL, }, |
}; |
}; |
|
|
int |
int |
|
|
{ |
{ |
struct getentdb *curdb; |
struct getentdb *curdb; |
|
|
|
if (pledge("stdio dns rpath", NULL) == -1) |
|
err(1, "pledge"); |
|
|
if (argc < 2) |
if (argc < 2) |
usage(); |
usage(); |
for (curdb = databases; curdb->name != NULL; curdb++) { |
for (curdb = databases; curdb->name != NULL; curdb++) { |
if (strcmp(curdb->name, argv[1]) == 0) { |
if (strcmp(curdb->name, argv[1]) == 0) { |
|
if (pledge(curdb->pledge, NULL) == -1) |
|
err(1, "pledge"); |
|
|
exit(curdb->fn(argc, argv)); |
exit(curdb->fn(argc, argv)); |
break; |
break; |
} |
} |