From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvoqw-0004xy-Kj for qemu-devel@nongnu.org; Fri, 22 May 2015 11:27:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yvoqs-0006zg-Jd for qemu-devel@nongnu.org; Fri, 22 May 2015 11:27:14 -0400 From: Kevin Wolf Date: Fri, 22 May 2015 17:26:36 +0200 Message-Id: <1432308400-13958-19-git-send-email-kwolf@redhat.com> In-Reply-To: <1432308400-13958-1-git-send-email-kwolf@redhat.com> References: <1432308400-13958-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 18/22] util: allow \n to terminate password input List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: "Daniel P. Berrange" 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 --- util/oslib-posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- 1.8.3.1