summaryrefslogtreecommitdiffstats
path: root/util/oslib-posix.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2015-05-12 17:09:20 +0100
committerKevin Wolf <kwolf@redhat.com>2015-05-22 17:08:01 +0200
commit6a11d5183fb7564a3d32007b46846312fd61a1c5 (patch)
tree315e17c9f472ae9b173d75266adc1216891977c7 /util/oslib-posix.c
parentd57e4e482e3997b1382625c84149ad0b69155fc0 (diff)
downloadhqemu-6a11d5183fb7564a3d32007b46846312fd61a1c5.zip
hqemu-6a11d5183fb7564a3d32007b46846312fd61a1c5.tar.gz
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 <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r--util/oslib-posix.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 1c23fd2..3ae4987 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;
}
OpenPOWER on IntegriCloud