Author: kevans
Date: Fri May 24 01:53:45 2019
New Revision: 348219
URL: https://svnweb.freebsd.org/changeset/base/348219

Log:
  bectl(8): Add a test for jail/unjail of numeric BE names
  
  Fixed by r348215, bectl ujail first attempts the trivial fetch of a jid by
  passing the first argument to 'ujail' to jail_getid(3) in case a jid/name
  have been passed in instead of a BE name. For numerically named BEs, this
  was doing the wrong thing: instead of failing to locate the jid specified
  and falling back to mountpath search, jail_getid(3) would return the input
  as-is.
  
  While here, I've fixed bectl_jail_cleanup which still used a hard-coded pool
  name that was overlooked w.r.t. other work that was in-flight around the
  same time.
  
  MFC after:    3 days

Modified:
  head/sbin/bectl/tests/bectl_test.sh

Modified: head/sbin/bectl/tests/bectl_test.sh
==============================================================================
--- head/sbin/bectl/tests/bectl_test.sh Fri May 24 01:51:58 2019        
(r348218)
+++ head/sbin/bectl/tests/bectl_test.sh Fri May 24 01:53:45 2019        
(r348219)
@@ -294,9 +294,16 @@ bectl_jail_body()
        atf_check cp /rescue/rescue ${root}/rescue/rescue
        atf_check bectl -r ${zpool}/ROOT umount default
 
-       # Prepare a second boot environment
+       # Prepare some more boot environments
        atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT create -e default 
target
+       atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT create -e default 
1234
 
+       # Attempt to unjail a BE with numeric name; jail_getid at one point
+       # did not validate that the input was a valid jid before returning the
+       # jid.
+       atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT jail -b 1234
+       atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT unjail 1234
+
        # When a jail name is not explicit, it should match the jail id.
        atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT jail -b -o 
jid=233637 default
        atf_check -o inline:"233637\n" -s exit:0 -x "jls -j 233637 name"
@@ -340,9 +347,10 @@ bectl_jail_body()
 # attempts to destroy the zpool.
 bectl_jail_cleanup()
 {
-       for bootenv in "default" "target"; do
+       zpool=$(get_zpool_name)
+       for bootenv in "default" "target" "1234"; do
                # mountpoint of the boot environment
-               mountpoint="$(bectl -r bectl_test/ROOT list -H | grep 
${bootenv} | awk '{print $3}')"
+               mountpoint="$(bectl -r ${zpool}/ROOT list -H | grep ${bootenv} 
| awk '{print $3}')"
 
                # see if any jail paths match the boot environment mountpoint
                jailid="$(jls | grep ${mountpoint} | awk '{print $1}')"
@@ -353,7 +361,7 @@ bectl_jail_cleanup()
                jail -r ${jailid}
        done;
 
-       bectl_cleanup $(get_zpool_name)
+       bectl_cleanup ${zpool}
 }
 
 atf_init_test_cases()
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to