From: Daniel P. Berrange Date: Tue, 12 May 2015 16:09:20 +0000 (+0100) Subject: util: allow \n to terminate password input X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=6a11d5183fb7564a3d32007b46846312fd61a1c5;p=qemu.git util: allow \n to terminate password input The qemu_read_password() method looks for \r to terminate the reading of the a password. This is what will be seen when reading the password from a TTY. When scripting though, it is useful to be able to send the password via a pipe, in which case we must look for \n to terminate password input. Signed-off-by: Daniel P. Berrange Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 1c23fd2132..3ae4987b6b 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -467,7 +467,8 @@ int qemu_read_password(char *buf, int buf_size) ret = -1; break; } else { - if (ch == '\r') { + if (ch == '\r' || + ch == '\n') { ret = 0; break; }