qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Subject: [Qemu-devel] [PATCH 3/5] util: allow \n to terminate password input
Date: Tue, 12 May 2015 17:09:20 +0100	[thread overview]
Message-ID: <1431446962-9860-4-git-send-email-berrange@redhat.com> (raw)
In-Reply-To: <1431446962-9860-1-git-send-email-berrange@redhat.com>

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>
---
 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;
             }
-- 
2.1.0

  parent reply	other threads:[~2015-05-12 16:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 16:09 [Qemu-devel] [PATCH 0/5] Misc fixes and testing of qcow[2] encryption Daniel P. Berrange
2015-05-12 16:09 ` [Qemu-devel] [PATCH 1/5] qcow2/qcow: protect against uninitialized encryption key Daniel P. Berrange
2015-05-12 18:06   ` Eric Blake
2015-05-12 16:09 ` [Qemu-devel] [PATCH 2/5] util: move read_password method out of qemu-img into osdep/oslib Daniel P. Berrange
2015-05-12 18:22   ` Eric Blake
2015-05-12 16:09 ` Daniel P. Berrange [this message]
2015-05-12 18:23   ` [Qemu-devel] [PATCH 3/5] util: allow \n to terminate password input Eric Blake
2015-05-12 16:09 ` [Qemu-devel] [PATCH 4/5] qemu-io: prompt for encryption keys when required Daniel P. Berrange
2015-05-12 18:32   ` Eric Blake
2015-05-13  8:09     ` Daniel P. Berrange
2015-05-13 10:50       ` Markus Armbruster
2015-05-12 16:09 ` [Qemu-devel] [PATCH 5/5] tests: add test case for encrypted qcow2 read/write Daniel P. Berrange
2015-05-12 18:35   ` Eric Blake
2015-05-12 19:06     ` [Qemu-devel] [Qemu-block] " John Snow
2015-05-12 19:52       ` Eric Blake
2015-05-12 19:54         ` John Snow
2015-05-18 15:38 ` [Qemu-devel] [PATCH 0/5] Misc fixes and testing of qcow[2] encryption Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431446962-9860-4-git-send-email-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).