summaryrefslogtreecommitdiffstats
path: root/sys/contrib/ipfilter/netinet
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2009-05-27 14:11:23 +0000
committerjamie <jamie@FreeBSD.org>2009-05-27 14:11:23 +0000
commita013e0afcbb44052a86a7977277d669d8883b7e7 (patch)
treeb7f782d79e61a1bd80655a068684cb0fd9f39922 /sys/contrib/ipfilter/netinet
parent6e53147404a7f4fb4173694bc812d9d23efd9fef (diff)
downloadFreeBSD-src-a013e0afcbb44052a86a7977277d669d8883b7e7.zip
FreeBSD-src-a013e0afcbb44052a86a7977277d669d8883b7e7.tar.gz
Add hierarchical jails. A jail may further virtualize its environment
by creating a child jail, which is visible to that jail and to any parent jails. Child jails may be restricted more than their parents, but never less. Jail names reflect this hierarchy, being MIB-style dot-separated strings. Every thread now points to a jail, the default being prison0, which contains information about the physical system. Prison0's root directory is the same as rootvnode; its hostname is the same as the global hostname, and its securelevel replaces the global securelevel. Note that the variable "securelevel" has actually gone away, which should not cause any problems for code that properly uses securelevel_gt() and securelevel_ge(). Some jail-related permissions that were kept in global variables and set via sysctls are now per-jail settings. The sysctls still exist for backward compatibility, used only by the now-deprecated jail(2) system call. Approved by: bz (mentor)
Diffstat (limited to 'sys/contrib/ipfilter/netinet')
-rw-r--r--sys/contrib/ipfilter/netinet/ip_fil_freebsd.c6
-rw-r--r--sys/contrib/ipfilter/netinet/ip_nat.c4
2 files changed, 10 insertions, 0 deletions
diff --git a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
index fee97c5..3e0e633 100644
--- a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
+++ b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
@@ -318,8 +318,10 @@ int iplioctl(dev, cmd, data, mode
# if (__FreeBSD_version >= 500024)
struct thread *p;
# if (__FreeBSD_version >= 500043)
+# define p_cred td_ucred
# define p_uid td_ucred->cr_ruid
# else
+# define p_cred t_proc->p_cred
# define p_uid t_proc->p_cred->p_ruid
# endif
# else
@@ -342,7 +344,11 @@ int mode;
SPL_INT(s);
#if (BSD >= 199306) && defined(_KERNEL)
+# if (__FreeBSD_version >= 500034)
+ if (securelevel_ge(p->p_cred, 3) && (mode & FWRITE))
+# else
if ((securelevel >= 3) && (mode & FWRITE))
+# endif
return EPERM;
#endif
diff --git a/sys/contrib/ipfilter/netinet/ip_nat.c b/sys/contrib/ipfilter/netinet/ip_nat.c
index d6f0b55..f790c7d 100644
--- a/sys/contrib/ipfilter/netinet/ip_nat.c
+++ b/sys/contrib/ipfilter/netinet/ip_nat.c
@@ -662,7 +662,11 @@ void *ctx;
return EPERM;
}
# else
+# if defined(__FreeBSD_version) && (__FreeBSD_version >= 500034)
+ if (securelevel_ge(curthread->td_ucred, 3) && (mode & FWRITE)) {
+# else
if ((securelevel >= 3) && (mode & FWRITE)) {
+# endif
return EPERM;
}
# endif
OpenPOWER on IntegriCloud