util: allow \n to terminate password input
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 12 May 2015 16:09:20 +0000 (17:09 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 22 May 2015 15:08:01 +0000 (17:08 +0200)
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 <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
util/oslib-posix.c

index 1c23fd2132cde0835917d70e1353a915d6f4b9e9..3ae4987b6bf9a9a3c38ed7754dc0c3a9fda1a050 100644 (file)
@@ -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;
             }