]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r348215, r348219: fix bectl(8) jail w/ numeric BE names
authorkevans <kevans@FreeBSD.org>
Mon, 27 May 2019 13:12:51 +0000 (13:12 +0000)
committerkevans <kevans@FreeBSD.org>
Mon, 27 May 2019 13:12:51 +0000 (13:12 +0000)
commit760841f9c8a410006fa4a9369fc66a6863146797
treec20c4aac5b018ce502ce2665984df8b8579c1527
parented66cf9542b42240ade32a2b19e60e859a81a325
MFC r348215, r348219: fix bectl(8) jail w/ numeric BE names

r348215:
jail_getid(3): validate jid string input

Currently, if jail_getid(3) is passed in a numeric string, it assumes that
this is a jid string and passes it back converted to an int without checking
that it's a valid/existing jid. This breaks consumers that might use
jail_getid(3) to see if it can trivially grab a jid from a name if that name
happens to be numeric but not actually the name/jid of the jail. Instead of
returning -1 for the jail not existing, it'll return the int version of the
input and the consumer will not fallback to trying other methods.

Pass the numeric input to jail_get(2) as the jid for validation, rather than
the name. This works well- the kernel enforces that jid=name if name is
numeric, so doing the safe thing and checking numeric input as a jid will
still DTRT based on the description of jail_getid.

r348219:
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.

Approved by: re (marius)
lib/libjail/jail_getid.c
sbin/bectl/tests/bectl_test.sh