xref: /freebsd/lib/libsys/nfssvc.2 (revision 8269e7673cf033aba67dab8264fe719920c70f87)
1*8269e767SBrooks Davis.\" Copyright (c) 1989, 1991, 1993
2*8269e767SBrooks Davis.\"	The Regents of the University of California.  All rights reserved.
3*8269e767SBrooks Davis.\"
4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
6*8269e767SBrooks Davis.\" are met:
7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
8*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
9*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
10*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
11*8269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
12*8269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors
13*8269e767SBrooks Davis.\"    may be used to endorse or promote products derived from this software
14*8269e767SBrooks Davis.\"    without specific prior written permission.
15*8269e767SBrooks Davis.\"
16*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*8269e767SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*8269e767SBrooks Davis.\" SUCH DAMAGE.
27*8269e767SBrooks Davis.\"
28*8269e767SBrooks Davis.Dd June 9, 1993
29*8269e767SBrooks Davis.Dt NFSSVC 2
30*8269e767SBrooks Davis.Os
31*8269e767SBrooks Davis.Sh NAME
32*8269e767SBrooks Davis.Nm nfssvc
33*8269e767SBrooks Davis.Nd NFS services
34*8269e767SBrooks Davis.Sh LIBRARY
35*8269e767SBrooks Davis.Lb libc
36*8269e767SBrooks Davis.Sh SYNOPSIS
37*8269e767SBrooks Davis.In sys/param.h
38*8269e767SBrooks Davis.In sys/mount.h
39*8269e767SBrooks Davis.In sys/time.h
40*8269e767SBrooks Davis.In nfs/rpcv2.h
41*8269e767SBrooks Davis.In nfsserver/nfs.h
42*8269e767SBrooks Davis.In unistd.h
43*8269e767SBrooks Davis.Ft int
44*8269e767SBrooks Davis.Fn nfssvc "int flags" "void *argstructp"
45*8269e767SBrooks Davis.Sh DESCRIPTION
46*8269e767SBrooks DavisThe
47*8269e767SBrooks Davis.Fn nfssvc
48*8269e767SBrooks Davissystem call is used by the NFS daemons to pass information into and out
49*8269e767SBrooks Davisof the kernel and also to enter the kernel as a server daemon.
50*8269e767SBrooks DavisThe
51*8269e767SBrooks Davis.Fa flags
52*8269e767SBrooks Davisargument consists of several bits that show what action is to be taken
53*8269e767SBrooks Davisonce in the kernel and the
54*8269e767SBrooks Davis.Fa argstructp
55*8269e767SBrooks Davispoints to one of three structures depending on which bits are set in
56*8269e767SBrooks Davisflags.
57*8269e767SBrooks Davis.Pp
58*8269e767SBrooks DavisOn the client side,
59*8269e767SBrooks Davis.Xr nfsiod 8
60*8269e767SBrooks Daviscalls
61*8269e767SBrooks Davis.Fn nfssvc
62*8269e767SBrooks Daviswith the
63*8269e767SBrooks Davis.Fa flags
64*8269e767SBrooks Davisargument set to
65*8269e767SBrooks Davis.Dv NFSSVC_BIOD
66*8269e767SBrooks Davisand
67*8269e767SBrooks Davis.Fa argstructp
68*8269e767SBrooks Davisset to
69*8269e767SBrooks Davis.Dv NULL
70*8269e767SBrooks Davisto enter the kernel as a block I/O server daemon.
71*8269e767SBrooks DavisFor
72*8269e767SBrooks Davis.Tn NQNFS ,
73*8269e767SBrooks Davis.Xr mount_nfs 8
74*8269e767SBrooks Daviscalls
75*8269e767SBrooks Davis.Fn nfssvc
76*8269e767SBrooks Daviswith the
77*8269e767SBrooks Davis.Dv NFSSVC_MNTD
78*8269e767SBrooks Davisflag, optionally or'd with the flags
79*8269e767SBrooks Davis.Dv NFSSVC_GOTAUTH
80*8269e767SBrooks Davisand
81*8269e767SBrooks Davis.Dv NFSSVC_AUTHINFAIL
82*8269e767SBrooks Davisalong with a pointer to a
83*8269e767SBrooks Davis.Bd -literal
84*8269e767SBrooks Davisstruct nfsd_cargs {
85*8269e767SBrooks Davis	char		*ncd_dirp;	/* Mount dir path */
86*8269e767SBrooks Davis	uid_t		ncd_authuid;	/* Effective uid */
87*8269e767SBrooks Davis	int		ncd_authtype;	/* Type of authenticator */
88*8269e767SBrooks Davis	int		ncd_authlen;	/* Length of authenticator string */
89*8269e767SBrooks Davis	u_char		*ncd_authstr;	/* Authenticator string */
90*8269e767SBrooks Davis	int		ncd_verflen;	/* and the verifier */
91*8269e767SBrooks Davis	u_char		*ncd_verfstr;
92*8269e767SBrooks Davis	NFSKERBKEY_T	ncd_key;	/* Session key */
93*8269e767SBrooks Davis};
94*8269e767SBrooks Davis.Ed
95*8269e767SBrooks Davis.Pp
96*8269e767SBrooks Davisstructure.
97*8269e767SBrooks DavisThe initial call has only the
98*8269e767SBrooks Davis.Dv NFSSVC_MNTD
99*8269e767SBrooks Davisflag set to specify service for the mount point.
100*8269e767SBrooks DavisIf the mount point is using Kerberos, then the
101*8269e767SBrooks Davis.Xr mount_nfs 8
102*8269e767SBrooks Davisutility will return from
103*8269e767SBrooks Davis.Fn nfssvc
104*8269e767SBrooks Daviswith
105*8269e767SBrooks Davis.Va errno
106*8269e767SBrooks Davis==
107*8269e767SBrooks Davis.Er ENEEDAUTH
108*8269e767SBrooks Daviswhenever the client side requires an ``rcmd''
109*8269e767SBrooks Davisauthentication ticket for the user.
110*8269e767SBrooks DavisThe
111*8269e767SBrooks Davis.Xr mount_nfs 8
112*8269e767SBrooks Davisutility will attempt to get the Kerberos ticket, and if successful will call
113*8269e767SBrooks Davis.Fn nfssvc
114*8269e767SBrooks Daviswith the flags
115*8269e767SBrooks Davis.Dv NFSSVC_MNTD
116*8269e767SBrooks Davisand
117*8269e767SBrooks Davis.Dv NFSSVC_GOTAUTH
118*8269e767SBrooks Davisafter filling the ticket into the
119*8269e767SBrooks Davisncd_authstr field
120*8269e767SBrooks Davisand
121*8269e767SBrooks Davissetting the ncd_authlen and ncd_authtype
122*8269e767SBrooks Davisfields of the nfsd_cargs structure.
123*8269e767SBrooks DavisIf
124*8269e767SBrooks Davis.Xr mount_nfs 8
125*8269e767SBrooks Davisfailed to get the ticket,
126*8269e767SBrooks Davis.Fn nfssvc
127*8269e767SBrooks Daviswill be called with the flags
128*8269e767SBrooks Davis.Dv NFSSVC_MNTD ,
129*8269e767SBrooks Davis.Dv NFSSVC_GOTAUTH
130*8269e767SBrooks Davisand
131*8269e767SBrooks Davis.Dv NFSSVC_AUTHINFAIL
132*8269e767SBrooks Davisto denote a failed authentication attempt.
133*8269e767SBrooks Davis.Pp
134*8269e767SBrooks DavisOn the server side,
135*8269e767SBrooks Davis.Fn nfssvc
136*8269e767SBrooks Davisis called with the flag
137*8269e767SBrooks Davis.Dv NFSSVC_NFSD
138*8269e767SBrooks Davisand a pointer to a
139*8269e767SBrooks Davis.Bd -literal
140*8269e767SBrooks Davisstruct nfsd_srvargs {
141*8269e767SBrooks Davis	struct nfsd	*nsd_nfsd;	/* Pointer to in kernel nfsd struct */
142*8269e767SBrooks Davis	uid_t		nsd_uid;	/* Effective uid mapped to cred */
143*8269e767SBrooks Davis	uint32_t	nsd_haddr;	/* Ip address of client */
144*8269e767SBrooks Davis	struct ucred	nsd_cr;		/* Cred. uid maps to */
145*8269e767SBrooks Davis	int		nsd_authlen;	/* Length of auth string (ret) */
146*8269e767SBrooks Davis	u_char		*nsd_authstr;	/* Auth string (ret) */
147*8269e767SBrooks Davis	int		nsd_verflen;	/* and the verifier */
148*8269e767SBrooks Davis	u_char		*nsd_verfstr;
149*8269e767SBrooks Davis	struct timeval	nsd_timestamp;	/* timestamp from verifier */
150*8269e767SBrooks Davis	uint32_t	nsd_ttl;	/* credential ttl (sec) */
151*8269e767SBrooks Davis	NFSKERBKEY_T	nsd_key;	/* Session key */
152*8269e767SBrooks Davis};
153*8269e767SBrooks Davis.Ed
154*8269e767SBrooks Davis.Pp
155*8269e767SBrooks Davisto enter the kernel as an
156*8269e767SBrooks Davis.Xr nfsd 8
157*8269e767SBrooks Davisdaemon.
158*8269e767SBrooks DavisWhenever an
159*8269e767SBrooks Davis.Xr nfsd 8
160*8269e767SBrooks Davisdaemon receives a Kerberos authentication ticket, it will return from
161*8269e767SBrooks Davis.Fn nfssvc
162*8269e767SBrooks Daviswith
163*8269e767SBrooks Davis.Va errno
164*8269e767SBrooks Davis==
165*8269e767SBrooks Davis.Er ENEEDAUTH .
166*8269e767SBrooks DavisThe
167*8269e767SBrooks Davis.Xr nfsd 8
168*8269e767SBrooks Davisutility will attempt to authenticate the ticket and generate a set of credentials
169*8269e767SBrooks Davison the server for the ``user id'' specified in the field nsd_uid.
170*8269e767SBrooks DavisThis is done by first authenticating the Kerberos ticket and then mapping
171*8269e767SBrooks Davisthe Kerberos principal to a local name and getting a set of credentials for
172*8269e767SBrooks Davisthat user via
173*8269e767SBrooks Davis.Xr getpwnam 3
174*8269e767SBrooks Davisand
175*8269e767SBrooks Davis.Xr getgrouplist 3 .
176*8269e767SBrooks DavisIf successful, the
177*8269e767SBrooks Davis.Xr nfsd 8
178*8269e767SBrooks Davisutility will call
179*8269e767SBrooks Davis.Fn nfssvc
180*8269e767SBrooks Daviswith the
181*8269e767SBrooks Davis.Dv NFSSVC_NFSD
182*8269e767SBrooks Davisand
183*8269e767SBrooks Davis.Dv NFSSVC_AUTHIN
184*8269e767SBrooks Davisflags set to pass the credential mapping in nsd_cr into the
185*8269e767SBrooks Daviskernel to be cached on the server socket for that client.
186*8269e767SBrooks DavisIf the authentication failed,
187*8269e767SBrooks Davis.Xr nfsd 8
188*8269e767SBrooks Daviscalls
189*8269e767SBrooks Davis.Fn nfssvc
190*8269e767SBrooks Daviswith the flags
191*8269e767SBrooks Davis.Dv NFSSVC_NFSD
192*8269e767SBrooks Davisand
193*8269e767SBrooks Davis.Dv NFSSVC_AUTHINFAIL
194*8269e767SBrooks Davisto denote an authentication failure.
195*8269e767SBrooks Davis.Pp
196*8269e767SBrooks DavisThe master
197*8269e767SBrooks Davis.Xr nfsd 8
198*8269e767SBrooks Davisserver daemon calls
199*8269e767SBrooks Davis.Fn nfssvc
200*8269e767SBrooks Daviswith the flag
201*8269e767SBrooks Davis.Dv NFSSVC_ADDSOCK
202*8269e767SBrooks Davisand a pointer to a
203*8269e767SBrooks Davis.Bd -literal
204*8269e767SBrooks Davisstruct nfsd_args {
205*8269e767SBrooks Davis	int	sock;	/* Socket to serve */
206*8269e767SBrooks Davis	caddr_t	name;	/* Client address for connection based sockets */
207*8269e767SBrooks Davis	int	namelen;/* Length of name */
208*8269e767SBrooks Davis};
209*8269e767SBrooks Davis.Ed
210*8269e767SBrooks Davis.Pp
211*8269e767SBrooks Davisto pass a server side
212*8269e767SBrooks Davis.Tn NFS
213*8269e767SBrooks Davissocket into the kernel for servicing by the
214*8269e767SBrooks Davis.Xr nfsd 8
215*8269e767SBrooks Davisdaemons.
216*8269e767SBrooks Davis.Sh RETURN VALUES
217*8269e767SBrooks DavisNormally
218*8269e767SBrooks Davis.Fn nfssvc
219*8269e767SBrooks Davisdoes not return unless the server
220*8269e767SBrooks Davisis terminated by a signal when a value of 0 is returned.
221*8269e767SBrooks DavisOtherwise, -1 is returned and the global variable
222*8269e767SBrooks Davis.Va errno
223*8269e767SBrooks Davisis set to specify the error.
224*8269e767SBrooks Davis.Sh ERRORS
225*8269e767SBrooks Davis.Bl -tag -width Er
226*8269e767SBrooks Davis.It Bq Er ENEEDAUTH
227*8269e767SBrooks DavisThis special error value
228*8269e767SBrooks Davisis really used for authentication support, particularly Kerberos,
229*8269e767SBrooks Davisas explained above.
230*8269e767SBrooks Davis.It Bq Er EPERM
231*8269e767SBrooks DavisThe caller is not the super-user.
232*8269e767SBrooks Davis.El
233*8269e767SBrooks Davis.Sh SEE ALSO
234*8269e767SBrooks Davis.Xr mount_nfs 8 ,
235*8269e767SBrooks Davis.Xr nfsd 8 ,
236*8269e767SBrooks Davis.Xr nfsiod 8
237*8269e767SBrooks Davis.Sh HISTORY
238*8269e767SBrooks DavisThe
239*8269e767SBrooks Davis.Fn nfssvc
240*8269e767SBrooks Davissystem call first appeared in
241*8269e767SBrooks Davis.Bx 4.4 .
242*8269e767SBrooks Davis.Sh BUGS
243*8269e767SBrooks DavisThe
244*8269e767SBrooks Davis.Fn nfssvc
245*8269e767SBrooks Davissystem call is designed specifically for the
246*8269e767SBrooks Davis.Tn NFS
247*8269e767SBrooks Davissupport daemons and as such is specific to their requirements.
248*8269e767SBrooks DavisIt should really return values to indicate the need for authentication
249*8269e767SBrooks Davissupport, since
250*8269e767SBrooks Davis.Er ENEEDAUTH
251*8269e767SBrooks Davisis not really an error.
252*8269e767SBrooks DavisSeveral fields of the argument structures are assumed to be valid and
253*8269e767SBrooks Davissometimes to be unchanged from a previous call, such that
254*8269e767SBrooks Davis.Fn nfssvc
255*8269e767SBrooks Davismust be used with extreme care.
256