diff options
author | jamie <jamie@FreeBSD.org> | 2009-05-29 21:27:12 +0000 |
---|---|---|
committer | jamie <jamie@FreeBSD.org> | 2009-05-29 21:27:12 +0000 |
commit | 572db1408a55640213faa331981d20cda01f68d8 (patch) | |
tree | 36c53629863ffb1eb32354e9a24549059dd6273f /sys/compat | |
parent | 64785ac65985d6800df1bacd80b5a3ba30b36b27 (diff) | |
download | FreeBSD-src-572db1408a55640213faa331981d20cda01f68d8.zip FreeBSD-src-572db1408a55640213faa331981d20cda01f68d8.tar.gz |
Place hostnames and similar information fully under the prison system.
The system hostname is now stored in prison0, and the global variable
"hostname" has been removed, as has the hostname_mtx mutex. Jails may
have their own host information, or they may inherit it from the
parent/system. The proper way to read the hostname is via
getcredhostname(), which will copy either the hostname associated with
the passed cred, or the system hostname if you pass NULL. The system
hostname can still be accessed directly (and without locking) at
prison0.pr_host, but that should be avoided where possible.
The "similar information" referred to is domainname, hostid, and
hostuuid, which have also become prison parameters and had their
associated global variables removed.
Approved by: bz (mentor)
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 10 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_stat.c | 20 |
2 files changed, 15 insertions, 15 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 7279197..dc8edf5 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$"); #include <sys/vnode.h> #include <sys/wait.h> #include <sys/cpuset.h> -#include <sys/vimage.h> #include <security/mac/mac_framework.h> @@ -715,10 +714,10 @@ linux_times(struct thread *td, struct linux_times_args *args) int linux_newuname(struct thread *td, struct linux_newuname_args *args) { - INIT_VPROCG(TD_TO_VPROCG(td)); struct l_new_utsname utsname; char osname[LINUX_MAX_UTSNAME]; char osrelease[LINUX_MAX_UTSNAME]; + struct prison *pr; char *p; #ifdef DEBUG @@ -741,9 +740,10 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args) } strlcpy(utsname.machine, linux_platform, LINUX_MAX_UTSNAME); - mtx_lock(&hostname_mtx); - strlcpy(utsname.domainname, V_domainname, LINUX_MAX_UTSNAME); - mtx_unlock(&hostname_mtx); + pr = td->td_ucred->cr_prison; + mtx_lock(&pr->pr_mtx); + strlcpy(utsname.domainname, pr->pr_domain, LINUX_MAX_UTSNAME); + mtx_unlock(&pr->pr_mtx); return (copyout(&utsname, args->buf, sizeof(utsname))); } diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c index 8c7b9b8..42e6122 100644 --- a/sys/compat/svr4/svr4_stat.c +++ b/sys/compat/svr4/svr4_stat.c @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #include <sys/sysproto.h> #include <sys/un.h> -#include <sys/vimage.h> #include <vm/vm.h> @@ -386,7 +385,7 @@ svr4_ustat(td, uap) return 0; } -/*extern char ostype[], hostname[], osrelease[], version[], machine[];*/ +/*extern char ostype[], osrelease[], version[], machine[];*/ int svr4_sys_uname(td, uap) @@ -412,15 +411,12 @@ svr4_sys_systeminfo(td, uap) struct thread *td; struct svr4_sys_systeminfo_args *uap; { - INIT_VPROCG(TD_TO_VPROCG(td)); + struct prison *pr; char *str = NULL; int error = 0; register_t *retval = td->td_retval; size_t len = 0; - char buf[11]; /* XXX NetBSD uses 256, but we use 11 - here as that seems like awfully - excessive kstack usage for hostid - string... */ + char buf[MAXHOSTNAMELEN]; u_int rlen = uap->len; switch (uap->what) { @@ -429,7 +425,8 @@ svr4_sys_systeminfo(td, uap) break; case SVR4_SI_HOSTNAME: - str = V_hostname; + getcredhostname(td->td_ucred, buf, sizeof(buf)); + str = buf; break; case SVR4_SI_RELEASE: @@ -470,8 +467,11 @@ svr4_sys_systeminfo(td, uap) break; case SVR4_SI_SRPC_DOMAIN: - /* XXXRW: locking? */ - str = V_domainname; + pr = td->td_ucred->cr_prison; + mtx_lock(&pr->pr_mtx); + strlcpy(buf, pr->pr_domain, sizeof(buf)); + mtx_unlock(&pr->pr_mtx); + str = buf; break; case SVR4_SI_PLATFORM: |