aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_xxx.c
diff options
context:
space:
mode:
authorJamie Gritton <jamie@FreeBSD.org>2009-05-29 21:27:12 +0000
committerJamie Gritton <jamie@FreeBSD.org>2009-05-29 21:27:12 +0000
commit76ca6f88dab430fe415094fb54beb7eaa010d22e (patch)
tree36c53629863ffb1eb32354e9a24549059dd6273f /sys/kern/kern_xxx.c
parent88812d9e1dfe430d3387fb39f958373f40b079f2 (diff)
downloadsrc-76ca6f88dab430fe415094fb54beb7eaa010d22e.tar.gz
src-76ca6f88dab430fe415094fb54beb7eaa010d22e.zip
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)
Notes
Notes: svn path=/head/; revision=193066
Diffstat (limited to 'sys/kern/kern_xxx.c')
-rw-r--r--sys/kern/kern_xxx.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index e60d05ebb1fb..095e3ff882dc 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/utsname.h>
-#include <sys/vimage.h>
#include <vm/vm_param.h>
@@ -103,9 +102,13 @@ ogethostid(td, uap)
struct thread *td;
struct ogethostid_args *uap;
{
+ size_t len = sizeof(long);
+ int name[2];
- *(long *)(td->td_retval) = hostid;
- return (0);
+ name[0] = CTL_KERN;
+ name[1] = KERN_HOSTID;
+ return (kernel_sysctl(td, name, 2, (long *)td->td_retval, &len,
+ NULL, 0, NULL, 0));
}
#endif /* COMPAT_43 */
@@ -121,15 +124,12 @@ osethostid(td, uap)
struct thread *td;
struct osethostid_args *uap;
{
- int error;
+ int name[2];
- error = priv_check(td, PRIV_SETHOSTID);
- if (error)
- return (error);
- mtx_lock(&Giant);
- hostid = uap->hostid;
- mtx_unlock(&Giant);
- return (0);
+ name[0] = CTL_KERN;
+ name[1] = KERN_HOSTID;
+ return (kernel_sysctl(td, name, 2, NULL, NULL, &uap->hostid,
+ sizeof(uap->hostid), NULL, 0));
}
int