2008-03-26 15:23:12 +00:00
|
|
|
/*-
|
2017-11-27 15:23:17 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2008-03-26 15:23:12 +00:00
|
|
|
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
|
|
|
|
* Authors: Doug Rabson <dfr@rabson.org>
|
|
|
|
* Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
|
|
|
|
#include <rpc/types.h>
|
|
|
|
#include <rpc/xdr.h>
|
|
|
|
|
|
|
|
static void xdrmbuf_destroy(XDR *);
|
|
|
|
static bool_t xdrmbuf_getlong(XDR *, long *);
|
|
|
|
static bool_t xdrmbuf_putlong(XDR *, const long *);
|
|
|
|
static bool_t xdrmbuf_getbytes(XDR *, char *, u_int);
|
|
|
|
static bool_t xdrmbuf_putbytes(XDR *, const char *, u_int);
|
|
|
|
/* XXX: w/64-bit pointers, u_int not enough! */
|
|
|
|
static u_int xdrmbuf_getpos(XDR *);
|
|
|
|
static bool_t xdrmbuf_setpos(XDR *, u_int);
|
|
|
|
static int32_t *xdrmbuf_inline(XDR *, u_int);
|
|
|
|
|
|
|
|
static const struct xdr_ops xdrmbuf_ops = {
|
|
|
|
xdrmbuf_getlong,
|
|
|
|
xdrmbuf_putlong,
|
|
|
|
xdrmbuf_getbytes,
|
|
|
|
xdrmbuf_putbytes,
|
|
|
|
xdrmbuf_getpos,
|
|
|
|
xdrmbuf_setpos,
|
|
|
|
xdrmbuf_inline,
|
|
|
|
xdrmbuf_destroy
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The procedure xdrmbuf_create initializes a stream descriptor for a
|
|
|
|
* mbuf.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xdrmbuf_create(XDR *xdrs, struct mbuf *m, enum xdr_op op)
|
|
|
|
{
|
|
|
|
|
2008-11-13 14:36:52 +00:00
|
|
|
KASSERT(m != NULL, ("xdrmbuf_create with NULL mbuf chain"));
|
2008-03-26 15:23:12 +00:00
|
|
|
xdrs->x_op = op;
|
|
|
|
xdrs->x_ops = &xdrmbuf_ops;
|
|
|
|
xdrs->x_base = (char *) m;
|
|
|
|
if (op == XDR_ENCODE) {
|
|
|
|
m = m_last(m);
|
|
|
|
xdrs->x_private = m;
|
|
|
|
xdrs->x_handy = m->m_len;
|
|
|
|
} else {
|
|
|
|
xdrs->x_private = m;
|
|
|
|
xdrs->x_handy = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
void
|
|
|
|
xdrmbuf_append(XDR *xdrs, struct mbuf *madd)
|
|
|
|
{
|
|
|
|
struct mbuf *m;
|
|
|
|
|
|
|
|
KASSERT(xdrs->x_ops == &xdrmbuf_ops && xdrs->x_op == XDR_ENCODE,
|
|
|
|
("xdrmbuf_append: invalid XDR stream"));
|
|
|
|
|
|
|
|
if (m_length(madd, NULL) == 0) {
|
|
|
|
m_freem(madd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m = (struct mbuf *) xdrs->x_private;
|
|
|
|
m->m_next = madd;
|
|
|
|
|
|
|
|
m = m_last(madd);
|
|
|
|
xdrs->x_private = m;
|
|
|
|
xdrs->x_handy = m->m_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mbuf *
|
|
|
|
xdrmbuf_getall(XDR *xdrs)
|
|
|
|
{
|
|
|
|
struct mbuf *m0, *m;
|
|
|
|
|
|
|
|
KASSERT(xdrs->x_ops == &xdrmbuf_ops && xdrs->x_op == XDR_DECODE,
|
|
|
|
("xdrmbuf_append: invalid XDR stream"));
|
|
|
|
|
|
|
|
m0 = (struct mbuf *) xdrs->x_base;
|
|
|
|
m = (struct mbuf *) xdrs->x_private;
|
|
|
|
if (m0 != m) {
|
|
|
|
while (m0->m_next != m)
|
|
|
|
m0 = m0->m_next;
|
|
|
|
m0->m_next = NULL;
|
|
|
|
xdrs->x_private = NULL;
|
|
|
|
} else {
|
|
|
|
xdrs->x_base = NULL;
|
|
|
|
xdrs->x_private = NULL;
|
|
|
|
}
|
|
|
|
|
2008-11-05 16:24:31 +00:00
|
|
|
if (m)
|
|
|
|
m_adj(m, xdrs->x_handy);
|
|
|
|
else
|
2013-03-15 10:21:18 +00:00
|
|
|
m = m_get(M_WAITOK, MT_DATA);
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
return (m);
|
|
|
|
}
|
|
|
|
|
2008-03-26 15:23:12 +00:00
|
|
|
static void
|
|
|
|
xdrmbuf_destroy(XDR *xdrs)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (xdrs->x_op == XDR_DECODE && xdrs->x_base) {
|
|
|
|
m_freem((struct mbuf *) xdrs->x_base);
|
|
|
|
xdrs->x_base = NULL;
|
|
|
|
xdrs->x_private = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool_t
|
|
|
|
xdrmbuf_getlong(XDR *xdrs, long *lp)
|
|
|
|
{
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
int32_t *p;
|
2008-03-26 15:23:12 +00:00
|
|
|
int32_t t;
|
|
|
|
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
p = xdrmbuf_inline(xdrs, sizeof(int32_t));
|
|
|
|
if (p) {
|
|
|
|
t = *p;
|
|
|
|
} else {
|
|
|
|
xdrmbuf_getbytes(xdrs, (char *) &t, sizeof(int32_t));
|
|
|
|
}
|
|
|
|
|
2008-03-26 15:23:12 +00:00
|
|
|
*lp = ntohl(t);
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool_t
|
|
|
|
xdrmbuf_putlong(xdrs, lp)
|
|
|
|
XDR *xdrs;
|
|
|
|
const long *lp;
|
|
|
|
{
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
int32_t *p;
|
2008-03-26 15:23:12 +00:00
|
|
|
int32_t t = htonl(*lp);
|
|
|
|
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
p = xdrmbuf_inline(xdrs, sizeof(int32_t));
|
|
|
|
if (p) {
|
|
|
|
*p = t;
|
|
|
|
return (TRUE);
|
|
|
|
} else {
|
|
|
|
return (xdrmbuf_putbytes(xdrs, (char *) &t, sizeof(int32_t)));
|
|
|
|
}
|
2008-03-26 15:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool_t
|
|
|
|
xdrmbuf_getbytes(XDR *xdrs, char *addr, u_int len)
|
|
|
|
{
|
|
|
|
struct mbuf *m = (struct mbuf *) xdrs->x_private;
|
|
|
|
size_t sz;
|
|
|
|
|
|
|
|
while (len > 0) {
|
|
|
|
/*
|
|
|
|
* Make sure we haven't hit the end.
|
|
|
|
*/
|
|
|
|
if (!m) {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See how much we can get from this mbuf.
|
|
|
|
*/
|
|
|
|
sz = m->m_len - xdrs->x_handy;
|
|
|
|
if (sz > len)
|
|
|
|
sz = len;
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
bcopy(mtod(m, const char *) + xdrs->x_handy, addr, sz);
|
2008-03-26 15:23:12 +00:00
|
|
|
|
|
|
|
addr += sz;
|
|
|
|
xdrs->x_handy += sz;
|
|
|
|
len -= sz;
|
|
|
|
|
|
|
|
if (xdrs->x_handy == m->m_len) {
|
|
|
|
m = m->m_next;
|
|
|
|
xdrs->x_private = (void *) m;
|
|
|
|
xdrs->x_handy = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool_t
|
|
|
|
xdrmbuf_putbytes(XDR *xdrs, const char *addr, u_int len)
|
|
|
|
{
|
|
|
|
struct mbuf *m = (struct mbuf *) xdrs->x_private;
|
|
|
|
struct mbuf *n;
|
|
|
|
size_t sz;
|
|
|
|
|
|
|
|
while (len > 0) {
|
|
|
|
sz = M_TRAILINGSPACE(m) + (m->m_len - xdrs->x_handy);
|
|
|
|
if (sz > len)
|
|
|
|
sz = len;
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
bcopy(addr, mtod(m, char *) + xdrs->x_handy, sz);
|
2008-03-26 15:23:12 +00:00
|
|
|
addr += sz;
|
|
|
|
xdrs->x_handy += sz;
|
|
|
|
if (xdrs->x_handy > m->m_len)
|
|
|
|
m->m_len = xdrs->x_handy;
|
|
|
|
len -= sz;
|
|
|
|
|
|
|
|
if (xdrs->x_handy == m->m_len && M_TRAILINGSPACE(m) == 0) {
|
|
|
|
if (!m->m_next) {
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
if (m->m_flags & M_EXT)
|
2013-03-15 10:21:18 +00:00
|
|
|
n = m_getcl(M_WAITOK, m->m_type, 0);
|
|
|
|
else
|
|
|
|
n = m_get(M_WAITOK, m->m_type);
|
2008-03-26 15:23:12 +00:00
|
|
|
m->m_next = n;
|
|
|
|
}
|
|
|
|
m = m->m_next;
|
|
|
|
xdrs->x_private = (void *) m;
|
|
|
|
xdrs->x_handy = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u_int
|
|
|
|
xdrmbuf_getpos(XDR *xdrs)
|
|
|
|
{
|
|
|
|
struct mbuf *m0 = (struct mbuf *) xdrs->x_base;
|
|
|
|
struct mbuf *m = (struct mbuf *) xdrs->x_private;
|
|
|
|
u_int pos = 0;
|
|
|
|
|
|
|
|
while (m0 && m0 != m) {
|
|
|
|
pos += m0->m_len;
|
|
|
|
m0 = m0->m_next;
|
|
|
|
}
|
|
|
|
KASSERT(m0, ("Corrupted mbuf chain"));
|
|
|
|
|
|
|
|
return (pos + xdrs->x_handy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool_t
|
|
|
|
xdrmbuf_setpos(XDR *xdrs, u_int pos)
|
|
|
|
{
|
|
|
|
struct mbuf *m = (struct mbuf *) xdrs->x_base;
|
|
|
|
|
|
|
|
while (m && pos > m->m_len) {
|
|
|
|
pos -= m->m_len;
|
|
|
|
m = m->m_next;
|
|
|
|
}
|
|
|
|
KASSERT(m, ("Corrupted mbuf chain"));
|
|
|
|
|
|
|
|
xdrs->x_private = (void *) m;
|
|
|
|
xdrs->x_handy = pos;
|
|
|
|
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t *
|
|
|
|
xdrmbuf_inline(XDR *xdrs, u_int len)
|
|
|
|
{
|
|
|
|
struct mbuf *m = (struct mbuf *) xdrs->x_private;
|
|
|
|
size_t available;
|
|
|
|
char *p;
|
|
|
|
|
2009-08-12 16:27:51 +00:00
|
|
|
if (!m)
|
|
|
|
return (0);
|
2008-03-26 15:23:12 +00:00
|
|
|
if (xdrs->x_op == XDR_ENCODE) {
|
|
|
|
available = M_TRAILINGSPACE(m) + (m->m_len - xdrs->x_handy);
|
|
|
|
} else {
|
|
|
|
available = m->m_len - xdrs->x_handy;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (available >= len) {
|
|
|
|
p = mtod(m, char *) + xdrs->x_handy;
|
|
|
|
if (((uintptr_t) p) & (sizeof(int32_t) - 1))
|
|
|
|
return (0);
|
|
|
|
xdrs->x_handy += len;
|
|
|
|
if (xdrs->x_handy > m->m_len)
|
|
|
|
m->m_len = xdrs->x_handy;
|
|
|
|
return ((int32_t *) p);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|