| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: mountd.c,v 1.4 2010/07/28 15:15:22 pooka Exp $ */ | | 1 | /* $NetBSD: mountd.c,v 1.5 2010/12/31 17:59:24 pooka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1989, 1993 | | 4 | * Copyright (c) 1989, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Herb Hasler and Rick Macklem at The University of Guelph. | | 8 | * Herb Hasler and Rick Macklem at The University of Guelph. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -32,27 +32,27 @@ | | | @@ -32,27 +32,27 @@ |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | #ifndef lint | | 36 | #ifndef lint |
37 | __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ | | 37 | __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ |
38 | The Regents of the University of California. All rights reserved."); | | 38 | The Regents of the University of California. All rights reserved."); |
39 | #endif /* not lint */ | | 39 | #endif /* not lint */ |
40 | | | 40 | |
41 | #ifndef lint | | 41 | #ifndef lint |
42 | #if 0 | | 42 | #if 0 |
43 | static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; | | 43 | static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; |
44 | #else | | 44 | #else |
45 | __RCSID("$NetBSD: mountd.c,v 1.4 2010/07/28 15:15:22 pooka Exp $"); | | 45 | __RCSID("$NetBSD: mountd.c,v 1.5 2010/12/31 17:59:24 pooka Exp $"); |
46 | #endif | | 46 | #endif |
47 | #endif /* not lint */ | | 47 | #endif /* not lint */ |
48 | | | 48 | |
49 | #include <sys/param.h> | | 49 | #include <sys/param.h> |
50 | #include <sys/file.h> | | 50 | #include <sys/file.h> |
51 | #include <sys/ioctl.h> | | 51 | #include <sys/ioctl.h> |
52 | #include <sys/mount.h> | | 52 | #include <sys/mount.h> |
53 | #include <sys/socket.h> | | 53 | #include <sys/socket.h> |
54 | #include <sys/stat.h> | | 54 | #include <sys/stat.h> |
55 | #include <syslog.h> | | 55 | #include <syslog.h> |
56 | #include <sys/ucred.h> | | 56 | #include <sys/ucred.h> |
57 | | | 57 | |
58 | #include <rpc/rpc.h> | | 58 | #include <rpc/rpc.h> |
| @@ -200,27 +200,29 @@ static int get_host __P((const char *, s | | | @@ -200,27 +200,29 @@ static int get_host __P((const char *, s |
200 | static struct hostlist *get_ht __P((void)); | | 200 | static struct hostlist *get_ht __P((void)); |
201 | static void get_mountlist __P((void)); | | 201 | static void get_mountlist __P((void)); |
202 | static int get_net __P((char *, struct netmsk *, int)); | | 202 | static int get_net __P((char *, struct netmsk *, int)); |
203 | static void free_exp_grp __P((struct exportlist *, struct grouplist *)); | | 203 | static void free_exp_grp __P((struct exportlist *, struct grouplist *)); |
204 | static struct grouplist *get_grp __P((void)); | | 204 | static struct grouplist *get_grp __P((void)); |
205 | static void hang_dirp __P((struct dirlist *, struct grouplist *, | | 205 | static void hang_dirp __P((struct dirlist *, struct grouplist *, |
206 | struct exportlist *, int)); | | 206 | struct exportlist *, int)); |
207 | static void mntsrv __P((struct svc_req *, SVCXPRT *)); | | 207 | static void mntsrv __P((struct svc_req *, SVCXPRT *)); |
208 | static void nextfield __P((char **, char **)); | | 208 | static void nextfield __P((char **, char **)); |
209 | static void parsecred __P((char *, struct uucred *)); | | 209 | static void parsecred __P((char *, struct uucred *)); |
210 | static int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *)); | | 210 | static int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *)); |
211 | static int scan_tree __P((struct dirlist *, struct sockaddr *)); | | 211 | static int scan_tree __P((struct dirlist *, struct sockaddr *)); |
212 | static void send_umntall __P((int)); | | 212 | static void send_umntall __P((int)); |
| | | 213 | #if 0 |
213 | static int umntall_each __P((caddr_t, struct sockaddr_in *)); | | 214 | static int umntall_each __P((caddr_t, struct sockaddr_in *)); |
| | | 215 | #endif |
214 | static int xdr_dir __P((XDR *, char *)); | | 216 | static int xdr_dir __P((XDR *, char *)); |
215 | static int xdr_explist __P((XDR *, caddr_t)); | | 217 | static int xdr_explist __P((XDR *, caddr_t)); |
216 | static int xdr_fhs __P((XDR *, caddr_t)); | | 218 | static int xdr_fhs __P((XDR *, caddr_t)); |
217 | static int xdr_mlist __P((XDR *, caddr_t)); | | 219 | static int xdr_mlist __P((XDR *, caddr_t)); |
218 | static int bitcmp __P((void *, void *, int)); | | 220 | static int bitcmp __P((void *, void *, int)); |
219 | static int netpartcmp __P((struct sockaddr *, struct sockaddr *, int)); | | 221 | static int netpartcmp __P((struct sockaddr *, struct sockaddr *, int)); |
220 | static int sacmp __P((struct sockaddr *, struct sockaddr *)); | | 222 | static int sacmp __P((struct sockaddr *, struct sockaddr *)); |
221 | static int allones __P((struct sockaddr_storage *, int)); | | 223 | static int allones __P((struct sockaddr_storage *, int)); |
222 | static int countones __P((struct sockaddr *)); | | 224 | static int countones __P((struct sockaddr *)); |
223 | static void bind_resv_port __P((int, sa_family_t, in_port_t)); | | 225 | static void bind_resv_port __P((int, sa_family_t, in_port_t)); |
224 | static void no_nfs(int); | | 226 | static void no_nfs(int); |
225 | static struct exportlist *exphead; | | 227 | static struct exportlist *exphead; |
226 | static struct mountlist *mlhead; | | 228 | static struct mountlist *mlhead; |
| @@ -2376,38 +2378,42 @@ add_mlist(hostp, dirp, flags) | | | @@ -2376,38 +2378,42 @@ add_mlist(hostp, dirp, flags) |
2376 | (void)fprintf(mlfile, "%s %s\n", mlp->ml_host, mlp->ml_dirp); | | 2378 | (void)fprintf(mlfile, "%s %s\n", mlp->ml_host, mlp->ml_dirp); |
2377 | (void)fclose(mlfile); | | 2379 | (void)fclose(mlfile); |
2378 | } | | 2380 | } |
2379 | | | 2381 | |
2380 | /* | | 2382 | /* |
2381 | * This function is called via. SIGTERM when the system is going down. | | 2383 | * This function is called via. SIGTERM when the system is going down. |
2382 | * It sends a broadcast RPCMNT_UMNTALL. | | 2384 | * It sends a broadcast RPCMNT_UMNTALL. |
2383 | */ | | 2385 | */ |
2384 | /* ARGSUSED */ | | 2386 | /* ARGSUSED */ |
2385 | static void | | 2387 | static void |
2386 | send_umntall(n) | | 2388 | send_umntall(n) |
2387 | int n; | | 2389 | int n; |
2388 | { | | 2390 | { |
| | | 2391 | #if 0 |
2389 | (void)clnt_broadcast(RPCPROG_MNT, RPCMNT_VER1, RPCMNT_UMNTALL, | | 2392 | (void)clnt_broadcast(RPCPROG_MNT, RPCMNT_VER1, RPCMNT_UMNTALL, |
2390 | xdr_void, NULL, xdr_void, NULL, (resultproc_t)umntall_each); | | 2393 | xdr_void, NULL, xdr_void, NULL, (resultproc_t)umntall_each); |
| | | 2394 | #endif |
2391 | exit(0); | | 2395 | exit(0); |
2392 | } | | 2396 | } |
2393 | | | 2397 | |
| | | 2398 | #if 0 |
2394 | static int | | 2399 | static int |
2395 | umntall_each(resultsp, raddr) | | 2400 | umntall_each(resultsp, raddr) |
2396 | caddr_t resultsp; | | 2401 | caddr_t resultsp; |
2397 | struct sockaddr_in *raddr; | | 2402 | struct sockaddr_in *raddr; |
2398 | { | | 2403 | { |
2399 | return (1); | | 2404 | return (1); |
2400 | } | | 2405 | } |
| | | 2406 | #endif |
2401 | | | 2407 | |
2402 | /* | | 2408 | /* |
2403 | * Free up a group list. | | 2409 | * Free up a group list. |
2404 | */ | | 2410 | */ |
2405 | static void | | 2411 | static void |
2406 | free_grp(grp) | | 2412 | free_grp(grp) |
2407 | struct grouplist *grp; | | 2413 | struct grouplist *grp; |
2408 | { | | 2414 | { |
2409 | | | 2415 | |
2410 | if (grp->gr_type == GT_HOST) { | | 2416 | if (grp->gr_type == GT_HOST) { |
2411 | if (grp->gr_ptr.gt_addrinfo != NULL) | | 2417 | if (grp->gr_ptr.gt_addrinfo != NULL) |
2412 | freeaddrinfo(grp->gr_ptr.gt_addrinfo); | | 2418 | freeaddrinfo(grp->gr_ptr.gt_addrinfo); |
2413 | } else if (grp->gr_type == GT_NET) { | | 2419 | } else if (grp->gr_type == GT_NET) { |