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/rpc/authunix_prot.c | |
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/rpc/authunix_prot.c')
-rw-r--r-- | sys/rpc/authunix_prot.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/sys/rpc/authunix_prot.c b/sys/rpc/authunix_prot.c index eb75e2d..fc03dff 100644 --- a/sys/rpc/authunix_prot.c +++ b/sys/rpc/authunix_prot.c @@ -44,12 +44,10 @@ __FBSDID("$FreeBSD$"); */ #include <sys/param.h> +#include <sys/jail.h> #include <sys/kernel.h> -#include <sys/lock.h> -#include <sys/mutex.h> #include <sys/systm.h> #include <sys/ucred.h> -#include <sys/vimage.h> #include <rpc/types.h> #include <rpc/xdr.h> @@ -69,14 +67,14 @@ xdr_authunix_parms(XDR *xdrs, uint32_t *time, struct xucred *cred) uint32_t namelen; uint32_t ngroups, i; uint32_t junk; - INIT_VPROCG(TD_TO_VPROCG(&thread0)); /* XXX revisit - fixme! */ + char hostbuf[MAXHOSTNAMELEN]; - mtx_lock(&hostname_mtx); if (xdrs->x_op == XDR_ENCODE) { /* * Restrict name length to 255 according to RFC 1057. */ - namelen = strlen(V_hostname); + getcredhostname(NULL, hostbuf, sizeof(hostbuf)); + namelen = strlen(hostbuf); if (namelen > 255) namelen = 255; } else { @@ -92,12 +90,11 @@ xdr_authunix_parms(XDR *xdrs, uint32_t *time, struct xucred *cred) * Ignore the hostname on decode. */ if (xdrs->x_op == XDR_ENCODE) { - if (!xdr_opaque(xdrs, V_hostname, namelen)) + if (!xdr_opaque(xdrs, hostbuf, namelen)) return (FALSE); } else { xdr_setpos(xdrs, xdr_getpos(xdrs) + RNDUP(namelen)); } - mtx_unlock(&hostname_mtx); if (!xdr_uint32_t(xdrs, &cred->cr_uid)) return (FALSE); |