📄 nfssvc.2
字号:
.\" 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. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. 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 June 9, 1993.Dt NFSSVC 2.Os.Sh NAME.Nm nfssvc.Nd NFS services.Sh SYNOPSIS.Fd #include <unistd.h>.Fd #include <nfs/nfs.h>.Ft int.Fn nfssvc "int flags" "void *argstructp".Sh DESCRIPTIONThe.Fn nfssvcfunction is used by the NFS daemons to pass information into and outof the kernel and also to enter the kernel as a server daemon.The.Fa flagsargument consists of several bits that show what action is to be takenonce in the kernel and the.Fa argstructppoints to one of three structures depending on which bits are set inflags..PpOn the client side,.Xr nfsiod 8calls.Fn nfssvcwith the.Fa flagsargument set to.Dv NFSSVC_BIODand.Fa argstructpset to.Dv NULLto enter the kernel as a block I/O server daemon.For.Nm NQNFS ,.Xr mount_nfs 8calls.Fn nfssvcwith the.Dv NFSSVC_MNTDflag, optionally or'd with the flags.Dv NFSSVC_GOTAUTHand.Dv NFSSVC_AUTHINFAILalong with a pointer to a.Bd -literalstruct nfsd_cargs { char *ncd_dirp; /* Mount dir path */ uid_t ncd_authuid; /* Effective uid */ int ncd_authtype; /* Type of authenticator */ int ncd_authlen; /* Length of authenticator string */ char *ncd_authstr; /* Authenticator string */};.Ed.spstructure.The initial call has only the.Dv NFSSVC_MNTDflag set to specify service for the mount point.If the mount point is using Kerberos, then the.Xr mount_nfs 8daemon will return from.Fn nfssvcwith errno == ENEEDAUTH whenever the client side requires an ``rcmd''authentication ticket for the user..Xr Mount_nfs 8will attempt to get the Kerberos ticket, and if successful will call.Fn nfssvcwith the flags.Dv NFSSVC_MNTDand.Dv NFSSVC_GOTAUTHafter filling the ticket into the ncd_authstr fieldandsetting the ncd_authlen and ncd_authtypefields of the nfsd_cargs structure.If.Xr mount_nfs 8failed to get the ticket,.Fn nfssvcwill be called with the flags.Dv NFSSVC_MNTD ,.Dv NFSSVC_GOTAUTHand.Dv NFSSVC_AUTHINFAILto denote a failed authentication attempt..PpOn the server side,.Fn nfssvcis called with the flag.Dv NFSSVC_NFSDand a pointer to a.Bd -literalstruct 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.spto enter the kernel as an.Xr nfsd 8daemon.Whenever an.Xr nfsd 8daemon receives a Kerberos authentication ticket, it will return from.Fn nfssvcwith errno == ENEEDAUTH.The.Xr nfsd 8will attempt to authenticate the ticket and generate a set of credentialson the server for the ``user id'' specified in the field nsd_uid.This is done by first authenticating the Kerberos ticket and then mappingthe Kerberos principal to a local name and getting a set of credentials forthat user via..Xr getpwnam 3and.Xr getgrouplist 3 .If successful, the.Xr nfsd 8will call.Fn nfssvcwith the.Dv NFSSVC_NFSDand.Dv NFSSVC_AUTHINflags set to pass the credential mapping in nsd_cr into thekernel to be cached on the server socket for that client.If the authentication failed,.Xr nfsd 8calls.Fn nfssvcwith the flags.Dv NFSSVC_NFSDand.Dv NFSSVC_AUTHINFAILto denote an authentication failure..PpThe master.Xr nfsd 8server daemon calls.Fn nfssvcwith the flag.Dv NFSSVC_ADDSOCKand a pointer to a.Bd -literalstruct nfsd_args { int sock; /* Socket to serve */ caddr_t name; /* Client address for connection based sockets */ int namelen; /* Length of name */};.Ed.spto pass a server side.Tn NFSsocket into the kernel for servicing by the.Xr nfsd 8daemons..Sh RETURN VALUESNormally.Nm nfssvcdoes not return unless the serveris terminated by a signal when a value of 0 is returned.Otherwise, -1 is returned and the global variable.Va errnois set to specify the error..Sh ERRORS.Bl -tag -width [ENEEDAUTH].It Bq Er ENEEDAUTHThis special error valueis really used for authentication support, particularly Kerberos,as explained above..It Bq Er EPERMThe caller is not the super-user..El.Sh SEE ALSO.Xr nfsd 8 ,.Xr mount_nfs 8 ,.Xr nfsiod 8.Sh HISTORYThe.Nm nfssvcfunction first appeared in 4.4BSD..Sh BUGSThe.Nm nfssvcsystem call is designed specifically for the.Tn NFSsupport daemons and as such is specific to their requirements.It should really return values to indicate the need for authenticationsupport, since.Dv ENEEDAUTHis not really an error.Several fields of the argument structures are assumed to be valid andsometimes to be unchanged from a previous call, such that.Nm nfssvcmust be used with extreme care.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -