mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
getpass: Don't fail if stdin is not a tty
We don't need to manipulate the tty state (such as turning off echo) when prompting for passwords if we're not reading from a tty. Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> Autobuild-User(master): Alexander Bokovoy <ab@samba.org> Autobuild-Date(master): Fri Apr 5 07:34:37 CEST 2013 on sn-devel-104
This commit is contained in:
parent
7f366d745c
commit
ca0d38596d
@ -170,6 +170,8 @@ int samba_getpass(const char *prompt,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (isatty (STDIN_FILENO)) {
|
||||
|
||||
ZERO_STRUCT(attr);
|
||||
ZERO_STRUCT(old_attr);
|
||||
|
||||
@ -196,6 +198,7 @@ int samba_getpass(const char *prompt,
|
||||
perror("tcsetattr");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* disable nonblocking I/O */
|
||||
if (fd & O_NDELAY) {
|
||||
@ -204,8 +207,11 @@ int samba_getpass(const char *prompt,
|
||||
|
||||
ok = samba_gets(prompt, buf, len, verify);
|
||||
|
||||
if (isatty (STDIN_FILENO)) {
|
||||
|
||||
/* reset terminal */
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &old_attr);
|
||||
}
|
||||
|
||||
/* close fd */
|
||||
if (fd & O_NDELAY) {
|
||||
|
Loading…
Reference in New Issue
Block a user