Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/volume_key/, dev-libs/volume_key/files/
Date: Wed, 18 Oct 2017 06:48:29
Message-Id: 1508309304.ee41609064da9c7f94945327af2902f815efdc9a.polynomial-c@gentoo
1 commit: ee41609064da9c7f94945327af2902f815efdc9a
2 Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
3 AuthorDate: Wed Oct 18 06:48:16 2017 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Wed Oct 18 06:48:24 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ee416090
7
8 dev-libs/volume_key: Added a patch for cryptsetup-2
9
10 Package-Manager: Portage-2.3.11, Repoman-2.3.3
11
12 .../files/volume_key-0.3.9-cryptsetup2.patch | 68 ++++++++++++++++++++++
13 dev-libs/volume_key/volume_key-0.3.9.ebuild | 3 +
14 2 files changed, 71 insertions(+)
15
16 diff --git a/dev-libs/volume_key/files/volume_key-0.3.9-cryptsetup2.patch b/dev-libs/volume_key/files/volume_key-0.3.9-cryptsetup2.patch
17 new file mode 100644
18 index 00000000000..c0386fabf72
19 --- /dev/null
20 +++ b/dev-libs/volume_key/files/volume_key-0.3.9-cryptsetup2.patch
21 @@ -0,0 +1,68 @@
22 +From a41c53d35b594a7fd8d5b92501b4fe52d7252909 Mon Sep 17 00:00:00 2001
23 +From: Milan Broz <gmazyland@×××××.com>
24 +Date: Tue, 17 Oct 2017 13:44:24 +0200
25 +Subject: [PATCH] volume_key: Switch to libcryptsetup error callback.
26 +
27 +This change should be compatible with new libcryptsetup as well.
28 +
29 +Note that now is error set even for retry, so the code must
30 +clear it after successfull (but retried) password query.
31 +
32 +Signed-off-by: Milan Broz <gmazyland@×××××.com>
33 +---
34 + lib/volume_luks.c | 21 ++++++++++++++-------
35 + 1 file changed, 14 insertions(+), 7 deletions(-)
36 +
37 +diff --git a/lib/volume_luks.c b/lib/volume_luks.c
38 +index 14794d7..4034cc3 100644
39 +--- a/lib/volume_luks.c
40 ++++ b/lib/volume_luks.c
41 +@@ -65,13 +65,8 @@ my_strerror (int err_no)
42 + static void
43 + error_from_cryptsetup (GError **error, LIBVKError code, int res)
44 + {
45 +- /* It's not possible to get the error message length from libcryptsetup, just
46 +- guess. */
47 +- char crypt_msg[4096];
48 +-
49 +- crypt_get_error (crypt_msg, sizeof (crypt_msg));
50 +- if (crypt_msg[0] != '\0')
51 +- g_set_error (error, LIBVK_ERROR, code, "%s", crypt_msg);
52 ++ if (error && *error && (*error)->message)
53 ++ (*error)->code = code;
54 + else
55 + {
56 + char *s;
57 +@@ -82,6 +77,16 @@ error_from_cryptsetup (GError **error, LIBVKError code, int res)
58 + }
59 + }
60 +
61 ++void cryptsetup_log (int level, const char *msg, void *usrptr)
62 ++{
63 ++ GError **error = usrptr;
64 ++
65 ++ if (level != CRYPT_LOG_ERROR)
66 ++ return;
67 ++ g_clear_error(error);
68 ++ g_set_error (error, LIBVK_ERROR, -1, "%s", msg);
69 ++}
70 ++
71 + /* Open volume PATH and load its header.
72 + Return the volume, or NULL on error. */
73 + static struct crypt_device *
74 +@@ -93,6 +98,7 @@ open_crypt_device (const char *path, GError **error)
75 + r = crypt_init (&cd, path);
76 + if (r < 0)
77 + goto err;
78 ++ crypt_set_log_callback(cd, cryptsetup_log, error);
79 + r = crypt_load (cd, CRYPT_LUKS1, NULL);
80 + if (r < 0)
81 + goto err_cd;
82 +@@ -307,6 +313,7 @@ luks_get_secret (struct libvk_volume *vol, enum libvk_secret secret_type,
83 + g_prefix_error (error, _("Error getting LUKS data encryption key: "));
84 + goto err_prompt;
85 + }
86 ++ g_clear_error(error);
87 + }
88 + g_set_error (error, LIBVK_ERROR, LIBVK_ERROR_FAILED,
89 + _("Too many attempts to get a valid passphrase"));
90
91 diff --git a/dev-libs/volume_key/volume_key-0.3.9.ebuild b/dev-libs/volume_key/volume_key-0.3.9.ebuild
92 index 6edf1dda06a..05ac55ccf1e 100644
93 --- a/dev-libs/volume_key/volume_key-0.3.9.ebuild
94 +++ b/dev-libs/volume_key/volume_key-0.3.9.ebuild
95 @@ -37,6 +37,9 @@ RESTRICT="test" # possible gpgme issue
96 PATCHES=(
97 "${FILESDIR}"/${P}-config.h.diff
98 "${FILESDIR}"/${PN}-0.3.9-find_python.patch
99 +
100 + # Patches from upstream (can usually be removed with next version bump)
101 + "${FILESDIR}/${P}-cryptsetup2.patch"
102 )
103
104 pkg_setup() {