NetBSD/lib/libc/sys/nfssvc.2

196 lines
5.6 KiB
Groff
Raw Normal View History

2009-03-11 00:00:47 +03:00
.\" $NetBSD: nfssvc.2,v 1.24 2009/03/10 21:00:47 joerg Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
1993-03-21 12:45:37 +03:00
.\"
.\" 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.
.\" 3. Neither the name of the University nor the names of its contributors
1993-03-21 12:45:37 +03:00
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
.\"
.\" @(#)nfssvc.2 8.1 (Berkeley) 6/9/93
1993-03-21 12:45:37 +03:00
.\"
2006-12-30 01:56:55 +03:00
.Dd December 30, 2006
1993-03-21 12:45:37 +03:00
.Dt NFSSVC 2
.Os
.Sh NAME
.Nm nfssvc
.Nd NFS services
.Sh LIBRARY
.Lb libc
1993-03-21 12:45:37 +03:00
.Sh SYNOPSIS
.In unistd.h
.In nfs/nfs.h
1993-03-21 12:45:37 +03:00
.Ft int
.Fn nfssvc "int flags" "void *argstructp"
1993-03-21 12:45:37 +03:00
.Sh DESCRIPTION
The
.Fn nfssvc
function is used by the NFS daemons to pass information into and out
of the kernel and also to enter the kernel as a server daemon.
The
.Fa flags
argument consists of several bits that show what action is to be taken
once in the kernel and the
.Fa argstructp
points to one of three structures depending on which bits are set in
flags.
Apply the NFS exports list rototill patch: - Remove all NFS related stuff from file system specific code. - Drop the vfs_checkexp hook and generalize it in the new nfs_check_export function, thus removing redundancy from all file systems. - Move all NFS export-related stuff from kern/vfs_subr.c to the new file sys/nfs/nfs_export.c. The former was becoming large and its code is always compiled, regardless of the build options. Using the latter, the code is only compiled in when NFSSERVER is enabled. While doing this, also make some functions in nfs_subs.c conditional to NFSSERVER. - Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a path and a set of export entries. At the moment it can only clear the exports list or append entries, one by one, but it is done in a way that allows setting the whole set of entries atomically in the future (see the comment in mountd_set_exports_list or in doc/TODO). - Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so that it becomes file system agnostic. In fact, all this whole thing was done to remove a 'XXX' block from this utility! - Change the mount*, newfs and fsck* userland utilities to not deal with NFS exports initialization; done internally by the kernel when initializing the NFS support for each file system. - Implement an interface for VFS (called VFS hooks) so that several kernel subsystems can run arbitrary code upon receipt of specific VFS events. At the moment, this only provides support for unmount and is used to destroy NFS exports lists from the file systems being unmounted, though it has room for extension. Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments and advice in the development of this patch.
2005-09-23 16:10:31 +04:00
.Ss Calls used by Xr nfsd 8
On the server side,
.Fn nfssvc
is called with the flag
.Dv NFSSVC_NFSD
and a pointer to a
.Bd -literal
struct nfsd_srvargs {
struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
uid_t nsd_uid; /* Effective uid mapped to cred */
u_long nsd_haddr; /* Ip address of client */
struct ucred nsd_cr; /* Cred. uid maps to */
int nsd_authlen; /* Length of auth string (ret) */
char *nsd_authstr; /* Auth string (ret) */
};
.Ed
.Pp
to enter the kernel as an
.Xr nfsd 8
daemon.
Whenever an
.Xr nfsd 8
daemon receives a Kerberos authentication ticket, it will return from
.Fn nfssvc
with errno set to
1999-12-11 22:35:48 +03:00
.Er ENEEDAUTH .
The
.Xr nfsd 8
will attempt to authenticate the ticket and generate a set of credentials
on the server for the
.Dq user id
specified in the field nsd_uid.
This is done by first authenticating the Kerberos ticket and then mapping
the Kerberos principal to a local name and getting a set of credentials for
that user via
.Xr getpwnam 3
and
.Xr getgrouplist 3 .
If successful, the
.Xr nfsd 8
will call
.Fn nfssvc
with the
.Dv NFSSVC_NFSD
and
.Dv NFSSVC_AUTHIN
flags set to pass the credential mapping in nsd_cr into the
kernel to be cached on the server socket for that client.
If the authentication failed,
.Xr nfsd 8
calls
.Fn nfssvc
with the flags
.Dv NFSSVC_NFSD
and
.Dv NFSSVC_AUTHINFAIL
to denote an authentication failure.
.Pp
The master
.Xr nfsd 8
server daemon calls
.Fn nfssvc
with the flag
.Dv NFSSVC_ADDSOCK
and a pointer to a
.Bd -literal
struct nfsd_args {
int sock; /* Socket to serve */
caddr_t name; /* Client address for connection based sockets */
int namelen; /* Length of name */
};
.Ed
.Pp
to pass a server side
1993-03-21 12:45:37 +03:00
.Tn NFS
socket into the kernel for servicing by the
.Xr nfsd 8
daemons.
Apply the NFS exports list rototill patch: - Remove all NFS related stuff from file system specific code. - Drop the vfs_checkexp hook and generalize it in the new nfs_check_export function, thus removing redundancy from all file systems. - Move all NFS export-related stuff from kern/vfs_subr.c to the new file sys/nfs/nfs_export.c. The former was becoming large and its code is always compiled, regardless of the build options. Using the latter, the code is only compiled in when NFSSERVER is enabled. While doing this, also make some functions in nfs_subs.c conditional to NFSSERVER. - Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a path and a set of export entries. At the moment it can only clear the exports list or append entries, one by one, but it is done in a way that allows setting the whole set of entries atomically in the future (see the comment in mountd_set_exports_list or in doc/TODO). - Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so that it becomes file system agnostic. In fact, all this whole thing was done to remove a 'XXX' block from this utility! - Change the mount*, newfs and fsck* userland utilities to not deal with NFS exports initialization; done internally by the kernel when initializing the NFS support for each file system. - Implement an interface for VFS (called VFS hooks) so that several kernel subsystems can run arbitrary code upon receipt of specific VFS events. At the moment, this only provides support for unmount and is used to destroy NFS exports lists from the file systems being unmounted, though it has room for extension. Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments and advice in the development of this patch.
2005-09-23 16:10:31 +04:00
.Ss Calls used by Xr mountd 8
The
.Xr mountd 8
server daemon calls
.Fn nfssvc
with the flag
.Dv NFSSVC_SETEXPORTSLIST
and a pointer to a
.Ft struct mountd_exports_list
object to atomically change the exports lists of a specific file system.
This structure has the following fields:
2009-03-11 00:00:47 +03:00
.Bl -tag -width ".Vt const char *mel_path"
Apply the NFS exports list rototill patch: - Remove all NFS related stuff from file system specific code. - Drop the vfs_checkexp hook and generalize it in the new nfs_check_export function, thus removing redundancy from all file systems. - Move all NFS export-related stuff from kern/vfs_subr.c to the new file sys/nfs/nfs_export.c. The former was becoming large and its code is always compiled, regardless of the build options. Using the latter, the code is only compiled in when NFSSERVER is enabled. While doing this, also make some functions in nfs_subs.c conditional to NFSSERVER. - Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a path and a set of export entries. At the moment it can only clear the exports list or append entries, one by one, but it is done in a way that allows setting the whole set of entries atomically in the future (see the comment in mountd_set_exports_list or in doc/TODO). - Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so that it becomes file system agnostic. In fact, all this whole thing was done to remove a 'XXX' block from this utility! - Change the mount*, newfs and fsck* userland utilities to not deal with NFS exports initialization; done internally by the kernel when initializing the NFS support for each file system. - Implement an interface for VFS (called VFS hooks) so that several kernel subsystems can run arbitrary code upon receipt of specific VFS events. At the moment, this only provides support for unmount and is used to destroy NFS exports lists from the file systems being unmounted, though it has room for extension. Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments and advice in the development of this patch.
2005-09-23 16:10:31 +04:00
.It Vt const char *mel_path
Path to the file system that will have its exports list replaced by the
one described in the other fields.
.It Vt size_t mel_nexports
Number of valid entries in the
.Vt mel_export
field.
If zero, the exports list will be cleared for the given file system.
.It Vt struct export_args mel_export[AF_MAX]
Set of exports to be used for the given file system.
.El
1993-03-21 12:45:37 +03:00
.Sh RETURN VALUES
Usually
.Nm
1993-03-21 12:45:37 +03:00
does not return unless the server
is terminated by a signal when a value of 0 is returned.
2004-05-13 14:20:57 +04:00
Otherwise, \-1 is returned and the global variable
1993-03-21 12:45:37 +03:00
.Va errno
is set to specify the error.
1993-03-21 12:45:37 +03:00
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er ENEEDAUTH
This special error value is really used for authentication support,
particularly Kerberos, as explained above.
1993-03-21 12:45:37 +03:00
.It Bq Er EPERM
The caller is not the super-user.
.El
.Sh SEE ALSO
.Xr mount_nfs 8 ,
.Xr nfsd 8
1993-03-21 12:45:37 +03:00
.Sh HISTORY
The
.Nm
1998-02-04 00:12:45 +03:00
function first appeared in
.Bx 4.4 .
.Sh BUGS
The
.Nm
system call is designed specifically for the
.Tn NFS
support daemons and as such is specific to their requirements.
It should really return values to indicate the need for authentication
support, since
1999-12-11 22:35:48 +03:00
.Er ENEEDAUTH
is not really an error.
Several fields of the argument structures are assumed to be valid and
sometimes to be unchanged from a previous call, such that
.Nm
must be used with extreme care.