Use warn(3). Hardcode progname instead of using argv[0]. Use Pa for file
name.
This commit is contained in:
parent
95802bf803
commit
3029b69f0b
@ -28,20 +28,19 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include "hash.h"
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This hash function is stolen directly from the
|
||||
* Berkeley DB package. It already exists inside libc, but
|
||||
|
@ -34,9 +34,10 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "$Id$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* This is a specially hacked-up version of getnetgrent.c used to parse
|
||||
@ -51,10 +52,6 @@ static char sccsid[] = "$Id$";
|
||||
#include <unistd.h>
|
||||
#include "hash.h"
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Static Variables and functions used by setnetgrent(), getnetgrent() and
|
||||
* __endnetgrent().
|
||||
@ -211,7 +208,7 @@ parse_netgrp(group)
|
||||
* spewing it out from inside libc can actually hose
|
||||
* certain programs.
|
||||
*/
|
||||
fprintf(stderr, "Cycle in netgroup %s\n", lp->l_groupname);
|
||||
warnx("cycle in netgroup %s", lp->l_groupname);
|
||||
#endif
|
||||
return (1);
|
||||
} else
|
||||
@ -265,7 +262,7 @@ parse_netgrp(group)
|
||||
* stay silent by default for compatibility's sake.
|
||||
*/
|
||||
if (fields < 3)
|
||||
fprintf(stderr, "Bad entry (%s%s%s%s%s) in netgroup \"%s\"\n",
|
||||
warnx("bad entry (%s%s%s%s%s) in netgroup \"%s\"",
|
||||
grp->ng_str[NG_HOST] == NULL ? "" : grp->ng_str[NG_HOST],
|
||||
grp->ng_str[NG_USER] == NULL ? "" : ",",
|
||||
grp->ng_str[NG_USER] == NULL ? "" : grp->ng_str[NG_USER],
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.\" $Id: revnetgroup.8,v 1.4 1997/02/22 14:22:03 peter Exp $
|
||||
.\"
|
||||
.Dd October 24, 1995
|
||||
.Dt REVNETGROUP 8
|
||||
@ -39,10 +39,12 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm revnetgroup
|
||||
.Fl u
|
||||
.Op Fl f Ar netgroup_file
|
||||
.Nm revnetgroup
|
||||
.Fl h
|
||||
.Op Fl f Ar netgroup_file
|
||||
.Sh DESCRIPTION
|
||||
.Nm revnetgroup
|
||||
.Nm Revnetgroup
|
||||
processes the contents of a file in
|
||||
.Xr netgroup 5
|
||||
format into what is called
|
||||
@ -51,23 +53,24 @@ form. That is, where the original file shows
|
||||
netgroup memberships in terms of which members reside in a particular
|
||||
group, the reverse netgroup format specifies what groups are associated
|
||||
with a particular member. This information is used to generate the
|
||||
.Nm netgroup.byuser
|
||||
.Pa netgroup.byuser
|
||||
and
|
||||
.Nm netgroup.byhosts
|
||||
NIS maps. These reverse netgroup maps are used to help speed up
|
||||
.Pa netgroup.byhosts
|
||||
.Tn NIS
|
||||
maps. These reverse netgroup maps are used to help speed up
|
||||
netgroup lookups, particularly for the
|
||||
.Fn innetgr
|
||||
library function.
|
||||
.Pp
|
||||
For example, the standard
|
||||
.Nm /etc/netgroup
|
||||
.Pa /etc/netgroup
|
||||
file may list a netgroup and a list of its members. Here, the
|
||||
netgroup is considered the
|
||||
.Pa key
|
||||
.Em key
|
||||
and the member names are the
|
||||
.Pa data .
|
||||
.Em data .
|
||||
By contrast, the reverse
|
||||
.Nm netgroup.byusers
|
||||
.Pa netgroup.byusers
|
||||
database lists each unique
|
||||
member as the key and the netgroups to which the members belong become
|
||||
the data. Seperate databases are created to hold information pertaining
|
||||
@ -75,7 +78,8 @@ to users and hosts; this allows netgroup username lookups
|
||||
and netgroup hostname lookups to be performed using independent keyspaces.
|
||||
.Pp
|
||||
By constructing these reverse netgroup databases (and the corresponding
|
||||
NIS maps) in advance, the
|
||||
.Tn NIS
|
||||
maps) in advance, the
|
||||
.Xr getnetgrent 3
|
||||
library functions are spared from having to work out the dependencies
|
||||
themselves on the fly. This is important on networks with large numbers
|
||||
@ -83,22 +87,28 @@ of users and hosts, since it can take a considerable amount of time
|
||||
to process very large netgroup databases.
|
||||
.Pp
|
||||
The
|
||||
.Nm revnetgroup
|
||||
.Nm
|
||||
command prints its results on the standard output. It is usually called
|
||||
only by
|
||||
.Nm /var/yp/Makefile
|
||||
when rebuilding the NIS netgroup maps.
|
||||
.Pa /var/yp/Makefile
|
||||
when rebuilding the
|
||||
.Tn NIS
|
||||
netgroup maps.
|
||||
.Pp
|
||||
.Sh OPTIONS
|
||||
The
|
||||
.Nm revnetgroup
|
||||
.Nm
|
||||
command supports the following options:
|
||||
.Bl -tag -width flag
|
||||
.Bl -tag -width indent
|
||||
.It Fl u
|
||||
Generate netgroup.byuser output; only username information in the
|
||||
Generate
|
||||
.Pa netgroup.byuser
|
||||
output; only username information in the
|
||||
original netgroup file is processed.
|
||||
.It Fl h
|
||||
Generate netgroup.byhost output; only hostname information in the
|
||||
Generate
|
||||
.Pa netgroup.byhost
|
||||
output; only hostname information in the
|
||||
original netgroup file is processed. (Note at least one of the
|
||||
.Fl u
|
||||
or
|
||||
@ -106,27 +116,31 @@ or
|
||||
flags must be specified.)
|
||||
.It Op Fl f Ar netgroup_file
|
||||
The
|
||||
.Nm revnetgroup
|
||||
.Nm
|
||||
command uses
|
||||
.Nm /etc/netgroup
|
||||
.Pa /etc/netgroup
|
||||
as its default input file. The
|
||||
.Fl f
|
||||
flag allows the user to specify an alternate input file. Specifying ``-''
|
||||
as the input file causes
|
||||
.Nm revnetgroup
|
||||
.Nm
|
||||
to read from the standard input.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width Pa -compact
|
||||
.Bl -tag -width /var/yp/Makefile -compact
|
||||
.It Pa /var/yp/Makefile
|
||||
The Makefile that calls
|
||||
the Makefile that calls
|
||||
.Nm yp_mkdb
|
||||
and
|
||||
.Nm revnetgroup
|
||||
to build the NIS databases.
|
||||
to build the
|
||||
.Tn NIS
|
||||
databases
|
||||
.It Pa /etc/netgroup
|
||||
The default netgroup database file. This file is most often found
|
||||
only on the NIS master server.
|
||||
the default netgroup database file. This file is most often found
|
||||
only on the
|
||||
.Tn NIS
|
||||
master server
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr getnetgrent 3 ,
|
||||
@ -134,4 +148,4 @@ only on the NIS master server.
|
||||
.Xr netgroup 5 ,
|
||||
.Xr yp_mkdb 8
|
||||
.Sh AUTHOR
|
||||
Bill Paul <wpaul@ctr.columbia.edu>
|
||||
.An Bill Paul Aq wpaul@ctr.columbia.edu
|
||||
|
@ -34,21 +34,20 @@
|
||||
* Written by Bill Paul <wpaul@ctr.columbia.edu>
|
||||
* Center for Telecommunications Research
|
||||
* Columbia University, New York City
|
||||
*
|
||||
* $Id: revnetgroup.c,v 1.7 1997/03/28 15:48:15 imp Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <unistd.h>
|
||||
#include "hash.h"
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$Id: revnetgroup.c,v 1.7 1997/03/28 15:48:15 imp Exp $";
|
||||
#endif
|
||||
|
||||
/* Default location of netgroup file. */
|
||||
char *netgroup = "/etc/netgroup";
|
||||
|
||||
@ -61,15 +60,13 @@ struct group_entry *gtable[TABLESIZE];
|
||||
*/
|
||||
struct member_entry *mtable[TABLESIZE];
|
||||
|
||||
void usage(prog)
|
||||
char *prog;
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf (stderr,"usage: %s -u|-h [-f netgroup file]\n",prog);
|
||||
fprintf (stderr,"usage: revnetgroup -u|-h [-f netgroup file]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
@ -85,21 +82,21 @@ main(argc, argv)
|
||||
int hosts = -1, i;
|
||||
|
||||
if (argc < 2)
|
||||
usage(argv[0]);
|
||||
usage();
|
||||
|
||||
while ((ch = getopt(argc, argv, "uhf:")) != -1) {
|
||||
switch(ch) {
|
||||
case 'u':
|
||||
if (hosts != -1) {
|
||||
warnx("please use only one of -u or -h");
|
||||
usage(argv[0]);
|
||||
usage();
|
||||
}
|
||||
hosts = 0;
|
||||
break;
|
||||
case 'h':
|
||||
if (hosts != -1) {
|
||||
warnx("please use only one of -u or -h");
|
||||
usage(argv[0]);
|
||||
usage();
|
||||
}
|
||||
hosts = 1;
|
||||
break;
|
||||
@ -107,13 +104,13 @@ main(argc, argv)
|
||||
netgroup = optarg;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hosts == -1)
|
||||
usage(argv[0]);
|
||||
usage();
|
||||
|
||||
if (strcmp(netgroup, "-")) {
|
||||
if ((fp = fopen(netgroup, "r")) == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user