summaryrefslogtreecommitdiffstats
path: root/sys/i386/ibcs2
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2009-05-29 21:27:12 +0000
committerjamie <jamie@FreeBSD.org>2009-05-29 21:27:12 +0000
commit572db1408a55640213faa331981d20cda01f68d8 (patch)
tree36c53629863ffb1eb32354e9a24549059dd6273f /sys/i386/ibcs2
parent64785ac65985d6800df1bacd80b5a3ba30b36b27 (diff)
downloadFreeBSD-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/i386/ibcs2')
-rw-r--r--sys/i386/ibcs2/ibcs2_socksys.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/sys/i386/ibcs2/ibcs2_socksys.c b/sys/i386/ibcs2/ibcs2_socksys.c
index 2dba77d..eb0559e 100644
--- a/sys/i386/ibcs2/ibcs2_socksys.c
+++ b/sys/i386/ibcs2/ibcs2_socksys.c
@@ -31,10 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysproto.h>
#include <sys/jail.h>
#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
#include <sys/sysctl.h>
-#include <sys/vimage.h>
#include <i386/ibcs2/ibcs2_socksys.h>
#include <i386/ibcs2/ibcs2_util.h>
@@ -152,7 +149,7 @@ ibcs2_getipdomainname(td, uap)
char hname[MAXHOSTNAMELEN], *dptr;
int len;
- /* Get the domain name */
+ /* Get the domain name. */
getcredhostname(td->td_ucred, hname, sizeof(hname));
dptr = index(hname, '.');
@@ -174,20 +171,17 @@ ibcs2_setipdomainname(td, uap)
struct thread *td;
struct setipdomainname_args *uap;
{
- INIT_VPROCG(TD_TO_VPROCG(td));
char hname[MAXHOSTNAMELEN], *ptr;
int error, sctl[2], hlen;
+ /* Get the domain name */
+ getcredhostname(td->td_ucred, hname, sizeof(hname));
+
/* W/out a hostname a domain-name is nonsense */
- mtx_lock(&hostname_mtx);
- if ( strlen(V_hostname) == 0 ) {
- mtx_unlock(&hostname_mtx);
+ if ( strlen(hname) == 0 )
return EINVAL;
- }
/* Get the host's unqualified name (strip off the domain) */
- snprintf(hname, sizeof(hname), "%s", V_hostname);
- mtx_unlock(&hostname_mtx);
ptr = index(hname, '.');
if ( ptr != NULL ) {
ptr++;
OpenPOWER on IntegriCloud