1999-07-25 13:01:04 +04:00
|
|
|
/* $NetBSD: mknetid.c,v 1.10 1999/07/25 09:01:04 lukem Exp $ */
|
1996-08-09 14:14:49 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Mats O Jansson
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
|
|
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
1997-10-13 07:51:58 +04:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#ifndef lint
|
1999-07-25 13:01:04 +04:00
|
|
|
__RCSID("$NetBSD: mknetid.c,v 1.10 1999/07/25 09:01:04 lukem Exp $");
|
1997-10-13 07:51:58 +04:00
|
|
|
#endif
|
|
|
|
|
1996-08-09 14:14:49 +04:00
|
|
|
/*
|
|
|
|
* Originally written by Mats O Jansson <moj@stacken.kth.se>
|
|
|
|
* Simplified a bit by Jason R. Thorpe <thorpej@NetBSD.ORG>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <err.h>
|
|
|
|
#include <grp.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
1998-06-08 10:53:47 +04:00
|
|
|
#include <util.h>
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1997-07-19 01:57:00 +04:00
|
|
|
#include <rpcsvc/ypclnt.h>
|
|
|
|
|
1996-08-09 14:14:49 +04:00
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
struct user {
|
|
|
|
char *usr_name; /* user name */
|
|
|
|
int usr_uid; /* user uid */
|
|
|
|
int usr_gid; /* user gid */
|
|
|
|
int gid_count; /* number of gids */
|
|
|
|
int gid[NGROUPS]; /* additional gids */
|
|
|
|
TAILQ_ENTRY(user) read; /* links in read order */
|
|
|
|
TAILQ_ENTRY(user) hash; /* links in hash order */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HASHMAX 55
|
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
void add_group __P((const char *, const char *));
|
|
|
|
void add_user __P((const char *, const char *, const char *));
|
1996-08-09 14:14:49 +04:00
|
|
|
int hashidx __P((char));
|
|
|
|
int isgsep __P((char));
|
1997-11-01 17:24:50 +03:00
|
|
|
int main __P((int, char *[]));
|
|
|
|
void print_hosts __P((const char *, const char *));
|
|
|
|
void print_netid __P((const char *));
|
|
|
|
void print_passwd_group __P((int, const char *));
|
|
|
|
void read_group __P((const char *));
|
|
|
|
void read_passwd __P((const char *));
|
|
|
|
void usage __P((void));
|
1996-08-09 14:14:49 +04:00
|
|
|
|
|
|
|
TAILQ_HEAD(user_list, user);
|
|
|
|
struct user_list root;
|
|
|
|
struct user_list hroot[HASHMAX];
|
|
|
|
|
1997-10-13 07:51:58 +04:00
|
|
|
extern char *__progname; /* from crt0.o */
|
1996-08-09 14:14:49 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
main(argc, argv)
|
|
|
|
int argc;
|
1997-07-19 01:57:00 +04:00
|
|
|
char *argv[];
|
1996-08-09 14:14:49 +04:00
|
|
|
{
|
1997-11-01 17:24:50 +03:00
|
|
|
char *HostFile = _PATH_HOSTS;
|
|
|
|
char *PasswdFile = _PATH_PASSWD;
|
|
|
|
char *GroupFile = _PATH_GROUP;
|
|
|
|
char *NetidFile = "/etc/netid";
|
|
|
|
|
1996-08-09 14:14:49 +04:00
|
|
|
int qflag, ch;
|
|
|
|
char *domain;
|
|
|
|
|
|
|
|
TAILQ_INIT(&root);
|
|
|
|
for (ch = 0; ch < HASHMAX; ch++)
|
|
|
|
TAILQ_INIT((&hroot[ch]));
|
|
|
|
|
|
|
|
qflag = 0;
|
|
|
|
domain = NULL;
|
|
|
|
|
|
|
|
while ((ch = getopt(argc, argv, "d:g:h:m:p:q")) != -1) {
|
|
|
|
switch (ch) {
|
|
|
|
case 'd':
|
|
|
|
domain = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'g':
|
|
|
|
GroupFile = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'h':
|
|
|
|
HostFile = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'm':
|
|
|
|
NetidFile = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'p':
|
|
|
|
PasswdFile = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'q':
|
|
|
|
qflag++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
}
|
1997-11-01 17:24:50 +03:00
|
|
|
if (argc != optind)
|
1996-08-09 14:14:49 +04:00
|
|
|
usage();
|
|
|
|
|
|
|
|
if (domain == NULL)
|
|
|
|
if (yp_get_default_domain(&domain))
|
1997-10-07 18:46:48 +04:00
|
|
|
errx(1, "Can't get YP domain name");
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
read_passwd(PasswdFile);
|
|
|
|
read_group(GroupFile);
|
1996-08-09 14:14:49 +04:00
|
|
|
|
|
|
|
print_passwd_group(qflag, domain);
|
1997-11-01 17:24:50 +03:00
|
|
|
print_hosts(HostFile, domain);
|
|
|
|
print_netid(NetidFile);
|
1996-08-09 14:14:49 +04:00
|
|
|
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
hashidx(key)
|
|
|
|
char key;
|
|
|
|
{
|
|
|
|
if (key < 'A')
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
if (key <= 'Z')
|
|
|
|
return(1 + key - 'A');
|
|
|
|
|
|
|
|
if (key < 'a')
|
|
|
|
return(27);
|
|
|
|
|
|
|
|
if (key <= 'z')
|
|
|
|
return(28 + key - 'a');
|
|
|
|
|
|
|
|
return(54);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
add_user(username, uid, gid)
|
1997-11-01 17:24:50 +03:00
|
|
|
const char *username, *uid, *gid;
|
1996-08-09 14:14:49 +04:00
|
|
|
{
|
|
|
|
struct user *u;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
idx = hashidx(username[0]);
|
|
|
|
|
|
|
|
u = (struct user *)malloc(sizeof(struct user));
|
|
|
|
if (u == NULL)
|
|
|
|
err(1, "can't allocate user");
|
|
|
|
memset(u, 0, sizeof(struct user));
|
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
u->usr_name = strdup(username);
|
1996-08-09 14:14:49 +04:00
|
|
|
if (u->usr_name == NULL)
|
|
|
|
err(1, "can't allocate user name");
|
|
|
|
|
|
|
|
u->usr_uid = atoi(uid);
|
|
|
|
u->usr_gid = atoi(gid);
|
|
|
|
u->gid_count = -1;
|
|
|
|
|
|
|
|
TAILQ_INSERT_TAIL(&root, u, read);
|
|
|
|
TAILQ_INSERT_TAIL((&hroot[idx]), u, hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
add_group(username, gid)
|
1997-11-01 17:24:50 +03:00
|
|
|
const char *username, *gid;
|
1996-08-09 14:14:49 +04:00
|
|
|
{
|
|
|
|
struct user *u;
|
|
|
|
int g, idx;
|
|
|
|
|
|
|
|
g = atoi(gid);
|
|
|
|
idx = hashidx(username[0]);
|
|
|
|
|
|
|
|
for (u = hroot[idx].tqh_first;
|
|
|
|
u != NULL; u = u->hash.tqe_next) {
|
|
|
|
if (strcmp(username, u->usr_name) == 0) {
|
|
|
|
if (g != u->usr_gid) {
|
|
|
|
u->gid_count++;
|
|
|
|
if (u->gid_count < NGROUPS)
|
|
|
|
u->gid[u->gid_count] = g;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-11-01 17:24:50 +03:00
|
|
|
read_passwd(fname)
|
|
|
|
const char *fname;
|
1996-08-09 14:14:49 +04:00
|
|
|
{
|
1997-11-01 17:24:50 +03:00
|
|
|
FILE *pfile;
|
1998-06-11 18:50:46 +04:00
|
|
|
size_t line_no;
|
|
|
|
int colon;
|
1997-11-13 21:35:57 +03:00
|
|
|
size_t len;
|
1999-07-25 13:01:04 +04:00
|
|
|
char *line, *p, *k, *u, *g;
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
if ((pfile = fopen(fname, "r")) == NULL)
|
|
|
|
err(1, "%s", fname);
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
line_no = 0;
|
1998-06-08 10:53:47 +04:00
|
|
|
for (;
|
1999-07-25 13:01:04 +04:00
|
|
|
(line = fparseln(pfile, &len, &line_no, NULL, FPARSELN_UNESCALL));
|
|
|
|
free(line)) {
|
1997-11-01 17:24:50 +03:00
|
|
|
if (len == 0) {
|
1998-06-11 18:50:46 +04:00
|
|
|
warnx("%s line %lu: empty line", fname,
|
|
|
|
(unsigned long)line_no);
|
1996-08-09 14:14:49 +04:00
|
|
|
continue;
|
1997-11-01 17:24:50 +03:00
|
|
|
}
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1999-07-25 13:01:04 +04:00
|
|
|
p = line;
|
1996-08-09 14:14:49 +04:00
|
|
|
for (k = p, colon = 0; *k != '\0'; k++)
|
|
|
|
if (*k == ':')
|
|
|
|
colon++;
|
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
if (colon != 6) {
|
1998-06-11 18:50:46 +04:00
|
|
|
warnx("%s line %lu: incorrect number of fields",
|
|
|
|
fname, (unsigned long)line_no);
|
1996-08-09 14:14:49 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
k = p;
|
|
|
|
p = strchr(p, ':');
|
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
/* If it's a YP entry, skip it. */
|
|
|
|
if (*k == '+' || *k == '-')
|
|
|
|
continue;
|
|
|
|
|
1996-08-09 14:14:49 +04:00
|
|
|
/* terminate password */
|
1997-11-01 17:24:50 +03:00
|
|
|
p = strchr(p, ':');
|
1996-08-09 14:14:49 +04:00
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
/* terminate uid */
|
1997-11-01 17:24:50 +03:00
|
|
|
u = p;
|
|
|
|
p = strchr(p, ':');
|
1996-08-09 14:14:49 +04:00
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
/* terminate gid */
|
1997-11-01 17:24:50 +03:00
|
|
|
g = p;
|
|
|
|
p = strchr(p, ':');
|
1996-08-09 14:14:49 +04:00
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
add_user(k, u, g);
|
|
|
|
}
|
1997-11-01 17:24:50 +03:00
|
|
|
(void)fclose(pfile);
|
1996-08-09 14:14:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
isgsep(ch)
|
1997-11-01 17:24:50 +03:00
|
|
|
char ch;
|
1996-08-09 14:14:49 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
switch (ch) {
|
|
|
|
case ',':
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\0':
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-11-01 17:24:50 +03:00
|
|
|
read_group(fname)
|
|
|
|
const char *fname;
|
1996-08-09 14:14:49 +04:00
|
|
|
{
|
1997-11-01 17:24:50 +03:00
|
|
|
FILE *gfile;
|
1998-06-11 18:50:46 +04:00
|
|
|
size_t line_no;
|
|
|
|
int colon;
|
1997-11-13 21:35:57 +03:00
|
|
|
size_t len;
|
1999-07-25 13:01:04 +04:00
|
|
|
char *line, *p, *k, *u, *g;
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
if ((gfile = fopen(fname, "r")) == NULL)
|
|
|
|
err(1, "%s", fname);
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
line_no = 0;
|
1998-06-08 10:53:47 +04:00
|
|
|
for (;
|
1999-07-25 13:01:04 +04:00
|
|
|
(line = fparseln(gfile, &len, &line_no, NULL, FPARSELN_UNESCALL));
|
|
|
|
free(line)) {
|
1997-11-01 17:24:50 +03:00
|
|
|
if (len == 0) {
|
1998-06-11 18:50:46 +04:00
|
|
|
warnx("%s line %lu: empty line", fname,
|
|
|
|
(unsigned long)line_no);
|
1997-11-01 17:24:50 +03:00
|
|
|
continue;
|
|
|
|
}
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1999-07-25 13:01:04 +04:00
|
|
|
p = line;
|
1996-08-09 14:14:49 +04:00
|
|
|
for (k = p, colon = 0; *k != '\0'; k++)
|
|
|
|
if (*k == ':')
|
|
|
|
colon++;
|
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
if (colon != 3) {
|
1998-06-11 18:50:46 +04:00
|
|
|
warnx("%s line %lu: incorrect number of fields",
|
|
|
|
fname, (unsigned long)line_no);
|
1996-08-09 14:14:49 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
/* terminate key */
|
|
|
|
k = p;
|
|
|
|
p = strchr(p, ':');
|
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
if (*k == '+' || *k == '-')
|
|
|
|
continue;
|
|
|
|
|
1996-08-09 14:14:49 +04:00
|
|
|
/* terminate password */
|
1997-11-01 17:24:50 +03:00
|
|
|
p = strchr(p, ':');
|
1996-08-09 14:14:49 +04:00
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
/* terminate gid */
|
1997-11-01 17:24:50 +03:00
|
|
|
g = p;
|
|
|
|
p = strchr(p, ':');
|
1996-08-09 14:14:49 +04:00
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
/* get the group list */
|
|
|
|
for (u = p; *u != '\0'; u = p) {
|
|
|
|
/* find separator */
|
1997-11-01 17:24:50 +03:00
|
|
|
for (; isgsep(*p) == 0; p++)
|
|
|
|
;
|
1996-08-09 14:14:49 +04:00
|
|
|
|
|
|
|
if (*p != '\0') {
|
|
|
|
*p = '\0';
|
|
|
|
if (u != p)
|
|
|
|
add_group(u, g);
|
|
|
|
p++;
|
|
|
|
} else if (u != p)
|
|
|
|
add_group(u, g);
|
|
|
|
}
|
|
|
|
}
|
1997-11-01 17:24:50 +03:00
|
|
|
(void)fclose(gfile);
|
1996-08-09 14:14:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
print_passwd_group(qflag, domain)
|
|
|
|
int qflag;
|
1997-11-01 17:24:50 +03:00
|
|
|
const char *domain;
|
1996-08-09 14:14:49 +04:00
|
|
|
{
|
|
|
|
struct user *u, *p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (u = root.tqh_first; u != NULL; u = u->read.tqe_next) {
|
|
|
|
for (p = root.tqh_first; p->usr_uid != u->usr_uid;
|
|
|
|
p = p->read.tqe_next)
|
|
|
|
/* empty */ ;
|
|
|
|
if (p != u) {
|
|
|
|
if (!qflag) {
|
|
|
|
warnx("unix.%d@%s %s", u->usr_uid, domain,
|
|
|
|
"multiply defined, ignoring duplicate");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("unix.%d@%s %d:%d", u->usr_uid, domain,
|
|
|
|
u->usr_uid, u->usr_gid);
|
|
|
|
if (u->gid_count >= 0)
|
|
|
|
for (i = 0; i <= u->gid_count; i++)
|
|
|
|
printf(",%d", u->gid[i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-11-01 17:24:50 +03:00
|
|
|
print_hosts(fname, domain)
|
|
|
|
const char *fname, *domain;
|
1996-08-09 14:14:49 +04:00
|
|
|
{
|
1997-11-01 17:24:50 +03:00
|
|
|
FILE *hfile;
|
1997-11-13 21:35:57 +03:00
|
|
|
size_t len;
|
1999-07-25 13:01:04 +04:00
|
|
|
char *line, *p, *k, *u;
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
if ((hfile = fopen(fname, "r")) == NULL)
|
|
|
|
err(1, "%s", fname);
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1998-06-08 10:53:47 +04:00
|
|
|
for (;
|
1999-07-25 13:01:04 +04:00
|
|
|
(line = fparseln(hfile, &len, NULL, NULL, FPARSELN_UNESCALL));
|
|
|
|
free(line)) {
|
1998-06-08 10:53:47 +04:00
|
|
|
if (len == 0)
|
1996-08-09 14:14:49 +04:00
|
|
|
continue;
|
|
|
|
|
1999-07-25 13:01:04 +04:00
|
|
|
p = line;
|
1996-08-09 14:14:49 +04:00
|
|
|
/* Find the key, replace trailing whitespace will <NUL> */
|
1997-11-01 17:24:50 +03:00
|
|
|
for (k = p; *p && isspace(*p) == 0; p++)
|
|
|
|
;
|
|
|
|
while (*p && isspace(*p))
|
1996-08-09 14:14:49 +04:00
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
/* Get first hostname. */
|
1997-11-01 17:24:50 +03:00
|
|
|
for (u = p; *p && !isspace(*p); p++)
|
|
|
|
;
|
|
|
|
*p = '\0';
|
1996-08-09 14:14:49 +04:00
|
|
|
|
|
|
|
printf("unix.%s@%s 0:%s\n", u, domain, u);
|
|
|
|
}
|
1997-11-01 17:24:50 +03:00
|
|
|
(void) fclose(hfile);
|
1996-08-09 14:14:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-11-01 17:24:50 +03:00
|
|
|
print_netid(fname)
|
|
|
|
const char *fname;
|
1996-08-09 14:14:49 +04:00
|
|
|
{
|
1997-11-01 17:24:50 +03:00
|
|
|
FILE *mfile;
|
1997-11-13 21:35:57 +03:00
|
|
|
size_t len;
|
1999-07-25 13:01:04 +04:00
|
|
|
char *line, *p, *k, *u;
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1997-11-01 17:24:50 +03:00
|
|
|
mfile = fopen(fname, "r");
|
|
|
|
if (mfile == NULL)
|
|
|
|
return;
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1998-06-08 10:53:47 +04:00
|
|
|
for (;
|
1999-07-25 13:01:04 +04:00
|
|
|
(line = fparseln(mfile, &len, NULL, NULL, FPARSELN_UNESCALL));
|
|
|
|
free(line)) {
|
1998-06-08 10:53:47 +04:00
|
|
|
if (len == 0)
|
1997-11-01 17:24:50 +03:00
|
|
|
continue;
|
1996-08-09 14:14:49 +04:00
|
|
|
|
1999-07-25 13:01:04 +04:00
|
|
|
p = line;
|
1996-08-09 14:14:49 +04:00
|
|
|
/* Find the key, replace trailing whitespace will <NUL> */
|
1997-11-01 17:24:50 +03:00
|
|
|
for (k = p; *p && !isspace(*p); p++)
|
|
|
|
;
|
|
|
|
while (*p && isspace(*p))
|
1996-08-09 14:14:49 +04:00
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
/* Get netid entry. */
|
1997-11-01 17:24:50 +03:00
|
|
|
for (u = p; *p && !isspace(*p); p++)
|
|
|
|
;
|
|
|
|
*p = '\0';
|
1996-08-09 14:14:49 +04:00
|
|
|
|
|
|
|
printf("%s %s\n", k, u);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
|
1997-07-19 01:57:00 +04:00
|
|
|
fprintf(stderr, "usage: %s %s\n", __progname,
|
1996-08-09 14:14:49 +04:00
|
|
|
"[-d domain] [-q] [-p passwdfile] [-g groupfile]");
|
1997-07-19 01:57:00 +04:00
|
|
|
fprintf(stderr, " %s %s", __progname,
|
1996-08-09 14:14:49 +04:00
|
|
|
"[-g groupfile] [-h hostfile] [-m netidfile]");
|
1997-07-19 01:57:00 +04:00
|
|
|
exit(1);
|
1996-08-09 14:14:49 +04:00
|
|
|
}
|