pw: Fix terminal handling when setting a group password.
Reported by: Coverity MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc.
This commit is contained in:
parent
e352957180
commit
79c8ad8368
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=365043
@ -66,14 +66,19 @@ grp_set_passwd(struct group *grp, bool update, int fd, bool precrypted)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((istty = isatty(fd))) {
|
if ((istty = isatty(fd))) {
|
||||||
|
if (tcgetattr(fd, &t) == -1)
|
||||||
|
istty = 0;
|
||||||
|
else {
|
||||||
n = t;
|
n = t;
|
||||||
/* Disable echo */
|
/* Disable echo */
|
||||||
n.c_lflag &= ~(ECHO);
|
n.c_lflag &= ~(ECHO);
|
||||||
tcsetattr(fd, TCSANOW, &n);
|
tcsetattr(fd, TCSANOW, &n);
|
||||||
printf("%sassword for group %s:", update ? "New p" : "P",
|
printf("%sassword for group %s:",
|
||||||
|
update ? "New p" : "P",
|
||||||
grp->gr_name);
|
grp->gr_name);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
b = read(fd, line, sizeof(line) - 1);
|
b = read(fd, line, sizeof(line) - 1);
|
||||||
if (istty) { /* Restore state */
|
if (istty) { /* Restore state */
|
||||||
tcsetattr(fd, TCSANOW, &t);
|
tcsetattr(fd, TCSANOW, &t);
|
||||||
|
Loading…
Reference in New Issue
Block a user