[BACK]Return to nfssvc.2 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / sys

File: [cvs.NetBSD.org] / src / lib / libc / sys / nfssvc.2 (download)

Revision 1.24, Tue Mar 10 21:00:47 2009 UTC (15 years, 1 month ago) by joerg
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-premerge-20091211, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, localcount-20160914, jym-xensuspend-nbase, jym-xensuspend-base, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver
Changes since 1.23: +2 -2 lines

Specify width for tag list

.\"	$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.
.\"
.\" 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
.\"    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
.\"
.Dd December 30, 2006
.Dt NFSSVC 2
.Os
.Sh NAME
.Nm nfssvc
.Nd NFS services
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In unistd.h
.In nfs/nfs.h
.Ft int
.Fn nfssvc "int flags" "void *argstructp"
.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.
.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
.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
.Tn NFS
socket into the kernel for servicing by the
.Xr nfsd 8
daemons.
.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:
.Bl -tag -width ".Vt const char *mel_path"
.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
.Sh RETURN VALUES
Usually
.Nm
does not return unless the server
is terminated by a signal when a value of 0 is returned.
Otherwise, \-1 is returned and the global variable
.Va errno
is set to specify the error.
.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.
.It Bq Er EPERM
The caller is not the super-user.
.El
.Sh SEE ALSO
.Xr mount_nfs 8 ,
.Xr nfsd 8
.Sh HISTORY
The
.Nm
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
.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.