blob: 11c1300f068e20daf0991fa555e987a46f3cbf04 (
plain) (
blame)
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
|
From bedf249e829f34d51cc8c4e4eef864b9b6163450 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 29 May 2019 13:19:24 +0200
Subject: [PATCH] nlplug-findfs: fix when cryptheader is a regular file
Handle case when the crypt header is a normal file which is included in
initramfs and not a blockdevice.
---
nlplug-findfs.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/nlplug-findfs.c b/nlplug-findfs.c
index 0283161..9f15de5 100644
--- a/nlplug-findfs.c
+++ b/nlplug-findfs.c
@@ -1213,6 +1213,13 @@ static void usage(int rc)
exit(rc);
}
+static int regular_file(const char *path)
+{
+ struct stat st;
+ int r = stat(path, &st);
+ return r == -1 ? 0 : S_ISREG(st.st_mode);
+}
+
int main(int argc, char *argv[])
{
struct pollfd fds[3];
@@ -1262,6 +1269,12 @@ int main(int argc, char *argv[])
break;
case 'H':
conf.crypt.header.device = EARGF(usage(1));
+ /* the header may be in a regular file and not a device */
+ if (regular_file(conf.crypt.header.device)) {
+ snprintf(conf.crypt.header.devnode,
+ sizeof(conf.crypt.header.devnode),
+ "%s", conf.crypt.header.device);
+ }
break;
case 'h':
usage(0);
--
2.21.0
|