summaryrefslogtreecommitdiffstats
path: root/sys-utils/losetup.c
diff options
context:
space:
mode:
authorKarel Zak2012-01-11 15:17:06 +0100
committerKarel Zak2012-01-11 15:17:06 +0100
commit6c503d5916efe6549bb8428931547735c2c54fa4 (patch)
treec37ffd65cc26190dd1f437f907dc2aac7057355c /sys-utils/losetup.c
parentbuild-sys: move swapon from mount/ to sys-utils/ (diff)
downloadkernel-qcow2-util-linux-6c503d5916efe6549bb8428931547735c2c54fa4.tar.gz
kernel-qcow2-util-linux-6c503d5916efe6549bb8428931547735c2c54fa4.tar.xz
kernel-qcow2-util-linux-6c503d5916efe6549bb8428931547735c2c54fa4.zip
losetup: move xgetpass() to lib/xgetpass.c
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/losetup.c')
-rw-r--r--sys-utils/losetup.c40
1 files changed, 1 insertions, 39 deletions
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index 7e80ee513..895363b35 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -18,6 +18,7 @@
#include "nls.h"
#include "strutils.h"
#include "loopdev.h"
+#include "xgetpass.h"
enum {
A_CREATE = 1, /* setup a new device */
@@ -31,45 +32,6 @@ enum {
static int verbose;
-/*
- * A function to read the passphrase either from the terminal or from
- * an open file descriptor.
- */
-static char *xgetpass(int pfd, const char *prompt)
-{
- char *pass;
- int buflen, i;
-
- if (pfd < 0) /* terminal */
- return getpass(prompt);
-
- pass = NULL;
- buflen = 0;
- for (i=0; ; i++) {
- if (i >= buflen-1) {
- /* we're running out of space in the buffer.
- * Make it bigger: */
- char *tmppass = pass;
- buflen += 128;
- pass = realloc(tmppass, buflen);
- if (pass == NULL) {
- /* realloc failed. Stop reading. */
- warn(_("Out of memory while reading passphrase"));
- pass = tmppass; /* the old buffer hasn't changed */
- break;
- }
- }
- if (read(pfd, pass+i, 1) != 1 ||
- pass[i] == '\n' || pass[i] == 0)
- break;
- }
-
- if (pass == NULL)
- return "";
-
- pass[i] = 0;
- return pass;
-}
static int printf_loopdev(struct loopdev_cxt *lc)
{