MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sysctl_jail_default_allow

Function sysctl_jail_default_allow

freebsd/kern/kern_jail.c:3844–3873  ·  view source on GitHub ↗

* Default parameters for jail(2) compatibility. For historical reasons, * the sysctl names have varying similarity to the parameter names. Prisons * just see their own parameters, and can't change them. */

Source from the content-addressed store, hash-verified

3842 * just see their own parameters, and can't change them.
3843 */
3844static int
3845sysctl_jail_default_allow(SYSCTL_HANDLER_ARGS)
3846{
3847 int error, i;
3848
3849 /* Get the current flag value, and convert it to a boolean. */
3850 if (req->td->td_ucred->cr_prison == &prison0) {
3851 mtx_lock(&prison0.pr_mtx);
3852 i = (jail_default_allow & arg2) != 0;
3853 mtx_unlock(&prison0.pr_mtx);
3854 } else
3855 i = prison_allow(req->td->td_ucred, arg2);
3856
3857 if (arg1 != NULL)
3858 i = !i;
3859 error = sysctl_handle_int(oidp, &i, 0, req);
3860 if (error || !req->newptr)
3861 return (error);
3862 i = i ? arg2 : 0;
3863 if (arg1 != NULL)
3864 i ^= arg2;
3865 /*
3866 * The sysctls don't have CTLFLAGS_PRISON, so assume prison0
3867 * for writing.
3868 */
3869 mtx_lock(&prison0.pr_mtx);
3870 jail_default_allow = (jail_default_allow & ~arg2) | i;
3871 mtx_unlock(&prison0.pr_mtx);
3872 return (0);
3873}
3874
3875SYSCTL_PROC(_security_jail, OID_AUTO, set_hostname_allowed,
3876 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,

Callers

nothing calls this directly

Calls 4

prison_allowFunction · 0.85
sysctl_handle_intFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected