summaryrefslogtreecommitdiff
path: root/usr.sbin/ypserv
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2009-12-20 12:34:00 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2009-12-20 12:34:00 +0000
commite062589e835eb747b7efd98158a3df37d91a87b2 (patch)
tree06aba4d9ebff94006e5fa1340b5d9c2f88926321 /usr.sbin/ypserv
parentd22f3a34dd2c27f8f12482ec1e706bd3fdc59def (diff)
When a passwd(5) file is not available, fall back to master.passwd(5).
That's useful because the latter is needed for passwd-maps, anyway. Make the master.passwd file name configurable in the same way as passwd. While here, do a bit of cleanup: - Drop the HOSTS, PASSWD, GROUP, NETID #defines: They are used nowhere else and serve no purpose. - Use err(3), it's simpler and more precise than fprintf(3)+goto. - Drop a debug statement forgotten a decade ago. - In the manual, improve .Nd, DESCRIPTION and .Xrs. Originally triggered by edd@'s gripes with our yp implementation. Regarding the manual, using many tweaks from jmc@. "I like this" ajacoutot@ "I think it's a good idea" edd@ "no opinion", "you decide" deraadt@
Diffstat (limited to 'usr.sbin/ypserv')
-rw-r--r--usr.sbin/ypserv/mknetid/mknetid.884
-rw-r--r--usr.sbin/ypserv/mknetid/mknetid.c58
2 files changed, 69 insertions, 73 deletions
diff --git a/usr.sbin/ypserv/mknetid/mknetid.8 b/usr.sbin/ypserv/mknetid/mknetid.8
index 7e8cd084412..3456bb12889 100644
--- a/usr.sbin/ypserv/mknetid/mknetid.8
+++ b/usr.sbin/ypserv/mknetid/mknetid.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mknetid.8,v 1.14 2009/10/16 09:46:40 sobrado Exp $
+.\" $OpenBSD: mknetid.8,v 1.15 2009/12/20 12:33:59 schwarze Exp $
.\"
.\" Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
.\" All rights reserved.
@@ -24,12 +24,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: October 16 2009 $
+.Dd $Mdocdate: December 20 2009 $
.Dt MKNETID 8
.Os
.Sh NAME
.Nm mknetid
-.Nd a YP filter program
+.Nd generate a YP map of group and domain memberships
.Sh SYNOPSIS
.Nm mknetid
.Bk -words
@@ -38,66 +38,88 @@
.Op Fl g Ar groupfile
.Op Fl h Ar hostfile
.Op Fl m Ar netidfile
+.Op Fl P Ar master.passwdfile
.Op Fl p Ar passwdfile
.Ek
.Sh DESCRIPTION
+The
.Nm
-is used to create a map named
-.Ar netid.byname .
-The map consists of information from
+utility combines information from the
.Xr passwd 5 ,
-.Xr group 5
-and
+.Xr group 5 ,
.Xr hosts 5 ,
-concatenated with a
+and
+.Xr netid 5
+files, printing it in
+.Xr netid 5
+format to the standard output.
+If the
+.Xr passwd 5
+file is not available, the
+.Xr master.passwd 5
+file is used instead.
+The
.Xr netid 5
-file, if one exists.
+file is optional and does not need to exist.
+.Pp
+The most common application is to pass the output to
+.Xr makedbm 8
+in order to create a
+.Pa netid.byname
+map for the
+.Xr yp 8
+subsystem.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl d Ar domain
-Which yp-domain if not default yp-domain.
+Use
+.Ar domain
+instead of the default
+.Xr domainname 1 .
.It Fl g Ar groupfile
-Alternate
-.Xr group 5
-file.
-Default is
+Use
+.Ar groupfile
+instead of
.Pa /etc/group .
.It Fl h Ar hostfile
-Alternate
-.Xr hosts 5
-file.
-Default is
+Use
+.Ar hostfile
+instead of
.Pa /etc/hosts .
.It Fl m Ar netidfile
-Alternate
-.Xr netid 5
-file.
-Default is
+Use
+.Ar netidfile
+instead of
.Pa /etc/netid .
-file.
+.It Fl P Ar master.passwdfile
+Use
+.Ar master.passwdfile
+instead of
+.Pa /etc/master.passwd .
.It Fl p Ar passwdfile
-Alternate
-.Xr passwd 5
-file.
-Default is
+Use
+.Ar passwdfile
+instead of
.Pa /etc/passwd .
.It Fl q
-Keep quiet about multiple occurrences of a UID.
+Keep quiet about multiple occurrences of a user ID.
Ignore all but the first.
.El
.Sh FILES
-.Bl -tag -width /etc/passwd -compact
+.Bl -tag -width /etc/master.passwd -compact
.It Pa /etc/passwd
+.It Pa /etc/master.passwd
.It Pa /etc/group
.It Pa /etc/hosts
.It Pa /etc/netid
.El
.Sh SEE ALSO
+.Xr domainname 1 ,
.Xr group 5 ,
.Xr hosts 5 ,
.Xr netid 5 ,
.Xr passwd 5 ,
-.Xr yp 8
+.Xr Makefile.yp 8
.Sh AUTHORS
.An Mats O Jansson Aq moj@stacken.kth.se
diff --git a/usr.sbin/ypserv/mknetid/mknetid.c b/usr.sbin/ypserv/mknetid/mknetid.c
index a901ad545aa..3ba3ecf4d89 100644
--- a/usr.sbin/ypserv/mknetid/mknetid.c
+++ b/usr.sbin/ypserv/mknetid/mknetid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mknetid.c,v 1.17 2009/10/27 23:59:58 deraadt Exp $ */
+/* $OpenBSD: mknetid.c,v 1.18 2009/12/20 12:33:59 schwarze Exp $ */
/*
* Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
@@ -49,29 +49,11 @@ struct user {
struct user *hprev, *hnext; /* links in hash order */
};
-#ifdef HOSTS
-char *HostFile = HOSTS;
-#else
char *HostFile = _PATH_HOSTS;
-#endif
-
-#ifdef PASSWD
-char *PasswdFile = PASSWD;
-#else
char *PasswdFile = _PATH_PASSWD;
-#endif
-
-#ifdef GROUP
-char *GroupFile = GROUP;
-#else
+char *MasterPasswdFile = _PATH_MASTERPASSWD;
char *GroupFile = _PATH_GROUP;
-#endif
-
-#ifdef NETID
-char *NetidFile = NETID;
-#else
char *NetidFile = "/etc/netid";
-#endif
#define HASHMAX 55
@@ -491,7 +473,7 @@ usage(void)
{
fprintf(stderr, "usage: mknetid [-q] [-d domain] [-g groupfile] "
"[-h hostfile] [-m netidfile]\n"
- " [-p passwdfile]\n");
+ " [-P master.passwdfile] [-p passwdfile]\n");
exit(1);
}
@@ -502,7 +484,7 @@ main(int argc, char *argv[])
int qflag = 0, ch;
char *domain = NULL;
- while ((ch = getopt(argc, argv, "d:g:h:m:p:q")) != -1)
+ while ((ch = getopt(argc, argv, "d:g:h:m:p:P:q")) != -1)
switch (ch) {
case 'd':
domain = optarg;
@@ -519,6 +501,9 @@ main(int argc, char *argv[])
case 'p':
PasswdFile = optarg;
break;
+ case 'P':
+ MasterPasswdFile = optarg;
+ break;
case 'q':
qflag++;
break;
@@ -534,27 +519,19 @@ main(int argc, char *argv[])
yp_get_default_domain(&domain);
pfile = fopen(PasswdFile, "r");
- if (pfile == NULL) {
- fprintf(stderr,"mknetid: can't open file \"%s\"\n",
- PasswdFile);
- goto bad;
- }
+ if (pfile == NULL)
+ pfile = fopen(MasterPasswdFile, "r");
+ if (pfile == NULL)
+ err(1, MasterPasswdFile);
gfile = fopen(GroupFile, "r");
- if (gfile == NULL) {
- fprintf(stderr,"mknetid: can't open file \"%s\"\n",
- GroupFile);
- goto bad;
- }
+ if (gfile == NULL)
+ err(1, GroupFile);
hfile = fopen(HostFile, "r");
- if (hfile == NULL) {
- fprintf(stderr,"mknetid: can't open file \"%s\"\n",
- HostFile);
- goto bad;
- }
+ if (hfile == NULL)
+ err(1, HostFile);
- printf("NetidFile: %s\n", NetidFile);
mfile = fopen(NetidFile, "r");
read_passwd(pfile, PasswdFile);
@@ -565,9 +542,6 @@ main(int argc, char *argv[])
if (mfile != NULL)
print_netid(mfile, NetidFile);
- return (0);
-bad:
- fprintf(stderr, "mknetid: passwd, group, host and netid maps not updated!\n");
- exit(1);
+ return 0;
}