summaryrefslogtreecommitdiff
path: root/usr.sbin/ypserv/mknetid/mknetid.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ypserv/mknetid/mknetid.c')
-rw-r--r--usr.sbin/ypserv/mknetid/mknetid.c58
1 files changed, 16 insertions, 42 deletions
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;
}