summaryrefslogtreecommitdiffstats
path: root/libexec/mknetid/mknetid.c
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2002-11-12 14:15:59 +0000
committermaxim <maxim@FreeBSD.org>2002-11-12 14:15:59 +0000
commitc8298592e9d6646b74179a8469ff9fee118fb642 (patch)
treedccf673bd2e58dcc455c1b78ff183cc0b2bca4ff /libexec/mknetid/mknetid.c
parentf4a7469d8f1d6af1519d7d94b8e9876ed5657e78 (diff)
downloadFreeBSD-src-c8298592e9d6646b74179a8469ff9fee118fb642.zip
FreeBSD-src-c8298592e9d6646b74179a8469ff9fee118fb642.tar.gz
o Fix usage().
o Explicitly initialize domain pointer. o Fix passwd file parsing. PR: bin/39671 (3) MFC after: 2 weeks
Diffstat (limited to 'libexec/mknetid/mknetid.c')
-rw-r--r--libexec/mknetid/mknetid.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/libexec/mknetid/mknetid.c b/libexec/mknetid/mknetid.c
index dd08c5a..6686866 100644
--- a/libexec/mknetid/mknetid.c
+++ b/libexec/mknetid/mknetid.c
@@ -91,7 +91,7 @@ usage(void)
{
fprintf (stderr, "%s\n%s\n",
"usage: mknetid [-q] [-g group_file] [-p passwd_file] [-h hosts_file]",
- " [-d netid_file] [-d domain]");
+ " [-n netid_file] [-d domain]");
exit(1);
}
@@ -111,6 +111,7 @@ main(int argc, char *argv[])
char *ptr, *pidptr, *gidptr, *hptr;
int quiet = 0;
+ domain = NULL;
while ((ch = getopt(argc, argv, "g:p:h:n:d:q")) != -1) {
switch(ch) {
case 'g':
@@ -180,22 +181,36 @@ domain not set");
* group information we just stored if necessary.
*/
while(fgets(readbuf, LINSIZ, pfp)) {
- if ((ptr = strchr(readbuf, ':')) == NULL)
+ /* Ignore comments: ^[ \t]*# */
+ for (ptr = readbuf; *ptr != '\0'; ptr++)
+ if (*ptr != ' ' && *ptr != '\t')
+ break;
+ if (*ptr == '#' || *ptr == '\0')
+ continue;
+ if ((ptr = strchr(readbuf, ':')) == NULL) {
warnx("bad passwd file entry: %s", readbuf);
+ continue;
+ }
*ptr = '\0';
ptr++;
- if ((ptr = strchr(ptr, ':')) == NULL)
+ if ((ptr = strchr(ptr, ':')) == NULL) {
warnx("bad passwd file entry: %s", readbuf);
+ continue;
+ }
*ptr = '\0';
ptr++;
pidptr = ptr;
- if ((ptr = strchr(ptr, ':')) == NULL)
+ if ((ptr = strchr(ptr, ':')) == NULL) {
warnx("bad passwd file entry: %s", readbuf);
+ continue;
+ }
*ptr = '\0';
ptr++;
gidptr = ptr;
- if ((ptr = strchr(ptr, ':')) == NULL)
+ if ((ptr = strchr(ptr, ':')) == NULL) {
warnx("bad passwd file entry: %s", readbuf);
+ continue;
+ }
*ptr = '\0';
i = atol(gidptr);
OpenPOWER on IntegriCloud