Skip to content

Commit 468919d

Browse files
committed
New filter: luks
This filter allows you to open, read and write LUKSv1 disk images, compatible with the ones used by dm-crypt and qemu.
1 parent f6d1c74 commit 468919d

File tree

10 files changed

+1669
-4
lines changed

10 files changed

+1669
-4
lines changed

TODO

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ Suggestions for filters
192192
connections. This may even allow a filter to offer a more parallel
193193
threading model than the underlying plugin.
194194

195-
* LUKS encrypt/decrypt filter, bonus points if compatible with qemu
196-
LUKS-encrypted disk images
197-
198195
* CBT filter to track dirty blocks. See these links for inspiration:
199196
https://www.cloudandheat.com/block-level-data-tracking-using-davice-mappers-dm-era/
200197
https://github.com/qemu/qemu/blob/master/docs/interop/bitmaps.rst
@@ -229,6 +226,14 @@ Suggestions for filters
229226
could inject a flush after pausing. However this requires that
230227
filter background threads have access to the plugin (see above).
231228

229+
nbdkit-luks-filter:
230+
231+
* This filter should also support LUKSv2 (and so should qemu).
232+
233+
* There are some missing features: ESSIV, more ciphers.
234+
235+
* Implement trim and zero if possible.
236+
232237
nbdkit-readahead-filter:
233238

234239
* The filter should open a new connection to the plugin per background

configure.ac

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ filters="\
127127
ip \
128128
limit \
129129
log \
130+
luks \
130131
multi-conn \
131132
nocache \
132133
noextents \
@@ -614,8 +615,9 @@ PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0], [
614615
], [
615616
AC_MSG_WARN([gnutls not found or < 3.3.0, TLS support will be disabled.])
616617
])
618+
AM_CONDITIONAL([HAVE_GNUTLS], [test "x$GNUTLS_LIBS" != "x"])
617619

618-
AS_IF([test "$GNUTLS_LIBS" != ""],[
620+
AS_IF([test "x$GNUTLS_LIBS" != "x"],[
619621
AC_MSG_CHECKING([for default TLS session priority string])
620622
AC_ARG_WITH([tls-priority],
621623
[AS_HELP_STRING([--with-tls-priority],
@@ -1379,6 +1381,7 @@ AC_CONFIG_FILES([Makefile
13791381
filters/ip/Makefile
13801382
filters/limit/Makefile
13811383
filters/log/Makefile
1384+
filters/luks/Makefile
13821385
filters/multi-conn/Makefile
13831386
filters/nocache/Makefile
13841387
filters/noextents/Makefile
@@ -1495,6 +1498,8 @@ feature "ext2 ................................... " \
14951498
test "x$HAVE_EXT2_TRUE" = "x"
14961499
feature "gzip ................................... " \
14971500
test "x$HAVE_ZLIB_TRUE" = "x"
1501+
feature "LUKS ................................... " \
1502+
test "x$HAVE_GNUTLS_TRUE" != "x"
14981503
feature "xz ..................................... " \
14991504
test "x$HAVE_LIBLZMA_TRUE" = "x"
15001505

docs/nbdkit-tls.pod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ More information can be found in L<gnutls_priority_init(3)>.
364364
=head1 SEE ALSO
365365

366366
L<nbdkit(1)>,
367+
L<nbdkit-luks-filter(1)>,
367368
L<nbdkit-tls-fallback-filter(1)>,
368369
L<nbdcopy(1)>,
369370
L<nbdfuse(1)>,

filters/luks/Makefile.am

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# nbdkit
2+
# Copyright (C) 2019-2022 Red Hat Inc.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are
6+
# met:
7+
#
8+
# * Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
#
11+
# * Redistributions in binary form must reproduce the above copyright
12+
# notice, this list of conditions and the following disclaimer in the
13+
# documentation and/or other materials provided with the distribution.
14+
#
15+
# * Neither the name of Red Hat nor the names of its contributors may be
16+
# used to endorse or promote products derived from this software without
17+
# specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
20+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
23+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26+
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29+
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30+
# SUCH DAMAGE.
31+
32+
include $(top_srcdir)/common-rules.mk
33+
34+
EXTRA_DIST = nbdkit-luks-filter.pod
35+
36+
if HAVE_GNUTLS
37+
38+
filter_LTLIBRARIES = nbdkit-luks-filter.la
39+
40+
nbdkit_luks_filter_la_SOURCES = \
41+
luks.c \
42+
$(top_srcdir)/include/nbdkit-filter.h \
43+
$(NULL)
44+
45+
nbdkit_luks_filter_la_CPPFLAGS = \
46+
-I$(top_srcdir)/include \
47+
-I$(top_srcdir)/common/include \
48+
-I$(top_srcdir)/common/utils \
49+
$(NULL)
50+
nbdkit_luks_filter_la_CFLAGS = \
51+
$(WARNINGS_CFLAGS) \
52+
$(GNUTLS_CFLAGS) \
53+
$(NULL)
54+
nbdkit_luks_filter_la_LIBADD = \
55+
$(top_builddir)/common/utils/libutils.la \
56+
$(IMPORT_LIBRARY_ON_WINDOWS) \
57+
$(GNUTLS_LIBS) \
58+
$(NULL)
59+
nbdkit_luks_filter_la_LDFLAGS = \
60+
-module -avoid-version -shared $(NO_UNDEFINED_ON_WINDOWS) \
61+
-Wl,--version-script=$(top_srcdir)/filters/filters.syms \
62+
$(NULL)
63+
64+
if HAVE_POD
65+
66+
man_MANS = nbdkit-luks-filter.1
67+
CLEANFILES += $(man_MANS)
68+
69+
nbdkit-luks-filter.1: nbdkit-luks-filter.pod \
70+
$(top_builddir)/podwrapper.pl
71+
$(PODWRAPPER) --section=1 --man $@ \
72+
--html $(top_builddir)/html/$@.html \
73+
$<
74+
75+
endif HAVE_POD
76+
77+
endif

0 commit comments

Comments
 (0)