o Fix usage().
o Explicitly initialize domain pointer. o Fix passwd file parsing. PR: bin/39671 (3) MFC after: 2 weeks
This commit is contained in:
parent
f90ce7b125
commit
e1b57f44ef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106811
@ -91,7 +91,7 @@ usage(void)
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "%s\n%s\n",
|
fprintf (stderr, "%s\n%s\n",
|
||||||
"usage: mknetid [-q] [-g group_file] [-p passwd_file] [-h hosts_file]",
|
"usage: mknetid [-q] [-g group_file] [-p passwd_file] [-h hosts_file]",
|
||||||
" [-d netid_file] [-d domain]");
|
" [-n netid_file] [-d domain]");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +111,7 @@ main(int argc, char *argv[])
|
|||||||
char *ptr, *pidptr, *gidptr, *hptr;
|
char *ptr, *pidptr, *gidptr, *hptr;
|
||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
|
|
||||||
|
domain = NULL;
|
||||||
while ((ch = getopt(argc, argv, "g:p:h:n:d:q")) != -1) {
|
while ((ch = getopt(argc, argv, "g:p:h:n:d:q")) != -1) {
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'g':
|
case 'g':
|
||||||
@ -180,22 +181,36 @@ domain not set");
|
|||||||
* group information we just stored if necessary.
|
* group information we just stored if necessary.
|
||||||
*/
|
*/
|
||||||
while(fgets(readbuf, LINSIZ, pfp)) {
|
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);
|
warnx("bad passwd file entry: %s", readbuf);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
ptr++;
|
ptr++;
|
||||||
if ((ptr = strchr(ptr, ':')) == NULL)
|
if ((ptr = strchr(ptr, ':')) == NULL) {
|
||||||
warnx("bad passwd file entry: %s", readbuf);
|
warnx("bad passwd file entry: %s", readbuf);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
ptr++;
|
ptr++;
|
||||||
pidptr = ptr;
|
pidptr = ptr;
|
||||||
if ((ptr = strchr(ptr, ':')) == NULL)
|
if ((ptr = strchr(ptr, ':')) == NULL) {
|
||||||
warnx("bad passwd file entry: %s", readbuf);
|
warnx("bad passwd file entry: %s", readbuf);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
ptr++;
|
ptr++;
|
||||||
gidptr = ptr;
|
gidptr = ptr;
|
||||||
if ((ptr = strchr(ptr, ':')) == NULL)
|
if ((ptr = strchr(ptr, ':')) == NULL) {
|
||||||
warnx("bad passwd file entry: %s", readbuf);
|
warnx("bad passwd file entry: %s", readbuf);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
i = atol(gidptr);
|
i = atol(gidptr);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user