Deleted Added
full compact
mountd.c (9202) mountd.c (9336)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Herb Hasler and Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 29 unchanged lines hidden (view full) ---

38static char copyright[] =
39"@(#) Copyright (c) 1989, 1993\n\
40 The Regents of the University of California. All rights reserved.\n";
41#endif /*not lint*/
42
43#ifndef lint
44/*static char sccsid[] = "From: @(#)mountd.c 8.8 (Berkeley) 2/20/94";*/
45static const char rcsid[] =
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Herb Hasler and Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 29 unchanged lines hidden (view full) ---

38static char copyright[] =
39"@(#) Copyright (c) 1989, 1993\n\
40 The Regents of the University of California. All rights reserved.\n";
41#endif /*not lint*/
42
43#ifndef lint
44/*static char sccsid[] = "From: @(#)mountd.c 8.8 (Berkeley) 2/20/94";*/
45static const char rcsid[] =
46 "$Id: mountd.c,v 1.7.2.1 1995/06/08 04:34:11 davidg Exp $";
46 "$Id: mountd.c,v 1.8 1995/06/11 19:30:46 rgrimes Exp $";
47#endif /*not lint*/
48
49#include <sys/param.h>
50#include <sys/file.h>
51#include <sys/ioctl.h>
52#include <sys/mount.h>
53#include <sys/socket.h>
54#include <sys/stat.h>
55#include <sys/syslog.h>
56#include <sys/ucred.h>
57
58#include <rpc/rpc.h>
59#include <rpc/pmap_clnt.h>
60#include <rpc/pmap_prot.h>
61#ifdef ISO
62#include <netiso/iso.h>
63#endif
64#include <nfs/rpcv2.h>
47#endif /*not lint*/
48
49#include <sys/param.h>
50#include <sys/file.h>
51#include <sys/ioctl.h>
52#include <sys/mount.h>
53#include <sys/socket.h>
54#include <sys/stat.h>
55#include <sys/syslog.h>
56#include <sys/ucred.h>
57
58#include <rpc/rpc.h>
59#include <rpc/pmap_clnt.h>
60#include <rpc/pmap_prot.h>
61#ifdef ISO
62#include <netiso/iso.h>
63#endif
64#include <nfs/rpcv2.h>
65#include <nfs/nfsv2.h>
65#include <nfs/nfsproto.h>
66
67#include <arpa/inet.h>
68
69#include <ctype.h>
70#include <errno.h>
71#include <grp.h>
72#include <netdb.h>
73#include <pwd.h>

--- 21 unchanged lines hidden (view full) ---

95 struct dirlist *dp_left;
96 struct dirlist *dp_right;
97 int dp_flag;
98 struct hostlist *dp_hosts; /* List of hosts this dir exported to */
99 char dp_dirp[1]; /* Actually malloc'd to size of dir */
100};
101/* dp_flag bits */
102#define DP_DEFSET 0x1
66
67#include <arpa/inet.h>
68
69#include <ctype.h>
70#include <errno.h>
71#include <grp.h>
72#include <netdb.h>
73#include <pwd.h>

--- 21 unchanged lines hidden (view full) ---

95 struct dirlist *dp_left;
96 struct dirlist *dp_right;
97 int dp_flag;
98 struct hostlist *dp_hosts; /* List of hosts this dir exported to */
99 char dp_dirp[1]; /* Actually malloc'd to size of dir */
100};
101/* dp_flag bits */
102#define DP_DEFSET 0x1
103#define DP_HOSTSET 0x2
104#define DP_KERB 0x4
103
104struct exportlist {
105 struct exportlist *ex_next;
106 struct dirlist *ex_dirl;
107 struct dirlist *ex_defdir;
108 int ex_flag;
109 fsid_t ex_fs;
110 char *ex_fsdir;

--- 23 unchanged lines hidden (view full) ---

134/* Group types */
135#define GT_NULL 0x0
136#define GT_HOST 0x1
137#define GT_NET 0x2
138#define GT_ISO 0x4
139#define GT_IGNORE 0x5
140
141struct hostlist {
105
106struct exportlist {
107 struct exportlist *ex_next;
108 struct dirlist *ex_dirl;
109 struct dirlist *ex_defdir;
110 int ex_flag;
111 fsid_t ex_fs;
112 char *ex_fsdir;

--- 23 unchanged lines hidden (view full) ---

136/* Group types */
137#define GT_NULL 0x0
138#define GT_HOST 0x1
139#define GT_NET 0x2
140#define GT_ISO 0x4
141#define GT_IGNORE 0x5
142
143struct hostlist {
144 int ht_flag; /* Uses DP_xx bits */
142 struct grouplist *ht_grp;
143 struct hostlist *ht_next;
144};
145
145 struct grouplist *ht_grp;
146 struct hostlist *ht_next;
147};
148
149struct fhreturn {
150 int fhr_flag;
151 int fhr_vers;
152 nfsfh_t fhr_fh;
153};
154
146/* Global defs */
147char *add_expdir __P((struct dirlist **, char *, int));
148void add_dlist __P((struct dirlist **, struct dirlist *,
155/* Global defs */
156char *add_expdir __P((struct dirlist **, char *, int));
157void add_dlist __P((struct dirlist **, struct dirlist *,
149 struct grouplist *));
158 struct grouplist *, int));
150void add_mlist __P((char *, char *));
151int check_dirpath __P((char *));
152int check_options __P((struct dirlist *));
159void add_mlist __P((char *, char *));
160int check_dirpath __P((char *));
161int check_options __P((struct dirlist *));
153int chk_host __P((struct dirlist *, u_long, int *));
162int chk_host __P((struct dirlist *, u_long, int *, int *));
154void del_mlist __P((char *, char *));
155struct dirlist *dirp_search __P((struct dirlist *, char *));
156int do_mount __P((struct exportlist *, struct grouplist *, int,
163void del_mlist __P((char *, char *));
164struct dirlist *dirp_search __P((struct dirlist *, char *));
165int do_mount __P((struct exportlist *, struct grouplist *, int,
157 struct ucred *, char *, int, struct statfs *));
166 struct ucred *, char *, int, struct statfs *));
158int do_opt __P((char **, char **, struct exportlist *, struct grouplist *,
159 int *, int *, struct ucred *));
160struct exportlist *ex_search __P((fsid_t *));
161struct exportlist *get_exp __P((void));
162void free_dir __P((struct dirlist *));
163void free_exp __P((struct exportlist *));
164void free_grp __P((struct grouplist *));
165void free_host __P((struct hostlist *));
166void get_exportlist __P((void));
167int get_host __P((char *, struct grouplist *, struct grouplist *));
167int do_opt __P((char **, char **, struct exportlist *, struct grouplist *,
168 int *, int *, struct ucred *));
169struct exportlist *ex_search __P((fsid_t *));
170struct exportlist *get_exp __P((void));
171void free_dir __P((struct dirlist *));
172void free_exp __P((struct exportlist *));
173void free_grp __P((struct grouplist *));
174void free_host __P((struct hostlist *));
175void get_exportlist __P((void));
176int get_host __P((char *, struct grouplist *, struct grouplist *));
177int get_num __P((char *));
168struct hostlist *get_ht __P((void));
169int get_line __P((void));
170void get_mountlist __P((void));
171int get_net __P((char *, struct netmsk *, int));
172void getexp_err __P((struct exportlist *, struct grouplist *));
173struct grouplist *get_grp __P((void));
174void hang_dirp __P((struct dirlist *, struct grouplist *,
175 struct exportlist *, int));
176void mntsrv __P((struct svc_req *, SVCXPRT *));
177void nextfield __P((char **, char **));
178void out_of_mem __P((void));
179void parsecred __P((char *, struct ucred *));
180int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *));
181int scan_tree __P((struct dirlist *, u_long));
182void send_umntall __P((void));
183int umntall_each __P((caddr_t, struct sockaddr_in *));
184int xdr_dir __P((XDR *, char *));
185int xdr_explist __P((XDR *, caddr_t));
178struct hostlist *get_ht __P((void));
179int get_line __P((void));
180void get_mountlist __P((void));
181int get_net __P((char *, struct netmsk *, int));
182void getexp_err __P((struct exportlist *, struct grouplist *));
183struct grouplist *get_grp __P((void));
184void hang_dirp __P((struct dirlist *, struct grouplist *,
185 struct exportlist *, int));
186void mntsrv __P((struct svc_req *, SVCXPRT *));
187void nextfield __P((char **, char **));
188void out_of_mem __P((void));
189void parsecred __P((char *, struct ucred *));
190int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *));
191int scan_tree __P((struct dirlist *, u_long));
192void send_umntall __P((void));
193int umntall_each __P((caddr_t, struct sockaddr_in *));
194int xdr_dir __P((XDR *, char *));
195int xdr_explist __P((XDR *, caddr_t));
186int xdr_fhs __P((XDR *, nfsv2fh_t *));
196int xdr_fhs __P((XDR *, caddr_t));
187int xdr_mlist __P((XDR *, caddr_t));
188
189/* C library */
190int getnetgrent();
191void endnetgrent();
192void setnetgrent();
193
194#ifdef ISO

--- 5 unchanged lines hidden (view full) ---

200struct grouplist *grphead;
201char exname[MAXPATHLEN];
202struct ucred def_anon = {
203 1,
204 (uid_t) -2,
205 1,
206 { (gid_t) -2 }
207};
197int xdr_mlist __P((XDR *, caddr_t));
198
199/* C library */
200int getnetgrent();
201void endnetgrent();
202void setnetgrent();
203
204#ifdef ISO

--- 5 unchanged lines hidden (view full) ---

210struct grouplist *grphead;
211char exname[MAXPATHLEN];
212struct ucred def_anon = {
213 1,
214 (uid_t) -2,
215 1,
216 { (gid_t) -2 }
217};
208int root_only = 1;
218int resvport_only = 1;
219int dir_only = 1;
209int opt_flags;
210/* Bits for above */
211#define OP_MAPROOT 0x01
212#define OP_MAPALL 0x02
213#define OP_KERB 0x04
214#define OP_MASK 0x08
215#define OP_NET 0x10
216#define OP_ISO 0x20

--- 16 unchanged lines hidden (view full) ---

233 */
234int
235main(argc, argv)
236 int argc;
237 char **argv;
238{
239 SVCXPRT *udptransp, *tcptransp;
240 int c;
220int opt_flags;
221/* Bits for above */
222#define OP_MAPROOT 0x01
223#define OP_MAPALL 0x02
224#define OP_KERB 0x04
225#define OP_MASK 0x08
226#define OP_NET 0x10
227#define OP_ISO 0x20

--- 16 unchanged lines hidden (view full) ---

244 */
245int
246main(argc, argv)
247 int argc;
248 char **argv;
249{
250 SVCXPRT *udptransp, *tcptransp;
251 int c;
252#ifdef __FreeBSD__
241 struct vfsconf *vfc;
242
243 vfc = getvfsbyname("nfs");
244 if(!vfc && vfsisloadable("nfs")) {
245 if(vfsload("nfs"))
246 err(1, "vfsload(nfs)");
247 endvfsent(); /* flush cache */
248 vfc = getvfsbyname("nfs");
249 }
250 if(!vfc) {
251 errx(1, "NFS support is not available in the running kernel");
252 }
253 struct vfsconf *vfc;
254
255 vfc = getvfsbyname("nfs");
256 if(!vfc && vfsisloadable("nfs")) {
257 if(vfsload("nfs"))
258 err(1, "vfsload(nfs)");
259 endvfsent(); /* flush cache */
260 vfc = getvfsbyname("nfs");
261 }
262 if(!vfc) {
263 errx(1, "NFS support is not available in the running kernel");
264 }
265#endif /* __FreeBSD__ */
253
266
254 while ((c = getopt(argc, argv, "dn")) != EOF)
267 while ((c = getopt(argc, argv, "dnr")) != EOF)
255 switch (c) {
268 switch (c) {
269 case 'n':
270 resvport_only = 0;
271 break;
272 case 'r':
273 dir_only = 0;
274 break;
256 case 'd':
257 debug = debug ? 0 : 1;
258 break;
275 case 'd':
276 debug = debug ? 0 : 1;
277 break;
259 case 'n':
260 root_only = 0;
261 break;
262 default:
278 default:
263 fprintf(stderr, "Usage: mountd [-n] [export_file]\n");
279 fprintf(stderr, "Usage: mountd [-r] [-n] [export_file]\n");
264 exit(1);
265 };
266 argc -= optind;
267 argv += optind;
268 grphead = (struct grouplist *)NULL;
269 exphead = (struct exportlist *)NULL;
270 mlhead = (struct mountlist *)NULL;
271 if (argc == 1) {

--- 23 unchanged lines hidden (view full) ---

295 fclose(pidfile);
296 }
297 }
298 if ((udptransp = svcudp_create(RPC_ANYSOCK)) == NULL ||
299 (tcptransp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL) {
300 syslog(LOG_ERR, "Can't create socket");
301 exit(1);
302 }
280 exit(1);
281 };
282 argc -= optind;
283 argv += optind;
284 grphead = (struct grouplist *)NULL;
285 exphead = (struct exportlist *)NULL;
286 mlhead = (struct mountlist *)NULL;
287 if (argc == 1) {

--- 23 unchanged lines hidden (view full) ---

311 fclose(pidfile);
312 }
313 }
314 if ((udptransp = svcudp_create(RPC_ANYSOCK)) == NULL ||
315 (tcptransp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL) {
316 syslog(LOG_ERR, "Can't create socket");
317 exit(1);
318 }
303 pmap_unset(RPCPROG_MNT, RPCMNT_VER1);
304 if (!svc_register(udptransp, RPCPROG_MNT, RPCMNT_VER1, mntsrv,
305 IPPROTO_UDP) ||
306 !svc_register(tcptransp, RPCPROG_MNT, RPCMNT_VER1, mntsrv,
307 IPPROTO_TCP)) {
319 pmap_unset(RPCPROG_MNT, 1);
320 pmap_unset(RPCPROG_MNT, 3);
321 if (!svc_register(udptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_UDP) ||
322 !svc_register(udptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_UDP) ||
323 !svc_register(tcptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_TCP) ||
324 !svc_register(tcptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_TCP)) {
308 syslog(LOG_ERR, "Can't register mount");
309 exit(1);
310 }
311 svc_run();
312 syslog(LOG_ERR, "Mountd died");
313 exit(1);
314}
315
316/*
317 * The mount rpc service
318 */
319void
320mntsrv(rqstp, transp)
321 struct svc_req *rqstp;
322 SVCXPRT *transp;
323{
324 struct exportlist *ep;
325 struct dirlist *dp;
325 syslog(LOG_ERR, "Can't register mount");
326 exit(1);
327 }
328 svc_run();
329 syslog(LOG_ERR, "Mountd died");
330 exit(1);
331}
332
333/*
334 * The mount rpc service
335 */
336void
337mntsrv(rqstp, transp)
338 struct svc_req *rqstp;
339 SVCXPRT *transp;
340{
341 struct exportlist *ep;
342 struct dirlist *dp;
326 nfsv2fh_t nfh;
343 struct fhreturn fhr;
327 struct authunix_parms *ucr;
328 struct stat stb;
329 struct statfs fsb;
330 struct hostent *hp;
331 u_long saddr;
344 struct authunix_parms *ucr;
345 struct stat stb;
346 struct statfs fsb;
347 struct hostent *hp;
348 u_long saddr;
349 u_short sport;
332 char rpcpath[RPCMNT_PATHLEN+1], dirpath[MAXPATHLEN];
350 char rpcpath[RPCMNT_PATHLEN+1], dirpath[MAXPATHLEN];
333 int bad = ENOENT, omask, defset;
334 uid_t uid = -2;
351 int bad = ENOENT, defset, hostset;
352 sigset_t sighup_mask;
335
353
336 /* Get authorization */
337 switch (rqstp->rq_cred.oa_flavor) {
338 case AUTH_UNIX:
339 ucr = (struct authunix_parms *)rqstp->rq_clntcred;
340 uid = ucr->aup_uid;
341 break;
342 case AUTH_NULL:
343 default:
344 break;
345 }
346
354 sigemptyset(&sighup_mask);
355 sigaddset(&sighup_mask, SIGHUP);
347 saddr = transp->xp_raddr.sin_addr.s_addr;
356 saddr = transp->xp_raddr.sin_addr.s_addr;
357 sport = ntohs(transp->xp_raddr.sin_port);
348 hp = (struct hostent *)NULL;
349 switch (rqstp->rq_proc) {
350 case NULLPROC:
351 if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
352 syslog(LOG_ERR, "Can't send reply");
353 return;
354 case RPCMNT_MOUNT:
358 hp = (struct hostent *)NULL;
359 switch (rqstp->rq_proc) {
360 case NULLPROC:
361 if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
362 syslog(LOG_ERR, "Can't send reply");
363 return;
364 case RPCMNT_MOUNT:
355 if ((uid != 0 && root_only) || uid == -2) {
365 if (sport >= IPPORT_RESERVED && resvport_only) {
356 svcerr_weakauth(transp);
357 return;
358 }
359 if (!svc_getargs(transp, xdr_dir, rpcpath)) {
360 svcerr_decode(transp);
361 return;
362 }
363
364 /*
365 * Get the real pathname and make sure it is a directory
366 svcerr_weakauth(transp);
367 return;
368 }
369 if (!svc_getargs(transp, xdr_dir, rpcpath)) {
370 svcerr_decode(transp);
371 return;
372 }
373
374 /*
375 * Get the real pathname and make sure it is a directory
366 * that exists.
376 * or a regular file if the -r option was specified
377 * and it exists.
367 */
368 if (realpath(rpcpath, dirpath) == 0 ||
369 stat(dirpath, &stb) < 0 ||
378 */
379 if (realpath(rpcpath, dirpath) == 0 ||
380 stat(dirpath, &stb) < 0 ||
370 (stb.st_mode & S_IFMT) != S_IFDIR ||
381 (!S_ISDIR(stb.st_mode) &&
382 (dir_only || !S_ISREG(stb.st_mode))) ||
371 statfs(dirpath, &fsb) < 0) {
372 chdir("/"); /* Just in case realpath doesn't */
373 if (debug)
374 fprintf(stderr, "stat failed on %s\n", dirpath);
375 if (!svc_sendreply(transp, xdr_long, (caddr_t)&bad))
376 syslog(LOG_ERR, "Can't send reply");
377 return;
378 }
379
380 /* Check in the exports list */
383 statfs(dirpath, &fsb) < 0) {
384 chdir("/"); /* Just in case realpath doesn't */
385 if (debug)
386 fprintf(stderr, "stat failed on %s\n", dirpath);
387 if (!svc_sendreply(transp, xdr_long, (caddr_t)&bad))
388 syslog(LOG_ERR, "Can't send reply");
389 return;
390 }
391
392 /* Check in the exports list */
381 omask = sigblock(sigmask(SIGHUP));
393 sigprocmask(SIG_BLOCK, &sighup_mask, NULL);
382 ep = ex_search(&fsb.f_fsid);
394 ep = ex_search(&fsb.f_fsid);
383 defset = 0;
384 if (ep && (chk_host(ep->ex_defdir, saddr, &defset) ||
395 hostset = defset = 0;
396 if (ep && (chk_host(ep->ex_defdir, saddr, &defset, &hostset) ||
385 ((dp = dirp_search(ep->ex_dirl, dirpath)) &&
397 ((dp = dirp_search(ep->ex_dirl, dirpath)) &&
386 chk_host(dp, saddr, &defset)) ||
398 chk_host(dp, saddr, &defset, &hostset)) ||
387 (defset && scan_tree(ep->ex_defdir, saddr) == 0 &&
388 scan_tree(ep->ex_dirl, saddr) == 0))) {
399 (defset && scan_tree(ep->ex_defdir, saddr) == 0 &&
400 scan_tree(ep->ex_dirl, saddr) == 0))) {
401 if (hostset & DP_HOSTSET)
402 fhr.fhr_flag = hostset;
403 else
404 fhr.fhr_flag = defset;
405 fhr.fhr_vers = rqstp->rq_vers;
389 /* Get the file handle */
406 /* Get the file handle */
390 bzero((caddr_t)&nfh, sizeof(nfh));
391 if (getfh(dirpath, (fhandle_t *)&nfh) < 0) {
407 bzero((caddr_t)&fhr.fhr_fh, sizeof(nfsfh_t));
408 if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) {
392 bad = errno;
393 syslog(LOG_ERR, "Can't get fh for %s", dirpath);
394 if (!svc_sendreply(transp, xdr_long,
395 (caddr_t)&bad))
396 syslog(LOG_ERR, "Can't send reply");
409 bad = errno;
410 syslog(LOG_ERR, "Can't get fh for %s", dirpath);
411 if (!svc_sendreply(transp, xdr_long,
412 (caddr_t)&bad))
413 syslog(LOG_ERR, "Can't send reply");
397 sigsetmask(omask);
414 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
398 return;
399 }
415 return;
416 }
400 if (!svc_sendreply(transp, xdr_fhs, (caddr_t)&nfh))
417 if (!svc_sendreply(transp, xdr_fhs, (caddr_t)&fhr))
401 syslog(LOG_ERR, "Can't send reply");
402 if (hp == NULL)
403 hp = gethostbyaddr((caddr_t)&saddr,
404 sizeof(saddr), AF_INET);
405 if (hp)
406 add_mlist(hp->h_name, dirpath);
407 else
408 add_mlist(inet_ntoa(transp->xp_raddr.sin_addr),
409 dirpath);
410 if (debug)
411 fprintf(stderr,"Mount successfull.\n");
412 } else {
413 bad = EACCES;
414 if (!svc_sendreply(transp, xdr_long, (caddr_t)&bad))
415 syslog(LOG_ERR, "Can't send reply");
416 }
418 syslog(LOG_ERR, "Can't send reply");
419 if (hp == NULL)
420 hp = gethostbyaddr((caddr_t)&saddr,
421 sizeof(saddr), AF_INET);
422 if (hp)
423 add_mlist(hp->h_name, dirpath);
424 else
425 add_mlist(inet_ntoa(transp->xp_raddr.sin_addr),
426 dirpath);
427 if (debug)
428 fprintf(stderr,"Mount successfull.\n");
429 } else {
430 bad = EACCES;
431 if (!svc_sendreply(transp, xdr_long, (caddr_t)&bad))
432 syslog(LOG_ERR, "Can't send reply");
433 }
417 sigsetmask(omask);
434 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
418 return;
419 case RPCMNT_DUMP:
420 if (!svc_sendreply(transp, xdr_mlist, (caddr_t)NULL))
421 syslog(LOG_ERR, "Can't send reply");
422 return;
423 case RPCMNT_UMOUNT:
435 return;
436 case RPCMNT_DUMP:
437 if (!svc_sendreply(transp, xdr_mlist, (caddr_t)NULL))
438 syslog(LOG_ERR, "Can't send reply");
439 return;
440 case RPCMNT_UMOUNT:
424 if ((uid != 0 && root_only) || uid == -2) {
441 if (sport >= IPPORT_RESERVED && resvport_only) {
425 svcerr_weakauth(transp);
426 return;
427 }
428 if (!svc_getargs(transp, xdr_dir, dirpath)) {
429 svcerr_decode(transp);
430 return;
431 }
432 if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
433 syslog(LOG_ERR, "Can't send reply");
434 hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
435 if (hp)
436 del_mlist(hp->h_name, dirpath);
437 del_mlist(inet_ntoa(transp->xp_raddr.sin_addr), dirpath);
438 return;
439 case RPCMNT_UMNTALL:
442 svcerr_weakauth(transp);
443 return;
444 }
445 if (!svc_getargs(transp, xdr_dir, dirpath)) {
446 svcerr_decode(transp);
447 return;
448 }
449 if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
450 syslog(LOG_ERR, "Can't send reply");
451 hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
452 if (hp)
453 del_mlist(hp->h_name, dirpath);
454 del_mlist(inet_ntoa(transp->xp_raddr.sin_addr), dirpath);
455 return;
456 case RPCMNT_UMNTALL:
440 if ((uid != 0 && root_only) || uid == -2) {
457 if (sport >= IPPORT_RESERVED && resvport_only) {
441 svcerr_weakauth(transp);
442 return;
443 }
444 if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
445 syslog(LOG_ERR, "Can't send reply");
446 hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
447 if (hp)
448 del_mlist(hp->h_name, (char *)NULL);

--- 16 unchanged lines hidden (view full) ---

465xdr_dir(xdrsp, dirp)
466 XDR *xdrsp;
467 char *dirp;
468{
469 return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN));
470}
471
472/*
458 svcerr_weakauth(transp);
459 return;
460 }
461 if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
462 syslog(LOG_ERR, "Can't send reply");
463 hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
464 if (hp)
465 del_mlist(hp->h_name, (char *)NULL);

--- 16 unchanged lines hidden (view full) ---

482xdr_dir(xdrsp, dirp)
483 XDR *xdrsp;
484 char *dirp;
485{
486 return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN));
487}
488
489/*
473 * Xdr routine to generate fhstatus
490 * Xdr routine to generate file handle reply
474 */
475int
491 */
492int
476xdr_fhs(xdrsp, nfh)
493xdr_fhs(xdrsp, cp)
477 XDR *xdrsp;
494 XDR *xdrsp;
478 nfsv2fh_t *nfh;
495 caddr_t cp;
479{
496{
480 u_long ok = 0;
497 register struct fhreturn *fhrp = (struct fhreturn *)cp;
498 u_long ok = 0, len, auth;
481
482 if (!xdr_long(xdrsp, &ok))
483 return (0);
499
500 if (!xdr_long(xdrsp, &ok))
501 return (0);
484 return (xdr_opaque(xdrsp, (caddr_t)nfh, NFSX_FH));
502 switch (fhrp->fhr_vers) {
503 case 1:
504 return (xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, NFSX_V2FH));
505 case 3:
506 len = NFSX_V3FH;
507 if (!xdr_long(xdrsp, &len))
508 return (0);
509 if (!xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, len))
510 return (0);
511 if (fhrp->fhr_flag & DP_KERB)
512 auth = RPCAUTH_KERB4;
513 else
514 auth = RPCAUTH_UNIX;
515 len = 1;
516 if (!xdr_long(xdrsp, &len))
517 return (0);
518 return (xdr_long(xdrsp, &auth));
519 };
520 return (0);
485}
486
487int
488xdr_mlist(xdrsp, cp)
489 XDR *xdrsp;
490 caddr_t cp;
491{
492 struct mountlist *mlp;

--- 23 unchanged lines hidden (view full) ---

516 */
517int
518xdr_explist(xdrsp, cp)
519 XDR *xdrsp;
520 caddr_t cp;
521{
522 struct exportlist *ep;
523 int false = 0;
521}
522
523int
524xdr_mlist(xdrsp, cp)
525 XDR *xdrsp;
526 caddr_t cp;
527{
528 struct mountlist *mlp;

--- 23 unchanged lines hidden (view full) ---

552 */
553int
554xdr_explist(xdrsp, cp)
555 XDR *xdrsp;
556 caddr_t cp;
557{
558 struct exportlist *ep;
559 int false = 0;
524 int omask, putdef;
560 int putdef;
561 sigset_t sighup_mask;
525
562
526 omask = sigblock(sigmask(SIGHUP));
563 sigemptyset(&sighup_mask);
564 sigaddset(&sighup_mask, SIGHUP);
565 sigprocmask(SIG_BLOCK, &sighup_mask, NULL);
527 ep = exphead;
528 while (ep) {
529 putdef = 0;
530 if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, &putdef))
531 goto errout;
532 if (ep->ex_defdir && putdef == 0 &&
533 put_exlist(ep->ex_defdir, xdrsp, (struct dirlist *)NULL,
534 &putdef))
535 goto errout;
536 ep = ep->ex_next;
537 }
566 ep = exphead;
567 while (ep) {
568 putdef = 0;
569 if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, &putdef))
570 goto errout;
571 if (ep->ex_defdir && putdef == 0 &&
572 put_exlist(ep->ex_defdir, xdrsp, (struct dirlist *)NULL,
573 &putdef))
574 goto errout;
575 ep = ep->ex_next;
576 }
538 sigsetmask(omask);
577 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
539 if (!xdr_bool(xdrsp, &false))
540 return (0);
541 return (1);
542errout:
578 if (!xdr_bool(xdrsp, &false))
579 return (0);
580 return (1);
581errout:
543 sigsetmask(omask);
582 sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
544 return (0);
545}
546
547/*
548 * Called from xdr_explist() to traverse the tree and export the
549 * directory paths.
550 */
551int

--- 103 unchanged lines hidden (view full) ---

655 * instead of just MOUNT_UFS.
656 */
657 num = getmntinfo(&fsp, MNT_NOWAIT);
658 for (i = 0; i < num; i++) {
659 union {
660 struct ufs_args ua;
661 struct iso_args ia;
662 struct mfs_args ma;
583 return (0);
584}
585
586/*
587 * Called from xdr_explist() to traverse the tree and export the
588 * directory paths.
589 */
590int

--- 103 unchanged lines hidden (view full) ---

694 * instead of just MOUNT_UFS.
695 */
696 num = getmntinfo(&fsp, MNT_NOWAIT);
697 for (i = 0; i < num; i++) {
698 union {
699 struct ufs_args ua;
700 struct iso_args ia;
701 struct mfs_args ma;
702#ifdef __NetBSD__
703 struct msdosfs_args da;
663 } targs;
664
704 } targs;
705
706 if (!strcmp(fsp->f_fstypename, MOUNT_MFS) ||
707 !strcmp(fsp->f_fstypename, MOUNT_UFS) ||
708 !strcmp(fsp->f_fstypename, MOUNT_MSDOS) ||
709 !strcmp(fsp->f_fstypename, MOUNT_CD9660)) {
710 targs.ua.fspec = NULL;
711 targs.ua.export.ex_flags = MNT_DELEXPORT;
712 if (mount(fsp->f_fstypename, fsp->f_mntonname,
713#else
714 } targs;
715
665 switch (fsp->f_type) {
666 case MOUNT_MFS:
667 case MOUNT_UFS:
668 case MOUNT_CD9660:
669 case MOUNT_MSDOS:
670 targs.ua.fspec = NULL;
671 targs.ua.export.ex_flags = MNT_DELEXPORT;
672 if (mount(fsp->f_type, fsp->f_mntonname,
716 switch (fsp->f_type) {
717 case MOUNT_MFS:
718 case MOUNT_UFS:
719 case MOUNT_CD9660:
720 case MOUNT_MSDOS:
721 targs.ua.fspec = NULL;
722 targs.ua.export.ex_flags = MNT_DELEXPORT;
723 if (mount(fsp->f_type, fsp->f_mntonname,
724#endif
673 fsp->f_flags | MNT_UPDATE,
674 (caddr_t)&targs) < 0)
675 syslog(LOG_ERR, "Can't delete exports for %s",
676 fsp->f_mntonname);
677 }
678 fsp++;
679 }
680

--- 119 unchanged lines hidden (view full) ---

800 if (has_host) {
801 grp->gr_next = get_grp();
802 grp = grp->gr_next;
803 }
804 if (netgrp) {
805 if (get_host(hst, grp, tgrp)) {
806 syslog(LOG_ERR, "Bad netgroup %s", cp);
807 getexp_err(ep, tgrp);
725 fsp->f_flags | MNT_UPDATE,
726 (caddr_t)&targs) < 0)
727 syslog(LOG_ERR, "Can't delete exports for %s",
728 fsp->f_mntonname);
729 }
730 fsp++;
731 }
732

--- 119 unchanged lines hidden (view full) ---

852 if (has_host) {
853 grp->gr_next = get_grp();
854 grp = grp->gr_next;
855 }
856 if (netgrp) {
857 if (get_host(hst, grp, tgrp)) {
858 syslog(LOG_ERR, "Bad netgroup %s", cp);
859 getexp_err(ep, tgrp);
860 endnetgrent();
808 goto nextline;
809 }
810 } else if (get_host(cp, grp, tgrp)) {
811 getexp_err(ep, tgrp);
812 goto nextline;
813 }
814 has_host = TRUE;
815 } while (netgrp && getnetgrent(&hst, &usr, &dom));

--- 44 unchanged lines hidden (view full) ---

860 goto nextline;
861 }
862 } while (grp->gr_next && (grp = grp->gr_next));
863
864 /*
865 * Success. Update the data structures.
866 */
867 if (has_host) {
861 goto nextline;
862 }
863 } else if (get_host(cp, grp, tgrp)) {
864 getexp_err(ep, tgrp);
865 goto nextline;
866 }
867 has_host = TRUE;
868 } while (netgrp && getnetgrent(&hst, &usr, &dom));

--- 44 unchanged lines hidden (view full) ---

913 goto nextline;
914 }
915 } while (grp->gr_next && (grp = grp->gr_next));
916
917 /*
918 * Success. Update the data structures.
919 */
920 if (has_host) {
868 hang_dirp(dirhead, tgrp, ep, (opt_flags & OP_ALLDIRS));
921 hang_dirp(dirhead, tgrp, ep, opt_flags);
869 grp->gr_next = grphead;
870 grphead = tgrp;
871 } else {
872 hang_dirp(dirhead, (struct grouplist *)NULL, ep,
922 grp->gr_next = grphead;
923 grphead = tgrp;
924 } else {
925 hang_dirp(dirhead, (struct grouplist *)NULL, ep,
873 (opt_flags & OP_ALLDIRS));
926 opt_flags);
874 free_grp(grp);
875 }
876 dirhead = (struct dirlist *)NULL;
877 if ((ep->ex_flag & EX_LINKED) == 0) {
878 ep2 = exphead;
879 epp = &exphead;
880
881 /*

--- 107 unchanged lines hidden (view full) ---

989 return (dp->dp_dirp);
990}
991
992/*
993 * Hang the dir list element off the dirpath binary tree as required
994 * and update the entry for host.
995 */
996void
927 free_grp(grp);
928 }
929 dirhead = (struct dirlist *)NULL;
930 if ((ep->ex_flag & EX_LINKED) == 0) {
931 ep2 = exphead;
932 epp = &exphead;
933
934 /*

--- 107 unchanged lines hidden (view full) ---

1042 return (dp->dp_dirp);
1043}
1044
1045/*
1046 * Hang the dir list element off the dirpath binary tree as required
1047 * and update the entry for host.
1048 */
1049void
997hang_dirp(dp, grp, ep, alldirs)
1050hang_dirp(dp, grp, ep, flags)
998 struct dirlist *dp;
999 struct grouplist *grp;
1000 struct exportlist *ep;
1051 struct dirlist *dp;
1052 struct grouplist *grp;
1053 struct exportlist *ep;
1001 int alldirs;
1054 int flags;
1002{
1003 struct hostlist *hp;
1004 struct dirlist *dp2;
1005
1055{
1056 struct hostlist *hp;
1057 struct dirlist *dp2;
1058
1006 if (alldirs) {
1059 if (flags & OP_ALLDIRS) {
1007 if (ep->ex_defdir)
1008 free((caddr_t)dp);
1009 else
1010 ep->ex_defdir = dp;
1060 if (ep->ex_defdir)
1061 free((caddr_t)dp);
1062 else
1063 ep->ex_defdir = dp;
1011 if (grp == (struct grouplist *)NULL)
1064 if (grp == (struct grouplist *)NULL) {
1012 ep->ex_defdir->dp_flag |= DP_DEFSET;
1065 ep->ex_defdir->dp_flag |= DP_DEFSET;
1013 else while (grp) {
1066 if (flags & OP_KERB)
1067 ep->ex_defdir->dp_flag |= DP_KERB;
1068 } else while (grp) {
1014 hp = get_ht();
1069 hp = get_ht();
1070 if (flags & OP_KERB)
1071 hp->ht_flag |= DP_KERB;
1015 hp->ht_grp = grp;
1016 hp->ht_next = ep->ex_defdir->dp_hosts;
1017 ep->ex_defdir->dp_hosts = hp;
1018 grp = grp->gr_next;
1019 }
1020 } else {
1021
1022 /*
1023 * Loop throught the directories adding them to the tree.
1024 */
1025 while (dp) {
1026 dp2 = dp->dp_left;
1072 hp->ht_grp = grp;
1073 hp->ht_next = ep->ex_defdir->dp_hosts;
1074 ep->ex_defdir->dp_hosts = hp;
1075 grp = grp->gr_next;
1076 }
1077 } else {
1078
1079 /*
1080 * Loop throught the directories adding them to the tree.
1081 */
1082 while (dp) {
1083 dp2 = dp->dp_left;
1027 add_dlist(&ep->ex_dirl, dp, grp);
1084 add_dlist(&ep->ex_dirl, dp, grp, flags);
1028 dp = dp2;
1029 }
1030 }
1031}
1032
1033/*
1034 * Traverse the binary tree either updating a node that is already there
1035 * for the new directory or adding the new node.
1036 */
1037void
1085 dp = dp2;
1086 }
1087 }
1088}
1089
1090/*
1091 * Traverse the binary tree either updating a node that is already there
1092 * for the new directory or adding the new node.
1093 */
1094void
1038add_dlist(dpp, newdp, grp)
1095add_dlist(dpp, newdp, grp, flags)
1039 struct dirlist **dpp;
1040 struct dirlist *newdp;
1041 struct grouplist *grp;
1096 struct dirlist **dpp;
1097 struct dirlist *newdp;
1098 struct grouplist *grp;
1099 int flags;
1042{
1043 struct dirlist *dp;
1044 struct hostlist *hp;
1045 int cmp;
1046
1047 dp = *dpp;
1048 if (dp) {
1049 cmp = strcmp(dp->dp_dirp, newdp->dp_dirp);
1050 if (cmp > 0) {
1100{
1101 struct dirlist *dp;
1102 struct hostlist *hp;
1103 int cmp;
1104
1105 dp = *dpp;
1106 if (dp) {
1107 cmp = strcmp(dp->dp_dirp, newdp->dp_dirp);
1108 if (cmp > 0) {
1051 add_dlist(&dp->dp_left, newdp, grp);
1109 add_dlist(&dp->dp_left, newdp, grp, flags);
1052 return;
1053 } else if (cmp < 0) {
1110 return;
1111 } else if (cmp < 0) {
1054 add_dlist(&dp->dp_right, newdp, grp);
1112 add_dlist(&dp->dp_right, newdp, grp, flags);
1055 return;
1056 } else
1057 free((caddr_t)newdp);
1058 } else {
1059 dp = newdp;
1060 dp->dp_left = (struct dirlist *)NULL;
1061 *dpp = dp;
1062 }
1063 if (grp) {
1064
1065 /*
1066 * Hang all of the host(s) off of the directory point.
1067 */
1068 do {
1069 hp = get_ht();
1113 return;
1114 } else
1115 free((caddr_t)newdp);
1116 } else {
1117 dp = newdp;
1118 dp->dp_left = (struct dirlist *)NULL;
1119 *dpp = dp;
1120 }
1121 if (grp) {
1122
1123 /*
1124 * Hang all of the host(s) off of the directory point.
1125 */
1126 do {
1127 hp = get_ht();
1128 if (flags & OP_KERB)
1129 hp->ht_flag |= DP_KERB;
1070 hp->ht_grp = grp;
1071 hp->ht_next = dp->dp_hosts;
1072 dp->dp_hosts = hp;
1073 grp = grp->gr_next;
1074 } while (grp);
1130 hp->ht_grp = grp;
1131 hp->ht_next = dp->dp_hosts;
1132 dp->dp_hosts = hp;
1133 grp = grp->gr_next;
1134 } while (grp);
1075 } else
1135 } else {
1076 dp->dp_flag |= DP_DEFSET;
1136 dp->dp_flag |= DP_DEFSET;
1137 if (flags & OP_KERB)
1138 dp->dp_flag |= DP_KERB;
1139 }
1077}
1078
1079/*
1080 * Search for a dirpath on the export point.
1081 */
1082struct dirlist *
1083dirp_search(dp, dirpath)
1084 struct dirlist *dp;

--- 12 unchanged lines hidden (view full) ---

1097 }
1098 return (dp);
1099}
1100
1101/*
1102 * Scan for a host match in a directory tree.
1103 */
1104int
1140}
1141
1142/*
1143 * Search for a dirpath on the export point.
1144 */
1145struct dirlist *
1146dirp_search(dp, dirpath)
1147 struct dirlist *dp;

--- 12 unchanged lines hidden (view full) ---

1160 }
1161 return (dp);
1162}
1163
1164/*
1165 * Scan for a host match in a directory tree.
1166 */
1167int
1105chk_host(dp, saddr, defsetp)
1168chk_host(dp, saddr, defsetp, hostsetp)
1106 struct dirlist *dp;
1107 u_long saddr;
1108 int *defsetp;
1169 struct dirlist *dp;
1170 u_long saddr;
1171 int *defsetp;
1172 int *hostsetp;
1109{
1110 struct hostlist *hp;
1111 struct grouplist *grp;
1112 u_long **addrp;
1113
1114 if (dp) {
1115 if (dp->dp_flag & DP_DEFSET)
1173{
1174 struct hostlist *hp;
1175 struct grouplist *grp;
1176 u_long **addrp;
1177
1178 if (dp) {
1179 if (dp->dp_flag & DP_DEFSET)
1116 *defsetp = 1;
1180 *defsetp = dp->dp_flag;
1117 hp = dp->dp_hosts;
1118 while (hp) {
1119 grp = hp->ht_grp;
1120 switch (grp->gr_type) {
1121 case GT_HOST:
1122 addrp = (u_long **)
1123 grp->gr_ptr.gt_hostent->h_addr_list;
1124 while (*addrp) {
1181 hp = dp->dp_hosts;
1182 while (hp) {
1183 grp = hp->ht_grp;
1184 switch (grp->gr_type) {
1185 case GT_HOST:
1186 addrp = (u_long **)
1187 grp->gr_ptr.gt_hostent->h_addr_list;
1188 while (*addrp) {
1125 if (**addrp == saddr)
1189 if (**addrp == saddr) {
1190 *hostsetp = (hp->ht_flag | DP_HOSTSET);
1126 return (1);
1191 return (1);
1192 }
1127 addrp++;
1128 }
1129 break;
1130 case GT_NET:
1131 if ((saddr & grp->gr_ptr.gt_net.nt_mask) ==
1193 addrp++;
1194 }
1195 break;
1196 case GT_NET:
1197 if ((saddr & grp->gr_ptr.gt_net.nt_mask) ==
1132 grp->gr_ptr.gt_net.nt_net)
1198 grp->gr_ptr.gt_net.nt_net) {
1199 *hostsetp = (hp->ht_flag | DP_HOSTSET);
1133 return (1);
1200 return (1);
1201 }
1134 break;
1135 };
1136 hp = hp->ht_next;
1137 }
1138 }
1139 return (0);
1140}
1141
1142/*
1143 * Scan tree for a host that matches the address.
1144 */
1145int
1146scan_tree(dp, saddr)
1147 struct dirlist *dp;
1148 u_long saddr;
1149{
1202 break;
1203 };
1204 hp = hp->ht_next;
1205 }
1206 }
1207 return (0);
1208}
1209
1210/*
1211 * Scan tree for a host that matches the address.
1212 */
1213int
1214scan_tree(dp, saddr)
1215 struct dirlist *dp;
1216 u_long saddr;
1217{
1150 int defset;
1218 int defset, hostset;
1151
1152 if (dp) {
1153 if (scan_tree(dp->dp_left, saddr))
1154 return (1);
1219
1220 if (dp) {
1221 if (scan_tree(dp->dp_left, saddr))
1222 return (1);
1155 if (chk_host(dp, saddr, &defset))
1223 if (chk_host(dp, saddr, &defset, &hostset))
1156 return (1);
1157 if (scan_tree(dp->dp_right, saddr))
1158 return (1);
1159 }
1160 return (0);
1161}
1162
1163/*

--- 143 unchanged lines hidden (view full) ---

1307 char *aptr[2];
1308
1309 if (grp->gr_type != GT_NULL)
1310 return (1);
1311 if ((hp = gethostbyname(cp)) == NULL) {
1312 if (isdigit(*cp)) {
1313 saddr = inet_addr(cp);
1314 if (saddr == -1) {
1224 return (1);
1225 if (scan_tree(dp->dp_right, saddr))
1226 return (1);
1227 }
1228 return (0);
1229}
1230
1231/*

--- 143 unchanged lines hidden (view full) ---

1375 char *aptr[2];
1376
1377 if (grp->gr_type != GT_NULL)
1378 return (1);
1379 if ((hp = gethostbyname(cp)) == NULL) {
1380 if (isdigit(*cp)) {
1381 saddr = inet_addr(cp);
1382 if (saddr == -1) {
1315 syslog(LOG_ERR, "Inet_addr failed");
1383 syslog(LOG_ERR, "Inet_addr failed for %s", cp);
1316 return (1);
1317 }
1318 if ((hp = gethostbyaddr((caddr_t)&saddr, sizeof (saddr),
1319 AF_INET)) == NULL) {
1320 hp = &t_host;
1321 hp->h_name = cp;
1322 hp->h_addrtype = AF_INET;
1323 hp->h_length = sizeof (u_long);
1324 hp->h_addr_list = aptr;
1325 aptr[0] = (char *)&saddr;
1326 aptr[1] = (char *)NULL;
1327 }
1328 } else {
1384 return (1);
1385 }
1386 if ((hp = gethostbyaddr((caddr_t)&saddr, sizeof (saddr),
1387 AF_INET)) == NULL) {
1388 hp = &t_host;
1389 hp->h_name = cp;
1390 hp->h_addrtype = AF_INET;
1391 hp->h_length = sizeof (u_long);
1392 hp->h_addr_list = aptr;
1393 aptr[0] = (char *)&saddr;
1394 aptr[1] = (char *)NULL;
1395 }
1396 } else {
1329 syslog(LOG_ERR, "Gethostbyname failed");
1397 syslog(LOG_ERR, "Gethostbyname failed for %s", cp);
1330 return (1);
1331 }
1332 }
1333 /*
1334 * Sanity check: make sure we don't already have an entry
1335 * for this host in the grouplist.
1336 */
1337 checkgrp = tgrp;

--- 81 unchanged lines hidden (view full) ---

1419get_ht()
1420{
1421 struct hostlist *hp;
1422
1423 hp = (struct hostlist *)malloc(sizeof (struct hostlist));
1424 if (hp == (struct hostlist *)NULL)
1425 out_of_mem();
1426 hp->ht_next = (struct hostlist *)NULL;
1398 return (1);
1399 }
1400 }
1401 /*
1402 * Sanity check: make sure we don't already have an entry
1403 * for this host in the grouplist.
1404 */
1405 checkgrp = tgrp;

--- 81 unchanged lines hidden (view full) ---

1487get_ht()
1488{
1489 struct hostlist *hp;
1490
1491 hp = (struct hostlist *)malloc(sizeof (struct hostlist));
1492 if (hp == (struct hostlist *)NULL)
1493 out_of_mem();
1494 hp->ht_next = (struct hostlist *)NULL;
1495 hp->ht_flag = 0;
1427 return (hp);
1428}
1429
1430#ifdef ISO
1431/*
1432 * Translate an iso address.
1433 */
1434get_isoaddr(cp, grp)

--- 54 unchanged lines hidden (view full) ---

1489 u_long **addrp;
1490 int done;
1491 char savedc = '\0';
1492 struct sockaddr_in sin, imask;
1493 union {
1494 struct ufs_args ua;
1495 struct iso_args ia;
1496 struct mfs_args ma;
1496 return (hp);
1497}
1498
1499#ifdef ISO
1500/*
1501 * Translate an iso address.
1502 */
1503get_isoaddr(cp, grp)

--- 54 unchanged lines hidden (view full) ---

1558 u_long **addrp;
1559 int done;
1560 char savedc = '\0';
1561 struct sockaddr_in sin, imask;
1562 union {
1563 struct ufs_args ua;
1564 struct iso_args ia;
1565 struct mfs_args ma;
1566#ifdef __NetBSD__
1567 struct msdosfs_args da;
1568#endif
1497 } args;
1498 u_long net;
1499
1500 args.ua.fspec = 0;
1501 args.ua.export.ex_flags = exflags;
1502 args.ua.export.ex_anon = *anoncrp;
1503 bzero((char *)&sin, sizeof(sin));
1504 bzero((char *)&imask, sizeof(imask));

--- 59 unchanged lines hidden (view full) ---

1564
1565 /*
1566 * XXX:
1567 * Maybe I should just use the fsb->f_mntonname path instead
1568 * of looping back up the dirp to the mount point??
1569 * Also, needs to know how to export all types of local
1570 * exportable file systems and not just MOUNT_UFS.
1571 */
1569 } args;
1570 u_long net;
1571
1572 args.ua.fspec = 0;
1573 args.ua.export.ex_flags = exflags;
1574 args.ua.export.ex_anon = *anoncrp;
1575 bzero((char *)&sin, sizeof(sin));
1576 bzero((char *)&imask, sizeof(imask));

--- 59 unchanged lines hidden (view full) ---

1636
1637 /*
1638 * XXX:
1639 * Maybe I should just use the fsb->f_mntonname path instead
1640 * of looping back up the dirp to the mount point??
1641 * Also, needs to know how to export all types of local
1642 * exportable file systems and not just MOUNT_UFS.
1643 */
1644#ifdef __NetBSD__
1645 while (mount(fsb->f_fstypename, dirp,
1646#else
1572 while (mount(fsb->f_type, dirp,
1647 while (mount(fsb->f_type, dirp,
1648#endif
1573 fsb->f_flags | MNT_UPDATE, (caddr_t)&args) < 0) {
1574 if (cp)
1575 *cp-- = savedc;
1576 else
1577 cp = dirp + dirplen - 1;
1578 if (errno == EPERM) {
1579 syslog(LOG_ERR,
1580 "Can't change attributes for %s.\n", dirp);

--- 447 unchanged lines hidden (view full) ---

2028 char *cp;
2029 int ret = 1;
2030 struct stat sb;
2031
2032 cp = dirp + 1;
2033 while (*cp && ret) {
2034 if (*cp == '/') {
2035 *cp = '\0';
1649 fsb->f_flags | MNT_UPDATE, (caddr_t)&args) < 0) {
1650 if (cp)
1651 *cp-- = savedc;
1652 else
1653 cp = dirp + dirplen - 1;
1654 if (errno == EPERM) {
1655 syslog(LOG_ERR,
1656 "Can't change attributes for %s.\n", dirp);

--- 447 unchanged lines hidden (view full) ---

2104 char *cp;
2105 int ret = 1;
2106 struct stat sb;
2107
2108 cp = dirp + 1;
2109 while (*cp && ret) {
2110 if (*cp == '/') {
2111 *cp = '\0';
2036 if (lstat(dirp, &sb) < 0 ||
2037 (sb.st_mode & S_IFMT) != S_IFDIR)
2112 if (lstat(dirp, &sb) < 0 || !S_ISDIR(sb.st_mode))
2038 ret = 0;
2039 *cp = '/';
2040 }
2041 cp++;
2042 }
2113 ret = 0;
2114 *cp = '/';
2115 }
2116 cp++;
2117 }
2043 if (lstat(dirp, &sb) < 0 ||
2044 (sb.st_mode & S_IFMT) != S_IFDIR)
2118 if (lstat(dirp, &sb) < 0 || !S_ISDIR(sb.st_mode))
2045 ret = 0;
2046 return (ret);
2047}
2119 ret = 0;
2120 return (ret);
2121}
2122
2123/*
2124 * Just translate an ascii string to an integer.
2125 */
2126int
2127get_num(cp)
2128 register char *cp;
2129{
2130 register int res = 0;
2131
2132 while (*cp) {
2133 if (*cp < '0' || *cp > '9')
2134 return (-1);
2135 res = res * 10 + (*cp++ - '0');
2136 }
2137 return (res);
2138}