2 # nbd client library in userspace
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 # Check that TLS to/from NBD servers works. It should be transparent
20 # as far as nbdcopy code is concerned, but using nbdcopy and TLS
21 # together stresses the library in unusual ways.
23 . ..
/tests
/functions.sh
28 requires
test "x$PSKTOOL" != "x"
29 requires nbdkit
--exit-with-parent --version
30 requires bash
-c "nbdkit --dump-config | grep tls=yes"
31 requires
cmp /dev
/null
/dev
/null
32 requires
hexdump -C /dev
/null
35 pidfile1
=copy-tls.pid1
36 pidfile2
=copy-tls.pid2
39 sock1
=$
(mktemp
-u /tmp
/libnbd-test-copy.XXXXXX
)
40 sock2
=$
(mktemp
-u /tmp
/libnbd-test-copy.XXXXXX
)
41 cleanup_fn
rm -f $pskfile $pidfile1 $pidfile2 $file1 $file2 $sock1 $sock2
43 $PSKTOOL -u alice
-p $pskfile
45 nbdkit
--exit-with-parent -f -v -P $pidfile1 -U $sock1 \
46 --tls=require
--tls-psk=$pskfile \
48 uri1
="nbds+unix://alice@/?socket=$sock1&tls-psk-file=$pskfile"
49 # Wait for the pidfile to appear.
51 if test -f $pidfile1; then
56 if ! test -f $pidfile1; then
57 echo "$0: nbdkit did not start up"
61 nbdkit
--exit-with-parent -f -v -P $pidfile2 -U $sock2 \
62 --tls=require
--tls-psk=$pskfile \
64 uri2
="nbds+unix://alice@/?socket=$sock2&tls-psk-file=$pskfile"
65 # Wait for the pidfile to appear.
67 if test -f $pidfile2; then
72 if ! test -f $pidfile2; then
73 echo "$0: nbdkit did not start up"
77 $VG nbdcopy
"$uri1" "$uri2"
79 # Download the file from both servers and check they are the same.
80 $VG nbdcopy
"$uri1" $file1
81 $VG nbdcopy
"$uri2" $file2
86 # Test the data is at least non-zero.
87 test "$(hexdump -C $file1 | head -1)" = "00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 |................|"