1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
--- ./mount/mount.c.orig 2012-05-25 04:44:58.993195438 -0500
+++ ./mount/mount.c 2012-08-02 12:04:52.455435631 -0500
@@ -41,6 +41,7 @@
#include "nls.h"
#include "blkdev.h"
#include "strutils.h"
+#include "xgetpass.h"
#define DO_PS_FIDDLING
@@ -1238,6 +1239,8 @@
int looptype;
uintmax_t offset = 0, sizelimit = 0;
struct loopdev_cxt lc;
+ char *pwd = NULL;
+ int ret = EX_FAIL;
/*
* In the case of a loop mount, either type is of the form lo@/dev/loop5
@@ -1317,8 +1320,18 @@
return EX_FAIL;
}
+ if (opt_encryption) {
+#ifdef MCL_FUTURE
+ if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
+ error(_("mount: couldn't lock into memory"));
+ return EX_FAIL;
+ }
+#endif
+ pwd = xgetpass(pfd, _("Password: "));
+ }
+
loopcxt_init(&lc, 0);
- /* loopcxt_enable_debug(&lc, 1); */
+ /*loopcxt_enable_debug(&lc, 1);*/
if (*loopdev && **loopdev)
loopcxt_set_device(&lc, *loopdev); /* use loop=<devname> */
@@ -1343,6 +1356,8 @@
rc = loopcxt_set_offset(&lc, offset);
if (!rc && sizelimit)
rc = loopcxt_set_sizelimit(&lc, sizelimit);
+ if (!rc && opt_encryption && pwd)
+ loopcxt_set_encryption(&lc, opt_encryption, pwd);
if (!rc)
loopcxt_set_flags(&lc, loop_opts);
@@ -1358,8 +1373,7 @@
break; /* success */
if (rc != -EBUSY) {
- if (verbose)
- printf(_("mount: failed setting up loop device\n"));
+ error(_("mount: %s: failed setting up loop device: %m"), *loopfile);
if (!opt_loopdev) {
my_free(*loopdev);
*loopdev = NULL;
@@ -1399,9 +1413,15 @@
}
}
- return 0;
+ ret = 0;
err:
- return EX_FAIL;
+ if (pwd) {
+ char *p = pwd;
+ while (*p)
+ *p++ = '\0';
+ free(pwd);
+ }
+ return ret;
}
--- ./mount/Makefile.am.orig 2012-05-25 04:44:58.000000000 -0500
+++ ./mount/Makefile.am 2012-08-02 12:04:14.958439138 -0500
@@ -23,7 +23,8 @@
$(top_srcdir)/lib/at.c \
$(top_srcdir)/lib/sysfs.c \
$(top_srcdir)/lib/loopdev.c \
- $(top_srcdir)/lib/strutils.c
+ $(top_srcdir)/lib/strutils.c \
+ $(top_srcdir)/lib/xgetpass.c
# generic flags for all programs
# -- note that pkg-config autoconf macros (pkg.m4) does not differentiate
|