PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/usr/src/suites/nfs/nfsv4/tests/srv_namespc/clntspc_mnt06.ksh

https://bitbucket.org/illumos/illumos-stc
Korn Shell | 486 lines | 309 code | 86 blank | 91 comment | 93 complexity | 931a3f0b64670c00d9962be460fafbd2 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. #! /usr/bin/ksh -p
  2. #
  3. # CDDL HEADER START
  4. #
  5. # The contents of this file are subject to the terms of the
  6. # Common Development and Distribution License (the "License").
  7. # You may not use this file except in compliance with the License.
  8. #
  9. # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10. # or http://www.opensolaris.org/os/licensing.
  11. # See the License for the specific language governing permissions
  12. # and limitations under the License.
  13. #
  14. # When distributing Covered Code, include this CDDL HEADER in each
  15. # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16. # If applicable, add the following below this CDDL HEADER, with the
  17. # fields enclosed by brackets "[]" replaced with your own identifying
  18. # information: Portions Copyright [yyyy] [name of copyright owner]
  19. #
  20. # CDDL HEADER END
  21. #
  22. #
  23. # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. # ident "%Z%%M% %I% %E% SMI"
  27. #
  28. # NFSv4 client name space test - mounting symlink
  29. #
  30. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  31. NAME=`basename $0`
  32. CDIR=`pwd`
  33. NSPC=`echo $NAME | sed 's/./ /g'`
  34. # Source for common functions
  35. . $TESTROOT/testsh
  36. # check for root to run
  37. is_root $NAME "NFSv4 name space tests (mount symlink)."
  38. TMPmnt=$ZONE_PATH/$NAME.$$
  39. mkdir -m 0777 -p $TMPmnt
  40. allunsupp=0
  41. is_cipso "vers=4" $SERVER
  42. if [ $? -eq $CIPSO_NFSV4 ]; then
  43. cipso_check_mntpaths $BASEDIR $TMPmnt
  44. if [ $? -ne 0 ]; then
  45. allunsupp=1
  46. echo "$NAME: UNSUPPORTED"
  47. echo "$NAME: CIPSO NFSv4 requires non-global zone mount dirs."
  48. echo "$NSPC The server's BASEDIR and client's MNTPTR"
  49. echo "$NSPC must contain path legs with matching"
  50. echo "$NSPC non-global zone paths."
  51. echo "$NSPC: Please try again ..."
  52. fi
  53. fi
  54. # Start test assertions here
  55. # ----------------------------------------------------------------------
  56. # a: Verify mounting symlink dir in a shared FS, expect succeed
  57. function assertion_a
  58. {
  59. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  60. ASSERTION="Mounting symlink dir in a shared FS"
  61. ASSERTION="$ASSERTION, expect succeed"
  62. echo "$NAME{a}: $ASSERTION"
  63. if [ $allunsupp -eq 1 ]; then
  64. echo "\t Test UNSUPPORTED"
  65. return $FAIL
  66. fi
  67. # SRVPATH should be a symlink
  68. SRVPATH=$BASEDIR/$SYMLDIR/dir2
  69. # Test it with the mount on the $SRVPATH
  70. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  71. ckreturn $? "mount <vers=4,rw $SERVER:$SRVPATH> failed" $TMPDIR/$NAME.mnt.$$
  72. [ $? -ne 0 ] && return $FAIL
  73. # verify the mount point is access'ble
  74. ls -lL $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  75. ckreturn $? "unable to access the mnt-point after share" $TMPDIR/$NAME.ck.$$
  76. [ $? -ne 0 ] && return $FAIL
  77. # umount it
  78. umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  79. ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  80. [ $? -ne 0 ] && return $FAIL
  81. echo "\t Test PASS"
  82. }
  83. # b: Verify mounting symlink file (w/no perm) in a shared FS, expect succeed
  84. function assertion_b
  85. {
  86. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  87. ASSERTION="Mounting symlink file(w/no PERM) in shared FS"
  88. ASSERTION="$ASSERTION, expect succeed"
  89. echo "$NAME{b}: $ASSERTION"
  90. if [ $allunsupp -eq 1 ]; then
  91. echo "\t Test UNSUPPORTED"
  92. return $FAIL
  93. fi
  94. # SRVPATH should be a symlink to a file with mode=0000
  95. SRVPATH=$BASEDIR/$SYMNOPF
  96. # Test it with the mount on the $SRVPATH
  97. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  98. ckreturn $? "mount <vers=4,rw $SERVER:$SRVPATH> failed" $TMPDIR/$NAME.mnt.$$
  99. [ $? -ne 0 ] && return $FAIL
  100. # verify Getattr the mount point is correct
  101. ls -l $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  102. ckreturn $? "unable to Getattr mnt-point after share" $TMPDIR/$NAME.ck.$$
  103. [ $? -ne 0 ] && return $FAIL
  104. Mode=`awk '{print $1}' $TMPDIR/$NAME.ck.$$`
  105. if [[ $TestZFS = 1 ]]; then
  106. # ACL/xattr is set for FNOPERM
  107. expmode="----------+"
  108. else
  109. expmode="----------"
  110. fi
  111. if [ "$Mode" != $expmode ]; then
  112. echo "\t Test FAIL: file mode is incorrect"
  113. cat $TMPDIR/$NAME.ck.$$
  114. umount $TMPmnt
  115. return $FAIL
  116. fi
  117. # umount it
  118. umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  119. ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  120. [ $? -ne 0 ] && return $FAIL
  121. echo "\t Test PASS"
  122. }
  123. # c: Verify mounting symlink to nosuchdir, expect fail
  124. function assertion_c
  125. {
  126. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  127. ASSERTION="Mounting symlink to nosuch dir, expect fail"
  128. echo "$NAME{c}: $ASSERTION"
  129. if [ $allunsupp -eq 1 ]; then
  130. echo "\t Test UNSUPPORTED"
  131. return $FAIL
  132. fi
  133. # SRVPATH should be a symlink file
  134. SRVPATH=$BASEDIR/syml_nodir
  135. # Test it with the mount on the $SRVPATH, should fail
  136. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  137. if [ $? -eq 0 ]; then
  138. echo "\t Test FAIL: mounting <$SRVPATH> did not fail"
  139. cat $TMPDIR/$NAME.mnt.$$
  140. return $FAIL
  141. fi
  142. # verify the mount point is not NFS mounted
  143. df -F nfs $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  144. if [ $? -eq 0 ]; then
  145. echo "\t Test FAIL: mount point <$TMPmnt> should not be NFS"
  146. cat $TMPDIR/$NAME.ck.$$
  147. return $FAIL
  148. fi
  149. echo "\t Test PASS"
  150. }
  151. # d: Verify mounting symlink to out-of namespace dir(usr/lib), expect fail
  152. function assertion_d
  153. {
  154. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  155. ASSERTION="Mounting symlink to out-of namespace dir(usr/lib), expect fail"
  156. echo "$NAME{d}: $ASSERTION"
  157. if [ $allunsupp -eq 1 ]; then
  158. echo "\t Test UNSUPPORTED"
  159. return $FAIL
  160. fi
  161. # SRVPATH should be a symlink file
  162. SRVPATH=$BASEDIR/syml_outns
  163. # Test it with the mount on the $SRVPATH, should fail
  164. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  165. if [ $? -eq 0 ]; then
  166. echo "\t Test FAIL: mounting <$SRVPATH> did not fail"
  167. cat $TMPDIR/$NAME.mnt.$$
  168. return $FAIL
  169. fi
  170. # verify the mount point is not NFS mounted
  171. df -F nfs $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  172. if [ $? -eq 0 ]; then
  173. echo "\t Test FAIL: mount point <$TMPmnt> should not be NFS"
  174. cat $TMPDIR/$NAME.ck.$$
  175. return $FAIL
  176. fi
  177. echo "\t Test PASS"
  178. }
  179. # e: Verify mounting symlink to file in unshared cross-mount, expect fail
  180. # XXX this assertion may need to change when client cross-mount is available.
  181. function assertion_e
  182. {
  183. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  184. ASSERTION="Mounting symlink to file in unshared cross-mnt, expect fail"
  185. echo "$NAME{e}: $ASSERTION"
  186. if [ $allunsupp -eq 1 ]; then
  187. echo "\t Test UNSUPPORTED"
  188. return $FAIL
  189. fi
  190. # SRVPATH should be a symlink file
  191. SRVPATH=$BASEDIR/syml_nofile
  192. # Test it with the mount on the $SRVPATH, should fail
  193. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  194. if [ $? -eq 0 ]; then
  195. echo "\t Test FAIL: mounting <$SRVPATH> did not fail"
  196. cat $TMPDIR/$NAME.mnt.$$
  197. return $FAIL
  198. fi
  199. # verify the mount point is not NFS mounted
  200. df -F nfs $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  201. if [ $? -eq 0 ]; then
  202. echo "\t Test FAIL: mount point should not be NFS"
  203. cat $TMPDIR/$NAME.ck.$$
  204. return $FAIL
  205. fi
  206. echo "\t Test PASS"
  207. }
  208. # h: Verify mounting symlink to another shared FS, expect succeed
  209. function assertion_h
  210. {
  211. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  212. ASSERTION="Mounting symlink to another shared FS"
  213. ASSERTION="$ASSERTION, expect succeed"
  214. echo "$NAME{h}: $ASSERTION"
  215. if [ $allunsupp -eq 1 ]; then
  216. echo "\t Test UNSUPPORTED"
  217. return $FAIL
  218. fi
  219. # SRVPATH should be a symlink
  220. SRVPATH=$BASEDIR/syml_sh_fs
  221. # Test it with the mount on the $SRVPATH
  222. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  223. ckreturn $? "mount <vers=4,rw $SERVER:$SRVPATH> failed" $TMPDIR/$NAME.mnt.$$
  224. [ $? -ne 0 ] && return $FAIL
  225. # verify the mount point is access'ble
  226. ls -lL $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  227. ckreturn $? "unable to access the mnt-point after share" $TMPDIR/$NAME.ck.$$
  228. [ $? -ne 0 ] && return $FAIL
  229. # umount it
  230. umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  231. ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  232. [ $? -ne 0 ] && return $FAIL
  233. echo "\t Test PASS"
  234. }
  235. # i: Verify mounting symlink to a non-shared FS w/in shared node, expect succeed
  236. # XXX this assertion may need to change when client cross-mount is available.
  237. function assertion_i
  238. {
  239. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  240. ASSERTION="Mounting symlink to non-shared FS in shared node, expect succeed"
  241. echo "$NAME{i}: $ASSERTION"
  242. if [ $allunsupp -eq 1 ]; then
  243. echo "\t Test UNSUPPORTED"
  244. return $FAIL
  245. fi
  246. # SRVPATH should be a symlink file
  247. SRVPATH=$BASEDIR/syml_nosh_fs
  248. # Test it with the mount on the $SRVPATH, should OK as a dir
  249. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  250. ckreturn $? "mount <vers=4,rw $SERVER:$SRVPATH> failed" $TMPDIR/$NAME.mnt.$$
  251. [ $? -ne 0 ] && return $FAIL
  252. # verify client can't create file in it
  253. touch $TMPmnt/testfile.$$ > $TMPDIR/$NAME.ck.$$ 2>&1
  254. if [ $? -eq 0 ]; then
  255. echo "\t Test FAIL: mount point should not be writable"
  256. cat $TMPDIR/$NAME.ck.$$
  257. return $FAIL
  258. fi
  259. # umount it
  260. umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  261. ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  262. [ $? -ne 0 ] && return $FAIL
  263. echo "\t Test PASS"
  264. }
  265. # m: Verify mounting symlink dir w/relative path, expect succeed
  266. function assertion_m
  267. {
  268. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  269. ASSERTION="Mounting symlink dir with relative path"
  270. ASSERTION="$ASSERTION, expect succeed"
  271. echo "$NAME{m}: $ASSERTION"
  272. if [ $allunsupp -eq 1 ]; then
  273. echo "\t Test UNSUPPORTED"
  274. return $FAIL
  275. fi
  276. # SRVPATH should be a symlink
  277. SRVPATH=$BASEDIR/syml_dotd
  278. # Test it with the mount on the $SRVPATH
  279. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  280. ckreturn $? "mount <vers=4,rw $SERVER:$SRVPATH> failed" $TMPDIR/$NAME.mnt.$$
  281. [ $? -ne 0 ] && return $FAIL
  282. # verify the mount point is access'ble
  283. ls -lL $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  284. ckreturn $? "unable to access the mnt-point after unshare" $TMPDIR/$NAME.ck.$$
  285. [ $? -ne 0 ] && return $FAIL
  286. # umount it
  287. umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  288. ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  289. [ $? -ne 0 ] && return $FAIL
  290. echo "\t Test PASS"
  291. }
  292. # n: Verify mounting symlink file w/relative path (. & ..), expect succeed
  293. function assertion_n
  294. {
  295. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  296. ASSERTION="Mounting symlink file w/relative path (. & ..)"
  297. ASSERTION="$ASSERTION, expect succeed"
  298. echo "$NAME{n}: $ASSERTION"
  299. if [ $allunsupp -eq 1 ]; then
  300. echo "\t Test UNSUPPORTED"
  301. return $FAIL
  302. fi
  303. # SRVPATH should be a symlink
  304. SRVPATH=$BASEDIR/syml_dotf
  305. # Test it with the mount on the $SRVPATH
  306. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  307. ckreturn $? "mount <vers=4,rw $SERVER:$SRVPATH> failed" $TMPDIR/$NAME.mnt.$$
  308. [ $? -ne 0 ] && return $FAIL
  309. # verify the mount point is access'ble
  310. ls -lL $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  311. ckreturn $? "unable to access the mnt-point after unshare" $TMPDIR/$NAME.ck.$$
  312. [ $? -ne 0 ] && return $FAIL
  313. # umount it
  314. umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  315. ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  316. [ $? -ne 0 ] && return $FAIL
  317. echo "\t Test PASS"
  318. }
  319. # o: Verify mounting symlink dir w/.. of shared inside shared FS, expect succeed
  320. function assertion_o
  321. {
  322. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  323. ASSERTION="Mounting symlink dir w/.. of shared inside shared FS"
  324. ASSERTION="$ASSERTION, expect succeed"
  325. echo "$NAME{o}: $ASSERTION"
  326. if [ $allunsupp -eq 1 ]; then
  327. echo "\t Test UNSUPPORTED"
  328. return $FAIL
  329. fi
  330. # SRVPATH should be a symlink
  331. SRVPATH=$BASEDIR/syml_dotdot
  332. # Test it with the mount on the $SRVPATH
  333. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  334. ckreturn $? "mount <vers=4,rw $SERVER:$SRVPATH> failed" $TMPDIR/$NAME.mnt.$$
  335. [ $? -ne 0 ] && return $FAIL
  336. # verify the mount point is access'ble
  337. ls -lL $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  338. ckreturn $? "unable to access the mnt-point after unshare" $TMPDIR/$NAME.ck.$$
  339. [ $? -ne 0 ] && return $FAIL
  340. # umount it
  341. umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  342. ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  343. [ $? -ne 0 ] && return $FAIL
  344. echo "\t Test PASS"
  345. }
  346. # p: Verify mounting symlink to an absolute syml in shared FS, expect succeed
  347. function assertion_p
  348. {
  349. [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  350. ASSERTION="Mounting symlink to an absolute symlink in shared FS"
  351. ASSERTION="$ASSERTION, expect succeed"
  352. echo "$NAME{p}: $ASSERTION"
  353. if [ $allunsupp -eq 1 ]; then
  354. echo "\t Test UNSUPPORTED"
  355. return $FAIL
  356. fi
  357. # SRVPATH should be a symlink
  358. SRVPATH=$BASEDIR/symldir2
  359. # Test it with the mount on the $SRVPATH
  360. mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  361. ckreturn $? "mount <vers=4,rw $SERVER:$SRVPATH> failed" $TMPDIR/$NAME.mnt.$$
  362. [ $? -ne 0 ] && return $FAIL
  363. # verify the mount point is access'ble
  364. ls -lL $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
  365. ckreturn $? "unable to access the mnt-point after unshare" $TMPDIR/$NAME.ck.$$
  366. [ $? -ne 0 ] && return $FAIL
  367. # umount it
  368. umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  369. ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  370. [ $? -ne 0 ] && return $FAIL
  371. echo "\t Test PASS"
  372. }
  373. # Start main program here:
  374. # ----------------------------------------------------------------------
  375. assertion_a
  376. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  377. assertion_b
  378. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  379. assertion_c
  380. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  381. assertion_d
  382. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  383. assertion_e
  384. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  385. assertion_h
  386. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  387. assertion_i
  388. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  389. assertion_m
  390. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  391. assertion_n
  392. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  393. assertion_o
  394. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  395. assertion_p
  396. [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
  397. # cleanup here
  398. rmdir $TMPmnt
  399. rm -f $TMPDIR/$NAME.*.$$
  400. exit 0