- Add a conf.sh file for executing common functions with geli

-- Use linear probing to find the first unique md(4) device, unlike the other
   code which uses attach_md, as geli(8) allocates the md(4) devices itself
- Don't hardcode /tmp for temporary files, which violates the kyua sandbox

MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
Enji Cooper 2016-01-08 19:38:59 +00:00
parent 873e5b5e14
commit 06908bcb39
21 changed files with 98 additions and 73 deletions

View File

@ -1,10 +1,11 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
echo "1..3"
@ -34,5 +35,4 @@ else
echo "not ok 3"
fi
mdconfig -d -u $no
rm -f $keyfile

View File

@ -0,0 +1,21 @@
#!/bin/sh
# $FreeBSD$
class="eli"
base=`basename $0`
# We need to use linear probing in order to detect the first available md(4)
# device instead of using mdconfig -a -t, because geli(8) attachs md(4) devices
no=0
while [ -c /dev/md$no ]; do
: $(( no += 1 ))
done
geli_test_cleanup()
{
[ -c /dev/md${no}.eli ] && geli detach md${no}.eli
mdconfig -d -u $no
}
trap geli_test_cleanup ABRT EXIT INT TERM
. `dirname $0`/../geom_subr.sh

View File

@ -1,8 +1,9 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
@ -126,5 +127,3 @@ if [ $? -eq 0 ]; then
else
echo "not ok 17"
fi
mdconfig -d -u $no

View File

@ -1,13 +1,14 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile3=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile4=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile1=`mktemp $base.XXXXXX` || exit 1
keyfile2=`mktemp $base.XXXXXX` || exit 1
keyfile3=`mktemp $base.XXXXXX` || exit 1
keyfile4=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
echo "1..14"
@ -136,5 +137,4 @@ else
echo "not ok 14"
fi
mdconfig -d -u $no
rm -f $keyfile1 $keyfile2 $keyfile3 $keyfile4

View File

@ -1,10 +1,11 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
echo "1..4"
@ -40,5 +41,4 @@ else
echo "not ok 4"
fi
mdconfig -d -u $no
rm -f $keyfile

View File

@ -1,11 +1,12 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
backupfile=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
backupfile=`mktemp $base.XXXXXX` || exit 1
echo "1..13"
@ -99,8 +100,5 @@ if [ -c /dev/md${no}.eli ]; then
else
echo "not ok 13 - -B file"
fi
geli detach md${no}
rm -f $backupfile
mdconfig -d -u $no
rm -f $keyfile
rm -f $backupfile $keyfile

View File

@ -1,13 +1,14 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile0=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
passfile0=`mktemp /tmp/$base.XXXXXX` || exit 1
passfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile0=`mktemp $base.XXXXXX` || exit 1
keyfile1=`mktemp $base.XXXXXX` || exit 1
passfile0=`mktemp $base.XXXXXX` || exit 1
passfile1=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
echo "1..150"
@ -122,5 +123,4 @@ for iter in -1 0 64; do
echo "ok ${i}"; i=$((i+1))
done
mdconfig -d -u $no
rm -f ${keyfile0} ${keyfile1} ${passfile0} ${passfile1}

View File

@ -1,10 +1,11 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
echo "1..1380"
@ -26,7 +27,7 @@ for cipher in aes:0 aes:128 aes:256 \
keylen=${cipher##*:}
for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 hmac/sha384 hmac/sha512; do
for secsize in 512 1024 2048 4096 8192; do
rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
rnd=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $secsize \* $sectors + 512`b -u $no || exit 1
dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1

View File

@ -1,10 +1,11 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
echo "1..1"
@ -18,5 +19,4 @@ else
echo "not ok 1"
fi
mdconfig -d -u $no
rm -f $keyfile

View File

@ -1,10 +1,11 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
echo "1..460"
@ -25,7 +26,7 @@ for cipher in aes:0 aes:128 aes:256 \
ealgo=${cipher%%:*}
keylen=${cipher##*:}
for secsize in 512 1024 2048 4096 8192; do
rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
rnd=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $secsize \* $sectors + 512`b -u $no || exit 1
dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1

View File

@ -1,11 +1,12 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
sector=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
sector=`mktemp $base.XXXXXX` || exit 1
echo "1..5520"

View File

@ -1,11 +1,12 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
sector=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
sector=`mktemp $base.XXXXXX` || exit 1
echo "1..2760"

View File

@ -1,11 +1,12 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
sector=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
sector=`mktemp $base.XXXXXX` || exit 1
echo "1..2760"

View File

@ -1,11 +1,12 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile1=`mktemp $base.XXXXXX` || exit 1
keyfile2=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
echo "1..9"
@ -93,5 +94,4 @@ else
echo "not ok 9"
fi
mdconfig -d -u $no
rm -f $keyfile1 $keyfile2

View File

@ -1,10 +1,11 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
echo "1..8"
@ -61,5 +62,4 @@ else
echo "not ok 8"
fi
mdconfig -d -u $no
rm -f $keyfile

View File

@ -1,8 +1,9 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
echo "1..1380"
@ -25,7 +26,7 @@ for cipher in aes:0 aes:128 aes:256 \
keylen=${cipher##*:}
for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 hmac/sha384 hmac/sha512; do
for secsize in 512 1024 2048 4096 8192; do
rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
rnd=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $secsize \* $sectors + 512`b -u $no || exit 1
geli onetime -a $aalgo -e $ealgo -l $keylen -s $secsize md${no} 2>/dev/null

View File

@ -1,8 +1,9 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
mdconfig -a -t malloc -s $sectors -u $no || exit 1

View File

@ -1,8 +1,9 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
echo "1..460"
@ -24,7 +25,7 @@ for cipher in aes:0 aes:128 aes:256 \
ealgo=${cipher%%:*}
keylen=${cipher##*:}
for secsize in 512 1024 2048 4096 8192; do
rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
rnd=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $secsize \* $sectors`b -u $no || exit 1
geli onetime -e $ealgo -l $keylen -s $secsize md${no} 2>/dev/null

View File

@ -1,10 +1,11 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
echo "1..11"

View File

@ -1,7 +1,8 @@
#! /bin/sh
#
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
echo 1..27
BLK=512
@ -22,8 +23,6 @@ setsize() {
# Initialise
kldload geom_eli >/dev/null 2>&1
setsize 10 40 || echo -n "not "
echo ok $i - "Sized ${md}a to 10m"
i=$((i + 1))
@ -145,6 +144,5 @@ echo ok $i - "Attached ${md}p1.eli"
i=$((i + 1))
geli detach ${md}p1.eli
mdconfig -du$unit
rm tmp.*

View File

@ -1,15 +1,16 @@
#!/bin/sh
# $FreeBSD$
. $(dirname $0)/conf.sh
base=`basename $0`
no=45
sectors=100
rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile3=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile4=`mktemp /tmp/$base.XXXXXX` || exit 1
keyfile5=`mktemp /tmp/$base.XXXXXX` || exit 1
rnd=`mktemp $base.XXXXXX` || exit 1
keyfile1=`mktemp $base.XXXXXX` || exit 1
keyfile2=`mktemp $base.XXXXXX` || exit 1
keyfile3=`mktemp $base.XXXXXX` || exit 1
keyfile4=`mktemp $base.XXXXXX` || exit 1
keyfile5=`mktemp $base.XXXXXX` || exit 1
mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
echo "1..16"
@ -152,5 +153,4 @@ else
echo "not ok 16"
fi
mdconfig -d -u $no
rm -f $keyfile1 $keyfile2 $keyfile3 $keyfile4 $keyfile5