Advertisement
Guest User

Untitled

a guest
Jun 8th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 48.57 KB | None | 0 0
  1. --- tools/regression/geom_eli/attach-d-H.t.orig 2013-06-02 19:42:49.990933533 +0300
  2. +++ tools/regression/geom_eli/attach-d-H.t  2013-06-02 15:00:57.014966277 +0300
  3. @@ -0,0 +1,43 @@
  4. +#!/bin/sh
  5. +
  6. +base=`basename $0`
  7. +no=45
  8. +sectors=100
  9. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  10. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  11. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  12. +
  13. +echo 1..3
  14. +
  15. +i=1
  16. +
  17. +dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  18. +
  19. +geli init -B none -H $hd -P -K $keyfile md${no}
  20. +geli attach -d -H $hd -p -k $keyfile md${no}
  21. +
  22. +if [ -c /dev/md${no}.eli ]; then
  23. +   echo "ok $i"
  24. +else
  25. +   echo "not ok $i"
  26. +fi
  27. +i=$((i + 1))
  28. +
  29. +dd if=/dev/md${no}.eli of=/dev/null 2>/dev/null
  30. +sleep 1
  31. +if [ -c /dev/md${no}.eli ]; then
  32. +   echo "ok $i"
  33. +else
  34. +   echo "not ok $i"
  35. +fi
  36. +i=$((i + 1))
  37. +true > /dev/md${no}.eli
  38. +sleep 1
  39. +if [ ! -c /dev/md${no}.eli ]; then
  40. +   echo "ok $i"
  41. +else
  42. +   echo "not ok $i"
  43. +fi
  44. +
  45. +mdconfig -d -u $no
  46. +rm -f $keyfile $hd
  47. --- tools/regression/geom_eli/configure-b-B-H.t.orig    2013-06-02 19:42:58.969753606 +0300
  48. +++ tools/regression/geom_eli/configure-b-B-H.t 2013-06-02 15:01:02.820704156 +0300
  49. @@ -0,0 +1,65 @@
  50. +#!/bin/sh
  51. +
  52. +base=`basename $0`
  53. +no=45
  54. +sectors=100
  55. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  56. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  57. +
  58. +echo 1..17
  59. +
  60. +i=1
  61. +
  62. +geli init -H $hd -B none -P -K /dev/null md${no} || echo -n "not "
  63. +echo ok $i; i=$((i + 1))
  64. +
  65. +geli dump -H $hd md${no} | egrep 'flags: 0x0$' >/dev/null || echo -n "not "
  66. +echo ok $i; i=$((i + 1))
  67. +
  68. +geli init -B none -H $hd -b -P -K /dev/null md${no} || echo -n "not "
  69. +echo ok $i; i=$((i + 1))
  70. +
  71. +geli dump -H $hd md${no} | egrep 'flags: 0x2$' >/dev/null || echo -n "not "
  72. +echo ok $i; i=$((i + 1))
  73. +
  74. +geli configure -B -H $hd md${no} || echo -n "not "
  75. +echo ok $i; i=$((i + 1))
  76. +
  77. +geli dump -H $hd md${no} | egrep 'flags: 0x0$' >/dev/null || echo -n "not "
  78. +echo ok $i; i=$((i + 1))
  79. +
  80. +geli configure -b -H $hd md${no} || echo -n "not "
  81. +echo ok $i; i=$((i + 1))
  82. +
  83. +geli dump -H $hd md${no} | egrep 'flags: 0x2$' >/dev/null || echo -n "not "
  84. +echo ok $i; i=$((i + 1))
  85. +
  86. +geli attach -H $hd -p -k /dev/null md${no} || echo -n "not "
  87. +echo ok $i; i=$((i + 1))
  88. +
  89. +geli list md${no}.eli | egrep '^Flags: .*BOOT' >/dev/null || echo -n "not "
  90. +echo ok $i; i=$((i + 1))
  91. +
  92. +geli configure -B -H $hd md${no} || echo -n "not "
  93. +echo ok $i; i=$((i + 1))
  94. +
  95. +geli list md${no}.eli | egrep '^Flags: .*BOOT' >/dev/null && echo -n "not "
  96. +echo ok $i; i=$((i + 1))
  97. +
  98. +geli dump -H $hd md${no} | egrep 'flags: 0x0$' >/dev/null || echo -n "not "
  99. +echo ok $i; i=$((i + 1))
  100. +
  101. +geli configure -b -H $hd md${no} || echo -n "not "
  102. +echo ok $i; i=$((i + 1))
  103. +
  104. +geli list md${no}.eli | egrep '^Flags: .*BOOT' >/dev/null || echo -n "not "
  105. +echo ok $i; i=$((i + 1))
  106. +
  107. +geli dump -H $hd md${no} | egrep 'flags: 0x2$' >/dev/null || echo -n "not "
  108. +echo ok $i; i=$((i + 1))
  109. +
  110. +geli detach md${no} || echo -n "not "
  111. +echo ok $i; i=$((i + 1))
  112. +
  113. +mdconfig -d -u $no
  114. +rm -f $hd
  115. --- tools/regression/geom_eli/delkey-H.t.orig   2013-06-02 19:43:06.736921082 +0300
  116. +++ tools/regression/geom_eli/delkey-H.t    2013-06-02 15:01:08.811465551 +0300
  117. @@ -0,0 +1,99 @@
  118. +#!/bin/sh
  119. +
  120. +base=`basename $0`
  121. +no=45
  122. +sectors=100
  123. +keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
  124. +keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
  125. +keyfile3=`mktemp /tmp/$base.XXXXXX` || exit 1
  126. +keyfile4=`mktemp /tmp/$base.XXXXXX` || exit 1
  127. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  128. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  129. +
  130. +echo 1..14
  131. +
  132. +i=1
  133. +
  134. +dd if=/dev/random of=${keyfile1} bs=512 count=16 >/dev/null 2>&1
  135. +dd if=/dev/random of=${keyfile2} bs=512 count=16 >/dev/null 2>&1
  136. +dd if=/dev/random of=${keyfile3} bs=512 count=16 >/dev/null 2>&1
  137. +dd if=/dev/random of=${keyfile4} bs=512 count=16 >/dev/null 2>&1
  138. +
  139. +geli init -B none -H $hd -P -K $keyfile1 md${no}
  140. +geli attach -H $hd -p -k $keyfile1 md${no}
  141. +geli setkey -H $hd -n 1 -P -K $keyfile2 md${no} 1>/dev/null
  142. +
  143. +# Remove key 0 for attached provider.
  144. +geli delkey -H $hd -n 0 md${no} || echo -n "not "
  145. +echo ok $i - "Remove key 0 for attached provider"
  146. +geli detach md${no}
  147. +i=$((i + 1))
  148. +
  149. +# We cannot use keyfile1 anymore.
  150. +geli attach -H $hd -p -k $keyfile1 md${no} 2>/dev/null && echo -n "not "
  151. +echo ok $i - "We cannot use keyfile anymore"
  152. +i=$((i + 1))
  153. +
  154. +# Attach with key 1.
  155. +geli attach -H $hd -p -k $keyfile2 md${no} || echo -n "not "
  156. +echo ok $i - "Attach with key 1"
  157. +i=$((i + 1))
  158. +
  159. +# We cannot remove last key without -f option (for attached provider).
  160. +geli delkey -H $hd -n 1 md${no} 2>/dev/null && echo -n "not "
  161. +echo ok $i - "We cannot remove last key without -f option (for attached provider)"
  162. +i=$((i + 1))
  163. +
  164. +# Remove last key for attached provider.
  165. +geli delkey -H $hd -f -n 1 md${no} || echo -n "not "
  166. +echo ok $i - "Remove last key for attached provider"
  167. +i=$((i + 1))
  168. +
  169. +# If there are no valid keys, but provider is attached, we can save situation.
  170. +geli setkey -H $hd -n 0 -P -K $keyfile3 md${no} 1>/dev/null || echo -n "not "
  171. +echo ok $i - "If there are no valid keys, but provider is attached, we can save situation"
  172. +geli detach md${no}
  173. +i=$((i + 1))
  174. +
  175. +# We cannot use keyfile2 anymore.
  176. +geli attach -H $hd -p -k $keyfile2 md${no} 2>/dev/null && echo -n "not "
  177. +echo ok $i - "We cannot use keyfile2 anymore"
  178. +i=$((i + 1))
  179. +
  180. +# Attach with key 0.
  181. +geli attach -H $hd -p -k $keyfile3 md${no} || echo -n "not "
  182. +echo ok $i - "Attach with key 0"
  183. +i=$((i + 1))
  184. +
  185. +# Setup key 1.
  186. +geli setkey -H $hd -n 1 -P -K $keyfile4 md${no} 1>/dev/null || echo -n "not "
  187. +echo ok $i - "Setup key 1"
  188. +geli detach md${no}
  189. +i=$((i + 1))
  190. +
  191. +# Remove key 1 for detached provider.
  192. +geli delkey -H $hd -n 1 md${no} || echo -n "not "
  193. +echo ok $i - "Remove key 1 for detached provider"
  194. +i=$((i + 1))
  195. +
  196. +# We cannot use keyfile4 anymore.
  197. +geli attach -H $hd -p -k $keyfile4 md${no} 2>/dev/null && echo -n "not "
  198. +echo ok $i - "We cannot use keyfile4 anymore"
  199. +i=$((i + 1))
  200. +
  201. +# We cannot remove last key without -f option (for detached provider).
  202. +geli delkey -H $hd -n 0 md${no} 2>/dev/null && echo -n "not "
  203. +echo ok $i - "We cannot remove last key without -f option (for detached provider)"
  204. +i=$((i + 1))
  205. +
  206. +# Remove last key for detached provider.
  207. +geli delkey -H $hd -f -n 0 md${no} || echo -n "not "
  208. +echo ok $i - "Remove last key for detached provider"
  209. +i=$((i + 1))
  210. +
  211. +# We cannot use keyfile3 anymore.
  212. +geli attach -H $hd -p -k $keyfile3 md${no} 2>/dev/null && echo -n "not "
  213. +echo ok $i - "We cannot use keyfile3 anymore"
  214. +
  215. +mdconfig -d -u $no
  216. +rm -f $keyfile1 $keyfile2 $keyfile3 $keyfile4 $hd
  217. --- tools/regression/geom_eli/detach-l-H.t.orig 2013-06-02 19:43:20.795044949 +0300
  218. +++ tools/regression/geom_eli/detach-l-H.t  2013-06-02 15:01:14.852233302 +0300
  219. @@ -0,0 +1,52 @@
  220. +#!/bin/sh
  221. +
  222. +base=`basename $0`
  223. +no=45
  224. +sectors=100
  225. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  226. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  227. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  228. +
  229. +echo 1..4
  230. +
  231. +i=1
  232. +
  233. +dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  234. +
  235. +geli init -B none -H $hd -P -K $keyfile md${no}
  236. +geli attach -H $hd -p -k $keyfile md${no}
  237. +if [ -c /dev/md${no}.eli ]; then
  238. +   echo "ok $i"
  239. +else
  240. +   echo "not ok $i"
  241. +fi
  242. +i=$((i + 1))
  243. +
  244. +dd if=/dev/md${no}.eli of=/dev/null 2>/dev/null
  245. +sleep 1
  246. +if [ -c /dev/md${no}.eli ]; then
  247. +   echo "ok $i"
  248. +else
  249. +   echo "not ok $i"
  250. +fi
  251. +i=$((i + 1))
  252. +
  253. +geli detach -l md${no}
  254. +if [ -c /dev/md${no}.eli ]; then
  255. +   echo "ok $i"
  256. +else
  257. +   echo "not ok $i"
  258. +fi
  259. +i=$((i + 1))
  260. +
  261. +dd if=/dev/md${no}.eli of=/dev/null 2>/dev/null
  262. +sleep 1
  263. +if [ ! -c /dev/md${no}.eli ]; then
  264. +   echo "ok $i"
  265. +else
  266. +   echo "not ok $i"
  267. +fi
  268. +i=$((i + 1))
  269. +
  270. +mdconfig -d -u $no
  271. +rm -f $keyfile $hd
  272. --- tools/regression/geom_eli/init-B-H.t.orig   2013-06-02 19:43:28.315191155 +0300
  273. +++ tools/regression/geom_eli/init-B-H.t    2013-06-02 15:06:22.584344471 +0300
  274. @@ -0,0 +1,125 @@
  275. +#!/bin/sh
  276. +
  277. +base=`basename $0`
  278. +no=45
  279. +sectors=100
  280. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  281. +backupfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  282. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  283. +mdconfig -a -t malloc -s $sectors -u $no || exit 1
  284. +
  285. +echo 1..13
  286. +
  287. +i=1
  288. +
  289. +dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  290. +
  291. +rm -f /var/backups/md${no}.eli
  292. +geli init -B none -H $hd -P -K $keyfile md${no} 2>/dev/null
  293. +if [ ! -f /var/backups/md${no}.eli ]; then
  294. +   echo "ok $i - -B none"
  295. +else
  296. +   echo "not ok $i - -B none"
  297. +fi
  298. +i=$((i + 1))
  299. +
  300. +rm -f /var/backups/md${no}.eli
  301. +geli init -H $hd -P -K $keyfile md${no} >/dev/null 2>&1
  302. +if [ -f /var/backups/md${no}.eli ]; then
  303. +   echo "ok $i - no -B"
  304. +else
  305. +   echo "not ok $i - no -B"
  306. +fi
  307. +i=$((i + 1))
  308. +
  309. +geli attach -p -k $keyfile md${no} 2>/dev/null
  310. +if [ $? -ne 0 ]; then
  311. +   echo "ok $i - no -B"
  312. +else
  313. +   echo "not ok $i - no -B"
  314. +fi
  315. +i=$((i + 1))
  316. +
  317. +if [ ! -c /dev/md${no}.eli ]; then
  318. +   echo "ok $i - no -B"
  319. +else
  320. +   echo "not ok $i - no -B"
  321. +fi
  322. +i=$((i + 1))
  323. +
  324. +geli restore $hd md${no}
  325. +if [ $? -eq 0 ]; then
  326. +   echo "ok $i - no -B"
  327. +else
  328. +   echo "not ok $i - no -B"
  329. +fi
  330. +i=$((i + 1))
  331. +
  332. +geli attach -p -k $keyfile md${no} 2>/dev/null
  333. +if [ $? -eq 0 ]; then
  334. +   echo "ok $i - no -B"
  335. +else
  336. +   echo "not ok $i - no -B"
  337. +fi
  338. +i=$((i + 1))
  339. +
  340. +if [ -c /dev/md${no}.eli ]; then
  341. +   echo "ok $i - no -B"
  342. +else
  343. +   echo "not ok $i - no -B"
  344. +fi
  345. +i=$((i + 1))
  346. +geli detach md${no}
  347. +
  348. +rm -f $backupfile
  349. +geli init -B $backupfile -H $hd -P -K $keyfile md${no} >/dev/null 2>&1
  350. +if [ -f $backupfile ]; then
  351. +   echo "ok $i - -B file"
  352. +else
  353. +   echo "not ok $i - -B file"
  354. +fi
  355. +i=$((i + 1))
  356. +geli clear md${no}
  357. +
  358. +geli attach -p -k $keyfile md${no} 2>/dev/null
  359. +if [ $? -ne 0 ]; then
  360. +   echo "ok $i - -B file"
  361. +else
  362. +   echo "not ok $i - -B file"
  363. +fi
  364. +i=$((i + 1))
  365. +
  366. +if [ ! -c /dev/md${no}.eli ]; then
  367. +   echo "ok $i - -B file"
  368. +else
  369. +   echo "not ok $i - -B file"
  370. +fi
  371. +i=$((i + 1))
  372. +
  373. +geli restore $hd md${no}
  374. +if [ $? -eq 0 ]; then
  375. +   echo "ok $i - -B file"
  376. +else
  377. +   echo "not ok $i - -B file"
  378. +fi
  379. +i=$((i + 1))
  380. +
  381. +geli attach -p -k $keyfile md${no} 2>/dev/null
  382. +if [ $? -eq 0 ]; then
  383. +   echo "ok $i - -B file"
  384. +else
  385. +   echo "not ok $i - -B file"
  386. +fi
  387. +i=$((i + 1))
  388. +
  389. +if [ -c /dev/md${no}.eli ]; then
  390. +   echo "ok $i - -B file"
  391. +else
  392. +   echo "not ok $i - -B file"
  393. +fi
  394. +i=$((i + 1))
  395. +geli detach md${no}
  396. +rm -f $backupfile
  397. +
  398. +mdconfig -d -u $no
  399. +rm -f $keyfile $hd
  400. --- tools/regression/geom_eli/init-H.t.orig 2013-06-02 19:43:36.111589789 +0300
  401. +++ tools/regression/geom_eli/init-H.t  2013-06-02 15:01:27.777876084 +0300
  402. @@ -0,0 +1,65 @@
  403. +#!/bin/sh
  404. +
  405. +base=`basename $0`
  406. +no=45
  407. +sectors=100
  408. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  409. +
  410. +echo 1..460
  411. +
  412. +i=1
  413. +
  414. +for cipher in aes:0 aes:128 aes:256 \
  415. +    aes-xts:0 aes-xts:128 aes-xts:256 \
  416. +    aes-cbc:0 aes-cbc:128 aes-cbc:192 aes-cbc:256 \
  417. +    3des:0 3des:192 \
  418. +    3des-cbc:0 3des-cbc:192 \
  419. +    blowfish:0 blowfish:128 blowfish:160 blowfish:192 blowfish:224 \
  420. +    blowfish:256 blowfish:288 blowfish:320 blowfish:352 blowfish:384 \
  421. +    blowfish:416 blowfish:448 \
  422. +    blowfish-cbc:0 blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 blowfish-cbc:224 \
  423. +    blowfish-cbc:256 blowfish-cbc:288 blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \
  424. +    blowfish-cbc:416 blowfish-cbc:448 \
  425. +    camellia:0 camellia:128 camellia:192 camellia:256 \
  426. +    camellia-cbc:0 camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do
  427. +   ealgo=${cipher%%:*}
  428. +   keylen=${cipher##*:}
  429. +   for secsize in 512 1024 2048 4096 8192; do
  430. +       hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  431. +       rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
  432. +       mdconfig -a -t malloc -s `expr $secsize \* $sectors + 512`b -u $no || exit 1
  433. +
  434. +       dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  435. +
  436. +       geli init -B none -H $hd -e $ealgo -l $keylen -P -K $keyfile -s $secsize md${no} 2>/dev/null
  437. +       geli attach -H $hd -p -k $keyfile md${no}
  438. +
  439. +       secs=`diskinfo /dev/md${no}.eli | awk '{print $4}'`
  440. +
  441. +       dd if=/dev/random of=${rnd} bs=${secsize} count=${secs} >/dev/null 2>&1
  442. +       dd if=${rnd} of=/dev/md${no}.eli bs=${secsize} count=${secs} 2>/dev/null
  443. +
  444. +       md_rnd=`dd if=${rnd} bs=${secsize} count=${secs} 2>/dev/null | md5`
  445. +       md_ddev=`dd if=/dev/md${no}.eli bs=${secsize} count=${secs} 2>/dev/null | md5`
  446. +       md_edev=`dd if=/dev/md${no} bs=${secsize} count=${secs} 2>/dev/null | md5`
  447. +
  448. +       if [ ${md_rnd} = ${md_ddev} ]; then
  449. +           echo "ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  450. +       else
  451. +           echo "not ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  452. +       fi
  453. +       i=$((i+1))
  454. +       if [ ${md_rnd} != ${md_edev} ]; then
  455. +           echo "ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  456. +       else
  457. +           echo "not ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  458. +       fi
  459. +       i=$((i+1))
  460. +
  461. +       geli detach md${no}
  462. +       rm -f $rnd $hd
  463. +       mdconfig -d -u $no
  464. +   done
  465. +done
  466. +
  467. +rm -f $keyfile
  468. --- tools/regression/geom_eli/init-J-H.t.orig   2013-06-02 19:43:45.135958250 +0300
  469. +++ tools/regression/geom_eli/init-J-H.t    2013-06-02 15:01:34.633747430 +0300
  470. @@ -0,0 +1,126 @@
  471. +#!/bin/sh
  472. +
  473. +base=`basename $0`
  474. +no=45
  475. +sectors=100
  476. +keyfile0=`mktemp /tmp/$base.XXXXXX` || exit 1
  477. +keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
  478. +passfile0=`mktemp /tmp/$base.XXXXXX` || exit 1
  479. +passfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
  480. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  481. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  482. +
  483. +echo 1..150
  484. +
  485. +dd if=/dev/random of=${keyfile0} bs=512 count=16 >/dev/null 2>&1
  486. +dd if=/dev/random of=${keyfile1} bs=512 count=16 >/dev/null 2>&1
  487. +dd if=/dev/random bs=512 count=16 2>/dev/null | sha1 > ${passfile0}
  488. +dd if=/dev/random bs=512 count=16 2>/dev/null | sha1 > ${passfile1}
  489. +
  490. +i=1
  491. +for iter in -1 0 64; do
  492. +   geli init -H $hd -i ${iter} -B none -J ${passfile0} -P md${no} 2>/dev/null && echo -n "not "
  493. +   echo "ok ${i}"; i=$((i+1))
  494. +   geli init -H $hd -i ${iter} -B none -J ${passfile0} -P -K ${keyfile0} md${no} 2>/dev/null && echo -n "not "
  495. +   echo "ok ${i}"; i=$((i+1))
  496. +   geli init -H $hd -i ${iter} -B none -J ${passfile0} -K ${keyfile0} md${no} 2>/dev/null || echo -n "not "
  497. +   echo "ok ${i}"; i=$((i+1))
  498. +   geli attach -H $hd -k ${keyfile0} -p md${no} 2>/dev/null && echo -n "not "
  499. +   echo "ok ${i}"; i=$((i+1))
  500. +   geli attach -H $hd -j ${passfile0} md${no} 2>/dev/null && echo -n "not "
  501. +   echo "ok ${i}"; i=$((i+1))
  502. +   geli attach -H $hd -j ${keyfile0} md${no} 2>/dev/null && echo -n "not "
  503. +   echo "ok ${i}"; i=$((i+1))
  504. +   geli attach -H $hd -k ${passfile0} -p md${no} 2>/dev/null && echo -n "not "
  505. +   echo "ok ${i}"; i=$((i+1))
  506. +   geli attach -H $hd -j ${keyfile0} -k ${passfile0} md${no} 2>/dev/null && echo -n "not "
  507. +   echo "ok ${i}"; i=$((i+1))
  508. +   geli attach -H $hd -j ${keyfile0} -k ${keyfile0} md${no} 2>/dev/null && echo -n "not "
  509. +   echo "ok ${i}"; i=$((i+1))
  510. +   geli attach -H $hd -j ${passfile0} -k ${passfile0} md${no} 2>/dev/null && echo -n "not "
  511. +   echo "ok ${i}"; i=$((i+1))
  512. +   geli attach -H $hd -j ${passfile0} -k ${keyfile0} md${no} 2>/dev/null || echo -n "not "
  513. +   echo "ok ${i}"; i=$((i+1))
  514. +   geli detach md${no} || echo -n "not "
  515. +   echo "ok ${i}"; i=$((i+1))
  516. +   cat ${keyfile0} | geli attach -H $hd -j ${passfile0} -k - md${no} 2>/dev/null || echo -n "not "
  517. +   echo "ok ${i}"; i=$((i+1))
  518. +   geli detach md${no} || echo -n "not "
  519. +   echo "ok ${i}"; i=$((i+1))
  520. +   cat ${passfile0} | geli attach -H $hd -j - -k ${keyfile0} md${no} 2>/dev/null || echo -n "not "
  521. +   echo "ok ${i}"; i=$((i+1))
  522. +   geli detach md${no} || echo -n "not "
  523. +   echo "ok ${i}"; i=$((i+1))
  524. +
  525. +   geli init -H $hd -i ${iter} -B none -J ${passfile0} -J ${passfile1} -P md${no} 2>/dev/null && echo -n "not "
  526. +   echo "ok ${i}"; i=$((i+1))
  527. +   geli init -H $hd -i ${iter} -B none -J ${passfile0} -J ${passfile1} -P -K ${keyfile0} -K ${keyfile1} md${no} 2>/dev/null && echo -n "not "
  528. +   echo "ok ${i}"; i=$((i+1))
  529. +   geli init -H $hd -i ${iter} -B none -J ${passfile0} -J ${passfile1} -K ${keyfile0} -K ${keyfile1} md${no} 2>/dev/null || echo -n "not "
  530. +   echo "ok ${i}"; i=$((i+1))
  531. +   geli attach -H $hd -k ${keyfile0} -p md${no} 2>/dev/null && echo -n "not "
  532. +   echo "ok ${i}"; i=$((i+1))
  533. +   geli attach -H $hd -k ${keyfile1} -p md${no} 2>/dev/null && echo -n "not "
  534. +   echo "ok ${i}"; i=$((i+1))
  535. +   geli attach -H $hd -j ${passfile0} md${no} 2>/dev/null && echo -n "not "
  536. +   echo "ok ${i}"; i=$((i+1))
  537. +   geli attach -H $hd -j ${passfile1} md${no} 2>/dev/null && echo -n "not "
  538. +   echo "ok ${i}"; i=$((i+1))
  539. +   geli attach -H $hd -k ${keyfile0} -k ${keyfile1} -p md${no} 2>/dev/null && echo -n "not "
  540. +   echo "ok ${i}"; i=$((i+1))
  541. +   geli attach -H $hd -j ${passfile0} -j ${passfile1} md${no} 2>/dev/null && echo -n "not "
  542. +   echo "ok ${i}"; i=$((i+1))
  543. +   geli attach -H $hd -k ${keyfile0} -j ${passfile0} md${no} 2>/dev/null && echo -n "not "
  544. +   echo "ok ${i}"; i=$((i+1))
  545. +   geli attach -H $hd -k ${keyfile0} -j ${passfile1} md${no} 2>/dev/null && echo -n "not "
  546. +   echo "ok ${i}"; i=$((i+1))
  547. +   geli attach -H $hd -k ${keyfile1} -j ${passfile0} md${no} 2>/dev/null && echo -n "not "
  548. +   echo "ok ${i}"; i=$((i+1))
  549. +   geli attach -H $hd -k ${keyfile1} -j ${passfile1} md${no} 2>/dev/null && echo -n "not "
  550. +   echo "ok ${i}"; i=$((i+1))
  551. +   geli attach -H $hd -k ${keyfile0} -j ${passfile0} -j ${passfile1} md${no} 2>/dev/null && echo -n "not "
  552. +   echo "ok ${i}"; i=$((i+1))
  553. +   geli attach -H $hd -k ${keyfile1} -j ${passfile0} -j ${passfile1} md${no} 2>/dev/null && echo -n "not "
  554. +   echo "ok ${i}"; i=$((i+1))
  555. +   geli attach -H $hd -k ${keyfile0} -k ${keyfile1} -j ${passfile0} md${no} 2>/dev/null && echo -n "not "
  556. +   echo "ok ${i}"; i=$((i+1))
  557. +   geli attach -H $hd -k ${keyfile0} -k ${keyfile1} -j ${passfile1} md${no} 2>/dev/null && echo -n "not "
  558. +   echo "ok ${i}"; i=$((i+1))
  559. +   geli attach -H $hd -k ${keyfile1} -k ${keyfile0} -j ${passfile0} -j ${passfile1} md${no} 2>/dev/null && echo -n "not "
  560. +   echo "ok ${i}"; i=$((i+1))
  561. +   geli attach -H $hd -k ${keyfile0} -k ${keyfile1} -j ${passfile1} -j ${passfile0} md${no} 2>/dev/null && echo -n "not "
  562. +   echo "ok ${i}"; i=$((i+1))
  563. +   geli attach -H $hd -k ${keyfile1} -k ${keyfile0} -j ${passfile1} -j ${passfile0} md${no} 2>/dev/null && echo -n "not "
  564. +   echo "ok ${i}"; i=$((i+1))
  565. +   geli attach -H $hd -j ${passfile0} -j ${passfile1} -k ${keyfile0} -k ${keyfile1} md${no} 2>/dev/null || echo -n "not "
  566. +   echo "ok ${i}"; i=$((i+1))
  567. +   geli detach md${no} || echo -n "not "
  568. +   echo "ok ${i}"; i=$((i+1))
  569. +   cat ${passfile0} | geli attach -H $hd -j - -j ${passfile1} -k ${keyfile0} -k ${keyfile1} md${no} 2>/dev/null || echo -n "not "
  570. +   echo "ok ${i}"; i=$((i+1))
  571. +   geli detach md${no} || echo -n "not "
  572. +   echo "ok ${i}"; i=$((i+1))
  573. +   cat ${passfile1} | geli attach -H $hd -j ${passfile0} -j - -k ${keyfile0} -k ${keyfile1} md${no} 2>/dev/null || echo -n "not "
  574. +   echo "ok ${i}"; i=$((i+1))
  575. +   geli detach md${no} || echo -n "not "
  576. +   echo "ok ${i}"; i=$((i+1))
  577. +   cat ${keyfile0} | geli attach -H $hd -j ${passfile0} -j ${passfile1} -k - -k ${keyfile1} md${no} 2>/dev/null || echo -n "not "
  578. +   echo "ok ${i}"; i=$((i+1))
  579. +   geli detach md${no} || echo -n "not "
  580. +   echo "ok ${i}"; i=$((i+1))
  581. +   cat ${keyfile1} | geli attach -H $hd -j ${passfile0} -j ${passfile1} -k ${keyfile0} -k - md${no} 2>/dev/null || echo -n "not "
  582. +   echo "ok ${i}"; i=$((i+1))
  583. +   geli detach md${no} || echo -n "not "
  584. +   echo "ok ${i}"; i=$((i+1))
  585. +   cat ${keyfile0} ${keyfile1} | geli attach -H $hd -j ${passfile0} -j ${passfile1} -k - md${no} 2>/dev/null || echo -n "not "
  586. +   echo "ok ${i}"; i=$((i+1))
  587. +   geli detach md${no} || echo -n "not "
  588. +   echo "ok ${i}"; i=$((i+1))
  589. +   cat ${passfile0} ${passfile1} | awk '{printf "%s", $0}' | geli attach -H $hd -j - -k ${keyfile0} -k ${keyfile1} md${no} 2>/dev/null || echo -n "not "
  590. +   echo "ok ${i}"; i=$((i+1))
  591. +   geli detach md${no} || echo -n "not "
  592. +   echo "ok ${i}"; i=$((i+1))
  593. +done
  594. +
  595. +mdconfig -d -u $no
  596. +rm -f ${keyfile0} ${keyfile1} ${passfile0} ${passfile1} $hd
  597. --- tools/regression/geom_eli/init-a-H.t.orig   2013-06-02 19:43:52.456513585 +0300
  598. +++ tools/regression/geom_eli/init-a-H.t    2013-06-02 15:01:41.133573525 +0300
  599. @@ -0,0 +1,60 @@
  600. +#!/bin/sh
  601. +
  602. +base=`basename $0`
  603. +no=45
  604. +sectors=100
  605. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  606. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  607. +
  608. +echo 1..1380
  609. +
  610. +i=1
  611. +
  612. +for cipher in aes:0 aes:128 aes:256 \
  613. +    aes-xts:0 aes-xts:128 aes-xts:256 \
  614. +    aes-cbc:0 aes-cbc:128 aes-cbc:192 aes-cbc:256 \
  615. +    3des:0 3des:192 \
  616. +    3des-cbc:0 3des-cbc:192 \
  617. +    blowfish:0 blowfish:128 blowfish:160 blowfish:192 blowfish:224 \
  618. +    blowfish:256 blowfish:288 blowfish:320 blowfish:352 blowfish:384 \
  619. +    blowfish:416 blowfish:448 \
  620. +    blowfish-cbc:0 blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 blowfish-cbc:224 \
  621. +    blowfish-cbc:256 blowfish-cbc:288 blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \
  622. +    blowfish-cbc:416 blowfish-cbc:448 \
  623. +    camellia:0 camellia:128 camellia:192 camellia:256 \
  624. +    camellia-cbc:0 camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do
  625. +   ealgo=${cipher%%:*}
  626. +   keylen=${cipher##*:}
  627. +   for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 hmac/sha384 hmac/sha512; do
  628. +       for secsize in 512 1024 2048 4096 8192; do
  629. +           rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
  630. +           mdconfig -a -t malloc -s `expr $secsize \* $sectors + 512`b -u $no || exit 1
  631. +
  632. +           dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  633. +
  634. +           geli init -B none -H $hd -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize md${no} 2>/dev/null
  635. +           geli attach -H $hd -p -k $keyfile md${no}
  636. +
  637. +           secs=`diskinfo /dev/md${no}.eli | awk '{print $4}'`
  638. +
  639. +           dd if=/dev/random of=${rnd} bs=${secsize} count=${secs} >/dev/null 2>&1
  640. +           dd if=${rnd} of=/dev/md${no}.eli bs=${secsize} count=${secs} 2>/dev/null
  641. +
  642. +           md_rnd=`dd if=${rnd} bs=${secsize} count=${secs} 2>/dev/null | md5`
  643. +           md_ddev=`dd if=/dev/md${no}.eli bs=${secsize} count=${secs} 2>/dev/null | md5`
  644. +
  645. +           if [ ${md_rnd} = ${md_ddev} ]; then
  646. +               echo "ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  647. +           else
  648. +               echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  649. +           fi
  650. +           i=$((i+1))
  651. +
  652. +           geli detach md${no}
  653. +           rm -f $rnd
  654. +           mdconfig -d -u $no
  655. +       done
  656. +   done
  657. +done
  658. +
  659. +rm -f $keyfile $hd
  660. --- tools/regression/geom_eli/init-i-P-H.t.orig 2013-06-02 19:44:00.977279982 +0300
  661. +++ tools/regression/geom_eli/init-i-P-H.t  2013-06-02 15:01:46.547261577 +0300
  662. @@ -0,0 +1,25 @@
  663. +#!/bin/sh
  664. +
  665. +base=`basename $0`
  666. +no=45
  667. +sectors=100
  668. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  669. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  670. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  671. +
  672. +echo 1..1
  673. +
  674. +i=1
  675. +
  676. +dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  677. +
  678. +geli init -B none -H $hd -i 64 -P -K ${keyfile} md${no} 2>/dev/null
  679. +if [ $? -ne 0 ]; then
  680. +   echo "ok $i"
  681. +else
  682. +   echo "not ok $i"
  683. +fi
  684. +i=$((i + 1))          
  685. +
  686. +mdconfig -d -u $no
  687. +rm -f $keyfile $hd
  688. --- tools/regression/geom_eli/integrity-copy-H.t.orig   2013-06-02 19:44:09.314457542 +0300
  689. +++ tools/regression/geom_eli/integrity-copy-H.t    2013-06-02 15:01:54.075218341 +0300
  690. @@ -0,0 +1,100 @@
  691. +#!/bin/sh
  692. +
  693. +base=`basename $0`
  694. +no=45
  695. +sectors=100
  696. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  697. +sector=`mktemp /tmp/$base.XXXXXX` || exit 1
  698. +
  699. +echo 1..5520
  700. +
  701. +i=1
  702. +
  703. +for cipher in aes:0 aes:128 aes:256 \
  704. +    aes-xts:0 aes-xts:128 aes-xts:256 \
  705. +    aes-cbc:0 aes-cbc:128 aes-cbc:192 aes-cbc:256 \
  706. +    3des:0 3des:192 \
  707. +    3des-cbc:0 3des-cbc:192 \
  708. +    blowfish:0 blowfish:128 blowfish:160 blowfish:192 blowfish:224 \
  709. +    blowfish:256 blowfish:288 blowfish:320 blowfish:352 blowfish:384 \
  710. +    blowfish:416 blowfish:448 \
  711. +    blowfish-cbc:0 blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 blowfish-cbc:224 \
  712. +    blowfish-cbc:256 blowfish-cbc:288 blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \
  713. +    blowfish-cbc:416 blowfish-cbc:448 \
  714. +    camellia:0 camellia:128 camellia:192 camellia:256 \
  715. +    camellia-cbc:0 camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do
  716. +   ealgo=${cipher%%:*}
  717. +   keylen=${cipher##*:}
  718. +   for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 hmac/sha384 hmac/sha512; do
  719. +       for secsize in 512 1024 2048 4096 8192; do
  720. +           #mdconfig -a -t malloc -s `expr $secsize \* 2 + 512`b -u $no || exit 1
  721. +           mdconfig -a -t malloc -s $sectors -u $no || exit 1
  722. +           hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  723. +
  724. +           dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  725. +
  726. +           geli init -B none -H $hd -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize md${no} 2>/dev/null
  727. +           geli attach -H $hd -p -k $keyfile md${no}
  728. +
  729. +           dd if=/dev/random of=/dev/md${no}.eli bs=${secsize} count=1 >/dev/null 2>&1
  730. +
  731. +           dd if=/dev/md${no}.eli bs=${secsize} count=1 >/dev/null 2>&1
  732. +           if [ $? -eq 0 ]; then
  733. +               echo "ok $i - small 1 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  734. +           else
  735. +               echo "not ok $i - small 1 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  736. +           fi
  737. +           i=$((i+1))
  738. +
  739. +           geli detach md${no}
  740. +           # Copy first small sector to the second small sector.
  741. +           # This should be detected as corruption.
  742. +           dd if=/dev/md${no} of=${sector} bs=512 count=1 >/dev/null 2>&1
  743. +           dd if=${sector} of=/dev/md${no} bs=512 count=1 seek=1 >/dev/null 2>&1
  744. +           geli attach -H $hd -p -k $keyfile md${no}
  745. +
  746. +           dd if=/dev/md${no}.eli of=/dev/null bs=${secsize} count=1 >/dev/null 2>&1
  747. +           if [ $? -ne 0 ]; then
  748. +               echo "ok $i - small 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  749. +           else
  750. +               echo "not ok $i - small 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  751. +           fi
  752. +           i=$((i+1))
  753. +
  754. +           ms=`diskinfo /dev/md${no} | awk '{print $3 - 512}'`
  755. +           ns=`diskinfo /dev/md${no}.eli | awk '{print $4}'`
  756. +           usecsize=`echo "($ms / $ns) - (($ms / $ns) % 512)" | bc`
  757. +
  758. +           dd if=/dev/random of=/dev/md${no}.eli bs=${secsize} count=2 >/dev/null 2>&1
  759. +
  760. +           dd if=/dev/md${no}.eli bs=${secsize} count=2 >/dev/null 2>&1
  761. +           if [ $? -eq 0 ]; then
  762. +               echo "ok $i - big 1 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  763. +           else
  764. +               echo "not ok $i - big 1 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  765. +           fi
  766. +           i=$((i+1))
  767. +
  768. +           geli detach md${no}
  769. +           # Copy first big sector to the second big sector.
  770. +           # This should be detected as corruption.
  771. +           dd if=/dev/md${no} of=${sector} bs=${usecsize} count=1 >/dev/null 2>&1
  772. +           dd if=${sector} of=/dev/md${no} bs=${usecsize} count=1 seek=1 >/dev/null 2>&1
  773. +           geli attach -H $hd -p -k $keyfile md${no}
  774. +
  775. +           dd if=/dev/md${no}.eli of=/dev/null bs=${secsize} count=2 >/dev/null 2>&1
  776. +           if [ $? -ne 0 ]; then
  777. +               echo "ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  778. +           else
  779. +               echo "not ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  780. +           fi
  781. +           i=$((i+1))
  782. +
  783. +           geli detach md${no}
  784. +           mdconfig -d -u $no
  785. +           rm $hd
  786. +       done
  787. +   done
  788. +done
  789. +
  790. +rm -f $keyfile $sector
  791. --- tools/regression/geom_eli/integrity-data-H.t.orig   2013-06-02 19:44:16.511963301 +0300
  792. +++ tools/regression/geom_eli/integrity-data-H.t    2013-06-02 15:01:59.841951264 +0300
  793. @@ -0,0 +1,70 @@
  794. +#!/bin/sh
  795. +
  796. +base=`basename $0`
  797. +no=45
  798. +sectors=100
  799. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  800. +sector=`mktemp /tmp/$base.XXXXXX` || exit 1
  801. +
  802. +echo 1..2760
  803. +
  804. +i=1
  805. +
  806. +for cipher in aes:0 aes:128 aes:256 \
  807. +    aes-xts:0 aes-xts:128 aes-xts:256 \
  808. +    aes-cbc:0 aes-cbc:128 aes-cbc:192 aes-cbc:256 \
  809. +    3des:0 3des:192 \
  810. +    3des-cbc:0 3des-cbc:192 \
  811. +    blowfish:0 blowfish:128 blowfish:160 blowfish:192 blowfish:224 \
  812. +    blowfish:256 blowfish:288 blowfish:320 blowfish:352 blowfish:384 \
  813. +    blowfish:416 blowfish:448 \
  814. +    blowfish-cbc:0 blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 blowfish-cbc:224 \
  815. +    blowfish-cbc:256 blowfish-cbc:288 blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \
  816. +    blowfish-cbc:416 blowfish-cbc:448 \
  817. +    camellia:0 camellia:128 camellia:192 camellia:256 \
  818. +    camellia-cbc:0 camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do
  819. +   ealgo=${cipher%%:*}
  820. +   keylen=${cipher##*:}
  821. +   for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 hmac/sha384 hmac/sha512; do
  822. +       for secsize in 512 1024 2048 4096 8192; do
  823. +           mdconfig -a -t malloc -s `expr $secsize \* 2 + 512`b -u $no || exit 1
  824. +           hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  825. +
  826. +           dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  827. +
  828. +           geli init -B none -H $hd -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize md${no} 2>/dev/null
  829. +           geli attach -H $hd -p -k $keyfile md${no}
  830. +
  831. +           dd if=/dev/random of=/dev/md${no}.eli bs=${secsize} count=1 >/dev/null 2>&1
  832. +
  833. +           dd if=/dev/md${no}.eli bs=${secsize} count=1 >/dev/null 2>&1
  834. +           if [ $? -eq 0 ]; then
  835. +               echo "ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  836. +           else
  837. +               echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  838. +           fi
  839. +           i=$((i+1))
  840. +
  841. +           geli detach md${no}
  842. +           # Corrupt 8 bytes of data.
  843. +           dd if=/dev/md${no} of=${sector} bs=512 count=1 >/dev/null 2>&1
  844. +           dd if=/dev/random of=${sector} bs=1 count=8 seek=64 conv=notrunc >/dev/null 2>&1
  845. +           dd if=${sector} of=/dev/md${no} bs=512 count=1 >/dev/null 2>&1
  846. +           geli attach -H $hd -p -k $keyfile md${no}
  847. +
  848. +           dd if=/dev/md${no}.eli of=/dev/null bs=${secsize} count=1 >/dev/null 2>&1
  849. +           if [ $? -ne 0 ]; then
  850. +               echo "ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  851. +           else
  852. +               echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  853. +           fi
  854. +           i=$((i+1))
  855. +
  856. +           geli detach md${no}
  857. +           mdconfig -d -u $no
  858. +           rm $hd
  859. +       done
  860. +   done
  861. +done
  862. +
  863. +rm -f $keyfile $sector
  864. --- tools/regression/geom_eli/integrity-hmac-H.t.orig   2013-06-02 19:44:23.520972406 +0300
  865. +++ tools/regression/geom_eli/integrity-hmac-H.t    2013-06-02 15:02:06.302772401 +0300
  866. @@ -0,0 +1,70 @@
  867. +#!/bin/sh
  868. +
  869. +base=`basename $0`
  870. +no=45
  871. +sectors=100
  872. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  873. +sector=`mktemp /tmp/$base.XXXXXX` || exit 1
  874. +
  875. +echo 1..2760
  876. +
  877. +i=1
  878. +
  879. +for cipher in aes:0 aes:128 aes:256 \
  880. +    aes-xts:0 aes-xts:128 aes-xts:256 \
  881. +    aes-cbc:0 aes-cbc:128 aes-cbc:192 aes-cbc:256 \
  882. +    3des:0 3des:192 \
  883. +    3des-cbc:0 3des-cbc:192 \
  884. +    blowfish:0 blowfish:128 blowfish:160 blowfish:192 blowfish:224 \
  885. +    blowfish:256 blowfish:288 blowfish:320 blowfish:352 blowfish:384 \
  886. +    blowfish:416 blowfish:448 \
  887. +    blowfish-cbc:0 blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 blowfish-cbc:224 \
  888. +    blowfish-cbc:256 blowfish-cbc:288 blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \
  889. +    blowfish-cbc:416 blowfish-cbc:448 \
  890. +    camellia:0 camellia:128 camellia:192 camellia:256 \
  891. +    camellia-cbc:0 camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do
  892. +   ealgo=${cipher%%:*}
  893. +   keylen=${cipher##*:}
  894. +   for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 hmac/sha384 hmac/sha512; do
  895. +       for secsize in 512 1024 2048 4096 8192; do
  896. +           mdconfig -a -t malloc -s `expr $secsize \* 2 + 512`b -u $no || exit 1
  897. +           hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  898. +
  899. +           dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  900. +
  901. +           geli init -B none -H $hd -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize md${no} 2>/dev/null
  902. +           geli attach -H $hd -p -k $keyfile md${no}
  903. +
  904. +           dd if=/dev/random of=/dev/md${no}.eli bs=${secsize} count=1 >/dev/null 2>&1
  905. +
  906. +           dd if=/dev/md${no}.eli bs=${secsize} count=1 >/dev/null 2>&1
  907. +           if [ $? -eq 0 ]; then
  908. +               echo "ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  909. +           else
  910. +               echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  911. +           fi
  912. +           i=$((i+1))
  913. +
  914. +           geli detach md${no}
  915. +           # Corrupt 8 bytes of HMAC.
  916. +           dd if=/dev/md${no} of=${sector} bs=512 count=1 >/dev/null 2>&1
  917. +           dd if=/dev/random of=${sector} bs=1 count=16 conv=notrunc >/dev/null 2>&1
  918. +           dd if=${sector} of=/dev/md${no} bs=512 count=1 >/dev/null 2>&1
  919. +           geli attach -H $hd -p -k $keyfile md${no}
  920. +
  921. +           dd if=/dev/md${no}.eli bs=${secsize} count=1 >/dev/null 2>&1
  922. +           if [ $? -ne 0 ]; then
  923. +               echo "ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  924. +           else
  925. +               echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
  926. +           fi
  927. +           i=$((i+1))
  928. +
  929. +           geli detach md${no}
  930. +           mdconfig -d -u $no
  931. +           rm $hd
  932. +       done
  933. +   done
  934. +done
  935. +
  936. +rm -f $keyfile $sector
  937. --- tools/regression/geom_eli/kill-H.t.orig 2013-06-02 19:44:31.851649909 +0300
  938. +++ tools/regression/geom_eli/kill-H.t  2013-06-02 15:03:47.244601588 +0300
  939. @@ -0,0 +1,40 @@
  940. +#!/bin/sh
  941. +
  942. +base=`basename $0`
  943. +no=45
  944. +sectors=100
  945. +keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
  946. +keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
  947. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  948. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  949. +
  950. +echo 1..2
  951. +
  952. +i=1
  953. +
  954. +dd if=/dev/random of=${keyfile1} bs=512 count=16 >/dev/null 2>&1
  955. +dd if=/dev/random of=${keyfile2} bs=512 count=16 >/dev/null 2>&1
  956. +
  957. +geli init -H $hd -B none -P -K $keyfile1 md${no}
  958. +geli attach -H $hd -p -k $keyfile1 md${no}
  959. +geli setkey -H $hd -n 1 -P -K $keyfile2 md${no}
  960. +
  961. +geli kill md${no}
  962. +if [ $? -eq 0 ]; then
  963. +   echo "ok $i"
  964. +else
  965. +   echo "not ok $i"
  966. +fi
  967. +i=$((i + 1))
  968. +sleep 1
  969. +
  970. +if [ ! -c /dev/md{$no}.eli ]; then
  971. +   echo "ok $i"
  972. +else
  973. +   echo "not ok $i"
  974. +fi
  975. +i=$((i + 1))
  976. +
  977. +
  978. +mdconfig -d -u $no
  979. +rm -f $keyfile1 $keyfile2 $hd
  980. --- tools/regression/geom_eli/nokey-H.t.orig    2013-06-02 19:44:38.948121946 +0300
  981. +++ tools/regression/geom_eli/nokey-H.t 2013-06-02 15:02:12.875607774 +0300
  982. @@ -0,0 +1,81 @@
  983. +#!/bin/sh
  984. +
  985. +base=`basename $0`
  986. +no=45
  987. +sectors=100
  988. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  989. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  990. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  991. +
  992. +echo 1..8
  993. +
  994. +i=1
  995. +
  996. +geli init -H $hd -B none -P md${no} 2>/dev/null
  997. +if [ $? -ne 0 ]; then
  998. +   echo "ok $i"
  999. +else
  1000. +   echo "not ok $i"
  1001. +fi
  1002. +i=$((i + 1))
  1003. +
  1004. +dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  1005. +
  1006. +geli init -H $hd -B none -P -K ${keyfile} md${no} 2>/dev/null
  1007. +if [ $? -eq 0 ]; then
  1008. +   echo "ok $i"
  1009. +else
  1010. +   echo "not ok $i"
  1011. +fi
  1012. +i=$((i + 1))
  1013. +
  1014. +geli attach -H $hd -p md${no} 2>/dev/null
  1015. +if [ $? -ne 0 ]; then
  1016. +   echo "ok $i"
  1017. +else
  1018. +   echo "not ok $i"
  1019. +fi
  1020. +i=$((i + 1))
  1021. +
  1022. +geli attach -H $hd -p -k ${keyfile} md${no} 2>/dev/null
  1023. +if [ $? -eq 0 ]; then
  1024. +   echo "ok $i"
  1025. +else
  1026. +   echo "not ok $i"
  1027. +fi
  1028. +i=$((i + 1))
  1029. +
  1030. +geli setkey -H $hd -n 0 -P md${no} 2>/dev/null
  1031. +if [ $? -ne 0 ]; then
  1032. +   echo "ok $i"
  1033. +else
  1034. +   echo "not ok $i"
  1035. +fi
  1036. +i=$((i + 1))
  1037. +
  1038. +geli detach md${no} 2>/dev/null
  1039. +if [ $? -eq 0 ]; then
  1040. +   echo "ok $i"
  1041. +else
  1042. +   echo "not ok $i"
  1043. +fi
  1044. +i=$((i + 1))
  1045. +
  1046. +geli setkey -H $hd -n 0 -p -P -K ${keyfile} md${no} 2>/dev/null
  1047. +if [ $? -ne 0 ]; then
  1048. +   echo "ok $i"
  1049. +else
  1050. +   echo "not ok $i"
  1051. +fi
  1052. +i=$((i + 1))
  1053. +
  1054. +geli setkey -H $hd -n 0 -p -k ${keyfile} -P md${no} 2>/dev/null
  1055. +if [ $? -ne 0 ]; then
  1056. +   echo "ok $i"
  1057. +else
  1058. +   echo "not ok $i"
  1059. +fi
  1060. +i=$((i + 1))
  1061. +
  1062. +mdconfig -d -u $no
  1063. +rm -f $keyfile $hd
  1064. --- tools/regression/geom_eli/readonly-H.t.orig 2013-06-02 19:44:47.704134861 +0300
  1065. +++ tools/regression/geom_eli/readonly-H.t  2013-06-02 15:00:51.180224711 +0300
  1066. @@ -0,0 +1,49 @@
  1067. +#!/bin/sh
  1068. +# $FreeBSD: stable/9/tools/regression/geom_eli/readonly.t 182452 2008-08-29 18:10:18Z pjd $
  1069. +
  1070. +base=`basename $0`
  1071. +no=45
  1072. +sectors=100
  1073. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  1074. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  1075. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  1076. +
  1077. +echo 1..10
  1078. +
  1079. +i=1
  1080. +
  1081. +dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
  1082. +
  1083. +geli init -H $hd -B none -P -K $keyfile md${no} || echo -n "not "
  1084. +echo ok $i; i=$((i + 1))
  1085. +
  1086. +geli attach -H $hd -r -p -k $keyfile md${no} || echo -n "not "
  1087. +echo ok $i; i=$((i + 1))
  1088. +
  1089. +sh -c "true >/dev/md${no}.eli" 2>/dev/null && echo -n "not "
  1090. +echo ok $i; i=$((i + 1))
  1091. +
  1092. +geli kill md${no} || echo -n "not "
  1093. +echo ok $i; i=$((i + 1))
  1094. +
  1095. +if [ -c /dev/md{$no}.eli ]; then echo "not "; fi
  1096. +echo ok $i; i=$((i + 1))
  1097. +
  1098. +geli attach -H $hd -r -p -k $keyfile md${no}
  1099. +geli setkey -H $hd -n 1 -P -K /dev/null md${no} 2>/dev/null && echo -n "not "
  1100. +echo ok $i; i=$((i + 1))
  1101. +
  1102. +geli delkey -H $hd -n 0 md${no} 2>/dev/null && echo -n "not "
  1103. +echo ok $i; i=$((i + 1))
  1104. +
  1105. +geli delkey -H $hd -f -n 0 md${no} 2>/dev/null && echo -n "not "
  1106. +echo ok $i; i=$((i + 1))
  1107. +
  1108. +geli list md${no}.eli | egrep '^Flags: .*READ-ONLY' >/dev/null || echo -n "not "
  1109. +echo ok $i; i=$((i + 1))
  1110. +
  1111. +geli detach md${no} || echo -n "not "
  1112. +echo ok $i; i=$((i + 1))
  1113. +
  1114. +mdconfig -d -u $no
  1115. +rm -f $keyfile $hd
  1116. --- tools/regression/geom_eli/resize-H.t.orig   2013-06-02 19:44:55.207434024 +0300
  1117. +++ tools/regression/geom_eli/resize-H.t    2013-06-02 14:58:47.222470318 +0300
  1118. @@ -0,0 +1,156 @@
  1119. +#! /bin/sh
  1120. +
  1121. +base=`basename $0`
  1122. +
  1123. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  1124. +meta=`mktemp /tmp/$base.XXXXXX` || exit 1
  1125. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  1126. +
  1127. +echo 1..26
  1128. +
  1129. +BLK=512
  1130. +BLKS_PER_MB=2048
  1131. +
  1132. +md=$(mdconfig -s40m) || exit 1
  1133. +unit=${md#md}
  1134. +i=1
  1135. +
  1136. +setsize() {
  1137. +    partszMB=$1 unitszMB=$2
  1138. +
  1139. +    {
  1140. +   echo a: $(($partszMB * $BLKS_PER_MB)) 0 4.2BSD 1024 8192
  1141. +   echo c: $(($unitszMB * $BLKS_PER_MB)) 0 unused 0 0
  1142. +    } | disklabel -R $md /dev/stdin
  1143. +}
  1144. +
  1145. +# Initialise
  1146. +
  1147. +kldload geom_eli >/dev/null 2>&1
  1148. +
  1149. +setsize 10 40 || echo -n "not "
  1150. +echo ok $i - "Sized ${md}a to 10m"
  1151. +i=$((i + 1))
  1152. +
  1153. +echo secret > $keyfile
  1154. +geli init -B none -H $hd -P -K $keyfile ${md}a || echo -n "not "
  1155. +echo ok $i - "Initialised geli on ${md}a"
  1156. +i=$((i + 1))
  1157. +
  1158. +geli attach -H $hd -p -k $keyfile ${md}a || echo -n "not "
  1159. +echo ok $i - "Attached ${md}a as ${md}a.eli"
  1160. +i=$((i + 1))
  1161. +
  1162. +newfs -U ${md}a.eli >/dev/null || echo -n "not "
  1163. +echo ok $i - "Initialised the filesystem on ${md}a.eli"
  1164. +i=$((i + 1))
  1165. +
  1166. +out=$(fsck -tufs -y ${md}a.eli)
  1167. +echo "$out" | fgrep -q MODIFIED && echo -n "not "
  1168. +echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
  1169. +   "lines of output"
  1170. +i=$((i + 1))
  1171. +
  1172. +geli detach ${md}a.eli || echo -n "not "
  1173. +echo ok $i - "Detached ${md}a.eli"
  1174. +i=$((i + 1))
  1175. +
  1176. +setsize 20 40 || echo -n "not "
  1177. +echo ok $i - "Sized ${md}a to 20m"
  1178. +i=$((i + 1))
  1179. +
  1180. +geli attach -H $hd -p -k $keyfile ${md}a 2>/dev/null && echo -n "not "
  1181. +echo ok $i - "Attaching ${md}a fails after resizing the consumer"
  1182. +i=$((i + 1))
  1183. +
  1184. +geli restore $hd ${md}a 2>/dev/null && echo -n "not "
  1185. +echo ok $i - "Restoring metadata on ${md}a.eli fails without -f"
  1186. +i=$((i + 1))
  1187. +
  1188. +geli restore -f $hd ${md}a || echo -n "not "
  1189. +echo ok $i - "Restoring metadata on ${md}a.eli can be forced"
  1190. +i=$((i + 1))
  1191. +
  1192. +geli backup ${md}a $hd
  1193. +geli clear ${md}a
  1194. +
  1195. +geli attach -H $hd -p -k $keyfile ${md}a || echo -n "not "
  1196. +echo ok $i - "Attaching ${md}a is now possible"
  1197. +i=$((i + 1))
  1198. +
  1199. +growfs -y ${md}a.eli >/dev/null || echo -n "not "
  1200. +echo ok $i - "Extended the filesystem on ${md}a.eli"
  1201. +i=$((i + 1))
  1202. +
  1203. +out=$(fsck -tufs -y ${md}a.eli)
  1204. +echo "$out" | fgrep -q MODIFIED && echo -n "not "
  1205. +echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
  1206. +   "lines of output"
  1207. +i=$((i + 1))
  1208. +
  1209. +# Now do the resize properly
  1210. +
  1211. +geli detach ${md}a.eli || echo -n "not "
  1212. +echo ok $i - "Detached ${md}a.eli"
  1213. +i=$((i + 1))
  1214. +
  1215. +setsize 30 40 || echo -n "not "
  1216. +echo ok $i - "Sized ${md}a to 30m"
  1217. +i=$((i + 1))
  1218. +
  1219. +geli resize -H $hd -s20m ${md}a || echo -n "not "
  1220. +echo ok $i - "Resizing works ok"
  1221. +i=$((i + 1))
  1222. +
  1223. +geli resize -H $hd -s20m ${md}a 2>/dev/null && echo -n "not "
  1224. +echo ok $i - "Resizing doesn't work a 2nd time (no old metadata)"
  1225. +i=$((i + 1))
  1226. +
  1227. +geli attach -H $hd -p -k $keyfile ${md}a || echo -n "not "
  1228. +echo ok $i - "Attaching ${md}a works ok"
  1229. +i=$((i + 1))
  1230. +
  1231. +growfs -y ${md}a.eli >/dev/null || echo -n "not "
  1232. +echo ok $i - "Extended the filesystem on ${md}a.eli"
  1233. +i=$((i + 1))
  1234. +
  1235. +out=$(fsck -tufs -y ${md}a.eli)
  1236. +echo "$out" | fgrep -q MODIFIED && echo -n "not "
  1237. +echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
  1238. +    "lines of output"
  1239. +i=$((i + 1))
  1240. +
  1241. +geli detach ${md}a.eli
  1242. +mdconfig -du$unit
  1243. +
  1244. +md=$(mdconfig -s40m) || exit 1
  1245. +unit=${md#md}
  1246. +
  1247. +gpart create -s GPT $md 1>/dev/null || echo -n "not "
  1248. +echo ok $i - "Installed a GPT on ${md}"
  1249. +i=$((i + 1))
  1250. +
  1251. +gpart add -s 20m -t freebsd-ufs -i 1 $md 1>/dev/null || echo -n "not "
  1252. +echo ok $i - "Added a 20m partition in slot 1"
  1253. +i=$((i + 1))
  1254. +
  1255. +geli init -B none -H $hd -P -K ${keyfile} ${md}p1 || echo -n "not "
  1256. +echo ok $i - "Initialised geli on ${md}p1"
  1257. +i=$((i + 1))
  1258. +
  1259. +gpart resize -s 30m -i 1 $md 1>/dev/null || echo -n "not "
  1260. +echo ok $i - "Resized partition ${md}p1 to 30m"
  1261. +i=$((i + 1))
  1262. +
  1263. +geli resize -H $hd -s 20m ${md}p1 || echo -n "not "
  1264. +echo ok $i - "Resized geli on ${md}p1 to 30m"
  1265. +i=$((i + 1))
  1266. +
  1267. +geli attach -H $hd -p -k $keyfile ${md}p1 || echo -n "not "
  1268. +echo ok $i - "Attached ${md}p1.eli"
  1269. +i=$((i + 1))
  1270. +
  1271. +geli detach ${md}p1.eli
  1272. +mdconfig -du$unit
  1273. +
  1274. +rm -f $keyfile $meta $hd
  1275. --- tools/regression/geom_eli/setkey-H.t.orig   2013-06-02 19:45:04.168246920 +0300
  1276. +++ tools/regression/geom_eli/setkey-H.t    2013-06-02 14:52:44.706396389 +0300
  1277. @@ -0,0 +1,108 @@
  1278. +#!/bin/sh
  1279. +
  1280. +base=`basename $0`
  1281. +no=45
  1282. +sectors=100
  1283. +rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
  1284. +keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
  1285. +keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
  1286. +keyfile3=`mktemp /tmp/$base.XXXXXX` || exit 1
  1287. +keyfile4=`mktemp /tmp/$base.XXXXXX` || exit 1
  1288. +keyfile5=`mktemp /tmp/$base.XXXXXX` || exit 1
  1289. +hd=`mktemp /tmp/$base.XXXXXX` || exit 1
  1290. +mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
  1291. +
  1292. +echo "1..16"
  1293. +
  1294. +i=1
  1295. +
  1296. +dd if=/dev/random of=${rnd} bs=512 count=${sectors} >/dev/null 2>&1
  1297. +hash1=`dd if=${rnd} bs=512 count=${sectors} 2>/dev/null | md5`
  1298. +dd if=/dev/random of=${keyfile1} bs=512 count=16 >/dev/null 2>&1
  1299. +dd if=/dev/random of=${keyfile2} bs=512 count=16 >/dev/null 2>&1
  1300. +dd if=/dev/random of=${keyfile3} bs=512 count=16 >/dev/null 2>&1
  1301. +dd if=/dev/random of=${keyfile4} bs=512 count=16 >/dev/null 2>&1
  1302. +dd if=/dev/random of=${keyfile5} bs=512 count=16 >/dev/null 2>&1
  1303. +
  1304. +geli init -B none -H $hd -P -K $keyfile1 md${no}
  1305. +geli attach -H $hd -p -k $keyfile1 md${no}
  1306. +
  1307. +dd if=${rnd} of=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null
  1308. +rm -f $rnd
  1309. +hash2=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
  1310. +
  1311. +geli setkey -H $hd -P -K $keyfile2 md${no} 1>/dev/null || echo -n "not "
  1312. +echo ok $i - "Change current key (0) for attached provider"
  1313. +i=$((i + 1))
  1314. +geli detach md${no}
  1315. +
  1316. +geli attach -H $hd -p -k $keyfile1 md${no} 2>/dev/null && echo -n "not "
  1317. +echo ok $i - "We cannot use keyfile1 anymore"
  1318. +i=$((i + 1))
  1319. +
  1320. +geli attach -H $hd -p -k $keyfile2 md${no} || echo -n "not "
  1321. +echo ok $i - "Attach with new key"
  1322. +i=$((i + 1))
  1323. +hash3=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
  1324. +
  1325. +geli setkey -H $hd -n 1 -P -K $keyfile3 md${no} 1>/dev/null || echo -n "not "
  1326. +echo ok $i - "Change key 1 for attached provider"
  1327. +i=$((i + 1))
  1328. +geli detach md${no}
  1329. +
  1330. +geli attach -H $hd -p -k $keyfile3 md${no} || echo -n "not "
  1331. +echo ok $i - "Attach with key 1"
  1332. +i=$((i + 1))
  1333. +hash4=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
  1334. +geli detach md${no}
  1335. +
  1336. +geli setkey -H $hd -p -k $keyfile3 -P -K $keyfile4 md${no} 1>/dev/null || echo -n "not "
  1337. +echo ok $i - "Change current (1) key for detached provider"
  1338. +i=$((i + 1))
  1339. +
  1340. +geli attach -H $hd -p -k $keyfile3 md${no} 2>/dev/null && echo -n "not "
  1341. +echo ok $i - "We cannot use keyfile3 anymore"
  1342. +i=$((i + 1))
  1343. +
  1344. +geli attach -H $hd -p -k $keyfile4 md${no} || echo -n "not "
  1345. +echo ok $i - "Attach with key 1"
  1346. +i=$((i + 1))
  1347. +hash5=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
  1348. +geli detach md${no}
  1349. +
  1350. +geli setkey -H $hd -n 0 -p -k $keyfile4 -P -K $keyfile5 md${no} 1>/dev/null || echo -n "not "
  1351. +echo ok $i - "Change key 0 for detached provider"
  1352. +i=$((i + 1))
  1353. +
  1354. +geli attach -H $hd -p -k $keyfile2 md${no} 2>/dev/null && echo -n "not "
  1355. +echo ok $i - "We cannot use keyfile2 anymore"
  1356. +i=$((i + 1))
  1357. +
  1358. +geli attach -H $hd -p -k $keyfile5 md${no} || echo -n "not "
  1359. +echo ok $i - "Attach with key 0"
  1360. +i=$((i + 1))
  1361. +hash6=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
  1362. +geli detach md${no}
  1363. +
  1364. +if [ ${hash1} != ${hash2} ]; then echo -n "not "; fi
  1365. +echo ok $i - "key1 equal key2"
  1366. +i=$((i + 1))
  1367. +
  1368. +if [ ${hash1} != ${hash3} ]; then echo -n "not "; fi
  1369. +echo ok $i - "key1 equal key3"
  1370. +i=$((i + 1))
  1371. +
  1372. +if [ ${hash1} != ${hash4} ]; then echo -n "not "; fi
  1373. +echo ok $i - "key1 equal key4"
  1374. +i=$((i + 1))
  1375. +
  1376. +if [ ${hash1} != ${hash5} ]; then echo -n "not "; fi
  1377. +echo ok $i - "key1 equal key5"
  1378. +i=$((i + 1))
  1379. +
  1380. +if [ ${hash1} != ${hash6} ]; then echo -n "not "; fi
  1381. +echo ok $i - "key1 equal key6"
  1382. +i=$((i + 1))
  1383. +
  1384. +mdconfig -d -u $no
  1385. +rm -f $keyfile1 $keyfile2 $keyfile3 $keyfile4 $keyfile5 $hd
  1386. --- tools/regression/geom_eli/resize.t.orig 2013-05-28 19:16:26.965730227 +0300
  1387. +++ tools/regression/geom_eli/resize.t  2013-06-02 14:59:14.592948965 +0300
  1388. @@ -2,6 +2,11 @@
  1389.  #
  1390.  # $FreeBSD: stable/9/tools/regression/geom_eli/resize.t 213231 2010-09-27 21:10:37Z pjd $
  1391.  
  1392. +base=`basename $0`
  1393. +
  1394. +keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
  1395. +meta=`mktemp /tmp/$base.XXXXXX` || exit 1
  1396. +
  1397.  echo 1..27
  1398.  
  1399.  BLK=512
  1400. @@ -28,17 +33,19 @@
  1401.  echo ok $i - "Sized ${md}a to 10m"
  1402.  i=$((i + 1))
  1403.  
  1404. -echo secret >tmp.key
  1405. -geli init -Bnone -PKtmp.key ${md}a || echo -n "not "
  1406. +echo secret > $keyfile
  1407. +geli init -B none -P -K $keyfile ${md}a || echo -n "not "
  1408.  echo ok $i - "Initialised geli on ${md}a"
  1409.  i=$((i + 1))
  1410. -geli attach -pk tmp.key ${md}a || echo -n "not "
  1411. +
  1412. +geli attach -p -k $keyfile ${md}a || echo -n "not "
  1413.  echo ok $i - "Attached ${md}a as ${md}a.eli"
  1414.  i=$((i + 1))
  1415.  
  1416.  newfs -U ${md}a.eli >/dev/null || echo -n "not "
  1417.  echo ok $i - "Initialised the filesystem on ${md}a.eli"
  1418.  i=$((i + 1))
  1419. +
  1420.  out=$(fsck -tufs -y ${md}a.eli)
  1421.  echo "$out" | fgrep -q MODIFIED && echo -n "not "
  1422.  echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
  1423. @@ -49,7 +56,7 @@
  1424.  # Doing a backup, resize & restore must be forced (with -f) as geli
  1425.  # verifies that the provider size in the metadata matches the consumer.
  1426.  
  1427. -geli backup ${md}a tmp.meta || echo -n "not "
  1428. +geli backup ${md}a $meta || echo -n "not "
  1429.  echo ok $i - "Backed up ${md}a metadata"
  1430.  i=$((i + 1))
  1431.  
  1432. @@ -60,18 +67,20 @@
  1433.  setsize 20 40 || echo -n "not "
  1434.  echo ok $i - "Sized ${md}a to 20m"
  1435.  i=$((i + 1))
  1436. -geli attach -pktmp.key ${md}a && echo -n "not "
  1437. +
  1438. +geli attach -p -k $keyfile ${md}a 2>/dev/null && echo -n "not "
  1439.  echo ok $i - "Attaching ${md}a fails after resizing the consumer"
  1440.  i=$((i + 1))
  1441.  
  1442. -geli restore tmp.meta ${md}a && echo -n "not "
  1443. +geli restore $meta ${md}a 2>/dev/null && echo -n "not "
  1444.  echo ok $i - "Restoring metadata on ${md}a.eli fails without -f"
  1445.  i=$((i + 1))
  1446. -geli restore -f tmp.meta ${md}a || echo -n "not "
  1447. +
  1448. +geli restore -f $meta ${md}a || echo -n "not "
  1449.  echo ok $i - "Restoring metadata on ${md}a.eli can be forced"
  1450.  i=$((i + 1))
  1451.  
  1452. -geli attach -pktmp.key ${md}a || echo -n "not "
  1453. +geli attach -p -k $keyfile ${md}a || echo -n "not "
  1454.  echo ok $i - "Attaching ${md}a is now possible"
  1455.  i=$((i + 1))
  1456.  
  1457. @@ -99,11 +108,12 @@
  1458.  geli resize -s20m ${md}a || echo -n "not "
  1459.  echo ok $i - "Resizing works ok"
  1460.  i=$((i + 1))
  1461. -geli resize -s20m ${md}a && echo -n "not "
  1462. +
  1463. +geli resize -s20m ${md}a 2>/dev/null && echo -n "not "
  1464.  echo ok $i - "Resizing doesn't work a 2nd time (no old metadata)"
  1465.  i=$((i + 1))
  1466.  
  1467. -geli attach -pktmp.key ${md}a || echo -n "not "
  1468. +geli attach -p -k $keyfile ${md}a || echo -n "not "
  1469.  echo ok $i - "Attaching ${md}a works ok"
  1470.  i=$((i + 1))
  1471.  
  1472. @@ -118,32 +128,40 @@
  1473.  i=$((i + 1))
  1474.  
  1475.  geli detach ${md}a.eli
  1476. +mdconfig -du$unit
  1477.  
  1478. +md=$(mdconfig -s40m) || exit 1
  1479. +unit=${md#md}
  1480.  
  1481.  # Verify that the man page example works, changing ada0 to $md,
  1482.  # 1g to 20m, 2g to 30m and keyfile to tmp.key, and adding -B none
  1483.  # to geli init.
  1484.  
  1485. -gpart create -s GPT $md || echo -n "not "
  1486. +gpart create -s GPT $md 1>/dev/null || echo -n "not "
  1487.  echo ok $i - "Installed a GPT on ${md}"
  1488.  i=$((i + 1))
  1489. -gpart add -s 20m -t freebsd-ufs -i 1 $md || echo -n "not "
  1490. +
  1491. +gpart add -s 20m -t freebsd-ufs -i 1 $md 1>/dev/null || echo -n "not "
  1492.  echo ok $i - "Added a 20m partition in slot 1"
  1493.  i=$((i + 1))
  1494. -geli init -B none -K tmp.key -P ${md}p1 || echo -n "not "
  1495. +
  1496. +geli init -B none -P -K ${keyfile} ${md}p1 || echo -n "not "
  1497.  echo ok $i - "Initialised geli on ${md}p1"
  1498.  i=$((i + 1))
  1499. -gpart resize -s 30m -i 1 $md || echo -n "not "
  1500. +
  1501. +gpart resize -s 30m -i 1 $md 1>/dev/null || echo -n "not "
  1502.  echo ok $i - "Resized partition ${md}p1 to 30m"
  1503.  i=$((i + 1))
  1504. +
  1505.  geli resize -s 20m ${md}p1 || echo -n "not "
  1506.  echo ok $i - "Resized geli on ${md}p1 to 30m"
  1507.  i=$((i + 1))
  1508. -geli attach -k tmp.key -p ${md}p1 || echo -n "not "
  1509. +
  1510. +geli attach -p -k $keyfile ${md}p1 || echo -n "not "
  1511.  echo ok $i - "Attached ${md}p1.eli"
  1512.  i=$((i + 1))
  1513.  
  1514.  geli detach ${md}p1.eli
  1515.  mdconfig -du$unit
  1516.  
  1517. -rm tmp.*
  1518. +rm -f $keyfile $meta
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement