Changeset View
Changeset View
Standalone View
Standalone View
head/sys/fs/nfs/nfs_commonsubs.c
Show All 36 Lines | |||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
/* | /* | ||||
* These functions support the macros and help fiddle mbuf chains for | * These functions support the macros and help fiddle mbuf chains for | ||||
* the nfs op functions. They do things like create the rpc header and | * the nfs op functions. They do things like create the rpc header and | ||||
* copy data between mbuf chains and uio lists. | * copy data between mbuf chains and uio lists. | ||||
*/ | */ | ||||
#ifndef APPLEKEXT | #ifndef APPLEKEXT | ||||
#include "opt_inet.h" | |||||
#include "opt_inet6.h" | #include "opt_inet6.h" | ||||
#include <fs/nfs/nfsport.h> | #include <fs/nfs/nfsport.h> | ||||
#include <security/mac/mac_framework.h> | #include <security/mac/mac_framework.h> | ||||
/* | /* | ||||
* Data items converted to xdr at startup, since they are constant | * Data items converted to xdr at startup, since they are constant | ||||
▲ Show 20 Lines • Show All 3,446 Lines • ▼ Show 20 Lines | nfsrv_cmpmixedcase(u_char *cp, u_char *cp2, int len) | ||||
else | else | ||||
return (1); | return (1); | ||||
} | } | ||||
/* | /* | ||||
* Set the port for the nfsuserd. | * Set the port for the nfsuserd. | ||||
*/ | */ | ||||
APPLESTATIC int | APPLESTATIC int | ||||
nfsrv_nfsuserdport(u_short port, NFSPROC_T *p) | nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPROC_T *p) | ||||
{ | { | ||||
struct nfssockreq *rp; | struct nfssockreq *rp; | ||||
#ifdef INET | |||||
struct sockaddr_in *ad; | struct sockaddr_in *ad; | ||||
#endif | |||||
#ifdef INET6 | |||||
struct sockaddr_in6 *ad6; | |||||
const struct in6_addr in6loopback = IN6ADDR_LOOPBACK_INIT; | |||||
#endif | |||||
int error; | int error; | ||||
NFSLOCKNAMEID(); | NFSLOCKNAMEID(); | ||||
if (nfsrv_nfsuserd) { | if (nfsrv_nfsuserd) { | ||||
NFSUNLOCKNAMEID(); | NFSUNLOCKNAMEID(); | ||||
error = EPERM; | error = EPERM; | ||||
goto out; | goto out; | ||||
} | } | ||||
nfsrv_nfsuserd = 1; | nfsrv_nfsuserd = 1; | ||||
NFSUNLOCKNAMEID(); | NFSUNLOCKNAMEID(); | ||||
/* | /* | ||||
* Set up the socket record and connect. | * Set up the socket record and connect. | ||||
*/ | */ | ||||
rp = &nfsrv_nfsuserdsock; | rp = &nfsrv_nfsuserdsock; | ||||
rp->nr_client = NULL; | rp->nr_client = NULL; | ||||
rp->nr_sotype = SOCK_DGRAM; | rp->nr_sotype = SOCK_DGRAM; | ||||
rp->nr_soproto = IPPROTO_UDP; | rp->nr_soproto = IPPROTO_UDP; | ||||
rp->nr_lock = (NFSR_RESERVEDPORT | NFSR_LOCALHOST); | rp->nr_lock = (NFSR_RESERVEDPORT | NFSR_LOCALHOST); | ||||
rp->nr_cred = NULL; | rp->nr_cred = NULL; | ||||
rp->nr_nam = malloc(sizeof(*rp->nr_nam), M_SONAME, M_WAITOK | M_ZERO); | |||||
NFSSOCKADDRSIZE(rp->nr_nam, sizeof (struct sockaddr_in)); | |||||
ad = NFSSOCKADDR(rp->nr_nam, struct sockaddr_in *); | |||||
ad->sin_family = AF_INET; | |||||
ad->sin_addr.s_addr = htonl((u_int32_t)0x7f000001); /* 127.0.0.1 */ | |||||
ad->sin_port = port; | |||||
rp->nr_prog = RPCPROG_NFSUSERD; | rp->nr_prog = RPCPROG_NFSUSERD; | ||||
error = 0; | |||||
switch (nargs->nuserd_family) { | |||||
#ifdef INET | |||||
case AF_INET: | |||||
rp->nr_nam = malloc(sizeof(struct sockaddr_in), M_SONAME, | |||||
M_WAITOK | M_ZERO); | |||||
ad = (struct sockaddr_in *)rp->nr_nam; | |||||
ad->sin_len = sizeof(struct sockaddr_in); | |||||
ad->sin_family = AF_INET; | |||||
ad->sin_addr.s_addr = htonl(INADDR_LOOPBACK); | |||||
ad->sin_port = nargs->nuserd_port; | |||||
break; | |||||
#endif | |||||
#ifdef INET6 | |||||
case AF_INET6: | |||||
rp->nr_nam = malloc(sizeof(struct sockaddr_in6), M_SONAME, | |||||
M_WAITOK | M_ZERO); | |||||
ad6 = (struct sockaddr_in6 *)rp->nr_nam; | |||||
ad6->sin6_len = sizeof(struct sockaddr_in6); | |||||
ad6->sin6_family = AF_INET6; | |||||
ad6->sin6_addr = in6loopback; | |||||
ad6->sin6_port = nargs->nuserd_port; | |||||
break; | |||||
#endif | |||||
default: | |||||
error = ENXIO; | |||||
} | |||||
rp->nr_vers = RPCNFSUSERD_VERS; | rp->nr_vers = RPCNFSUSERD_VERS; | ||||
if (error == 0) | |||||
error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0); | error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0); | ||||
if (error) { | if (error) { | ||||
free(rp->nr_nam, M_SONAME); | free(rp->nr_nam, M_SONAME); | ||||
nfsrv_nfsuserd = 0; | nfsrv_nfsuserd = 0; | ||||
} | } | ||||
out: | out: | ||||
NFSEXITCODE(error); | NFSEXITCODE(error); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,159 Lines • Show Last 20 Lines |