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