freebsd-skq/sbin/bectl
kevans 5234db7610 bectl: use jail id as the default jail name for a boot environment
By default, bectl is setting the jail 'name' parameter to the boot
environment name, which causes an error when the boot environment name is
not a valid jail name. With the attached fix, when no name is supplied, the
default jail name will be the jail id - this is is the same behavior as the
jail command.

Additionally, this commit addresses two other bugs that prevented unjailing
in scenarios where the jail name does not match the boot environment name:

1. In 'bectl_locate_jail', 'mountpoint' is used to resolve the boot
  environment path, but really 'mounted' should be used. 'mountpoint' is the
  path where the zfs dataset will be mounted. 'mounted' is the path where
  the dataset is actually mounted.

2. in 'bectl_search_jail_paths', 'jail_getv' would fail after the first
  call. Which is fine, if the boot environment you're unjailing is the next
  one up. According to 'man jail_getv', it's expecting name and value
  strings. 'jail_getv' is being passed an integer for the lastjid, so amend
  that to use a string instead.

Test cases have been amended to reflect the bugs found.

PR:		233637
Submitted by:	Rob <rob.fx907_gmail.com>
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D18607
2018-12-25 15:18:41 +00:00
..
tests bectl: use jail id as the default jail name for a boot environment 2018-12-25 15:18:41 +00:00
bectl_jail.c bectl: use jail id as the default jail name for a boot environment 2018-12-25 15:18:41 +00:00
bectl_list.c bectl(8): Use strcmp, rather than trying to directly compare 2018-08-12 00:09:52 +00:00
bectl.8 bectl: use jail id as the default jail name for a boot environment 2018-12-25 15:18:41 +00:00
bectl.c bectl: sync usage with man page, removing stray multibyte characters 2018-11-26 15:11:32 +00:00
bectl.h bectl(8): Split list functionality out into its own file as well 2018-08-06 03:41:52 +00:00
Makefile bectl(8): Add some regression tests 2018-11-19 02:30:12 +00:00