diff options
Diffstat (limited to 'meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/017-wrs-dynamic-rpc.patch')
-rw-r--r-- | meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/017-wrs-dynamic-rpc.patch | 258 |
1 files changed, 258 insertions, 0 deletions
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/017-wrs-dynamic-rpc.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/017-wrs-dynamic-rpc.patch new file mode 100644 index 0000000000..18e12de789 --- /dev/null +++ b/meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/017-wrs-dynamic-rpc.patch | |||
@@ -0,0 +1,258 @@ | |||
1 | # Add the ability to choose alternate RPC ports at runtime and disable | ||
2 | # security so that it can run as a userland process | ||
3 | # Patch origin: Wind River | ||
4 | |||
5 | Index: nfs-server-2.2beta47/auth_init.c | ||
6 | =================================================================== | ||
7 | --- nfs-server-2.2beta47.orig/auth_init.c | ||
8 | +++ nfs-server-2.2beta47/auth_init.c | ||
9 | @@ -409,6 +409,7 @@ auth_init(char *fname) | ||
10 | fname = EXPORTSFILE; | ||
11 | auth_file = fname; /* Save for re-initialization */ | ||
12 | |||
13 | +#ifdef ROOT_LEVEL_SECURITY | ||
14 | /* Check protection of exports file. */ | ||
15 | switch(iCheckAccess(auth_file, EXPORTSOWNERUID, EXPORTSOWNERGID)) { | ||
16 | case FACCESSWRITABLE: | ||
17 | @@ -424,6 +425,7 @@ auth_init(char *fname) | ||
18 | Dprintf(L_ERROR, "exiting because of security violation.\n"); | ||
19 | exit(1); | ||
20 | } | ||
21 | +#endif | ||
22 | |||
23 | if ((ef = fopen(fname, "r")) == NULL) { | ||
24 | Dprintf(L_ERROR, "Could not open exports file %s: %s\n", | ||
25 | Index: nfs-server-2.2beta47/nfsd.c | ||
26 | =================================================================== | ||
27 | --- nfs-server-2.2beta47.orig/nfsd.c | ||
28 | +++ nfs-server-2.2beta47/nfsd.c | ||
29 | @@ -46,6 +46,7 @@ static char pathbuf_1[NFS_MAXPATHLEN + N | ||
30 | |||
31 | extern char version[]; | ||
32 | static char *program_name; | ||
33 | +static int nfs_prog = NFS_PROGRAM; | ||
34 | |||
35 | /* | ||
36 | * Option table | ||
37 | @@ -60,6 +61,7 @@ static struct option longopts[] = { | ||
38 | { "help", 0, 0, 'h' }, | ||
39 | { "log-transfers", 0, 0, 'l' }, | ||
40 | { "allow-non-root", 0, 0, 'n' }, | ||
41 | + { "prog", required_argument, 0, 'g' }, | ||
42 | { "port", required_argument, 0, 'P' }, | ||
43 | { "promiscuous", 0, 0, 'p' }, | ||
44 | { "re-export", 0, 0, 'r' }, | ||
45 | @@ -73,9 +75,10 @@ static struct option longopts[] = { | ||
46 | { "udp-only", 0, 0, OPT_NOTCP }, | ||
47 | { "loopback-only", 0, 0, OPT_LOOPBACK }, | ||
48 | { "hashed-inodes", 0, 0, 'I' }, | ||
49 | + { "nfs-pid", required_argument, 0, 'N' }, | ||
50 | { NULL, 0, 0, 0 } | ||
51 | }; | ||
52 | -static const char * shortopts = "a:d:Ff:hlnP:prR:tvz::"; | ||
53 | +static const char * shortopts = "a:d:Ff:g:hlnN:P:prR:tvz::"; | ||
54 | |||
55 | /* | ||
56 | * Table of supported versions | ||
57 | @@ -1003,6 +1006,8 @@ main(int argc, char **argv) | ||
58 | int failsafe_level = 0; | ||
59 | int c; | ||
60 | int i, ncopies = 1; | ||
61 | + char *nfs_pid_file = NULL; | ||
62 | + | ||
63 | |||
64 | program_name = argv[0]; | ||
65 | chdir("/"); | ||
66 | @@ -1026,9 +1031,15 @@ main(int argc, char **argv) | ||
67 | case 'f': | ||
68 | auth_file = optarg; | ||
69 | break; | ||
70 | + case 'g': | ||
71 | + nfs_prog = atoi(optarg); | ||
72 | + break; | ||
73 | case 'l': | ||
74 | log_transfers = 1; | ||
75 | break; | ||
76 | + case 'N': | ||
77 | + nfs_pid_file = strdup(optarg); | ||
78 | + break; | ||
79 | case 'n': | ||
80 | allow_non_root = 1; | ||
81 | break; | ||
82 | @@ -1114,7 +1125,7 @@ main(int argc, char **argv) | ||
83 | log_open("nfsd", foreground); | ||
84 | |||
85 | /* Initialize RPC stuff */ | ||
86 | - rpc_init("nfsd", NFS_PROGRAM, nfsd_versions, nfs_dispatch, | ||
87 | + rpc_init("nfsd", nfs_prog, nfsd_versions, nfs_dispatch, | ||
88 | nfsport, NFS_MAXDATA); | ||
89 | |||
90 | if (_rpcpmstart) { | ||
91 | @@ -1145,7 +1156,10 @@ main(int argc, char **argv) | ||
92 | /* Initialize the AUTH module. */ | ||
93 | auth_init(auth_file); | ||
94 | |||
95 | - setpidpath(_PATH_NFSD_PIDFILE); | ||
96 | + if (nfs_pid_file == 0) | ||
97 | + nfs_pid_file = _PATH_NFSD_PIDFILE; | ||
98 | + setpidpath(nfs_pid_file); | ||
99 | + | ||
100 | if (failsafe_level == 0) { | ||
101 | /* Start multiple copies of the server */ | ||
102 | writepid(getpid(), 1); | ||
103 | @@ -1215,9 +1229,11 @@ usage(FILE *fp, int n) | ||
104 | fprintf(fp, | ||
105 | "Usage: %s [-Fhnpv] [-d kind] [-f exports-file] [-P port] [--version]\n" | ||
106 | " [--debug kind] [--exports-file=file] [--port port]\n" | ||
107 | +" [--prog alternate_rpc_port_nubmer]\n" | ||
108 | " [--allow-non-root] [--promiscuous] [--version] [--foreground]\n" | ||
109 | " [--re-export] [--log-transfers] [--public-root path]\n" | ||
110 | " [--no-spoof-trace] [--no-cross-mounts] [--hashed-inodes] [--help]\n" | ||
111 | +" [--nfs-pid file]\n" | ||
112 | , program_name); | ||
113 | exit(n); | ||
114 | } | ||
115 | @@ -1234,7 +1250,7 @@ sigterm(int sig) | ||
116 | static void | ||
117 | terminate(void) | ||
118 | { | ||
119 | - rpc_exit(NFS_PROGRAM, nfsd_versions); | ||
120 | + rpc_exit(nfs_prog, nfsd_versions); | ||
121 | efs_shutdown(); | ||
122 | } | ||
123 | |||
124 | Index: nfs-server-2.2beta47/mountd.c | ||
125 | =================================================================== | ||
126 | --- nfs-server-2.2beta47.orig/mountd.c | ||
127 | +++ nfs-server-2.2beta47/mountd.c | ||
128 | @@ -42,6 +42,7 @@ int hashed_inodes; /* dummy */ | ||
129 | static void usage(FILE *, int); | ||
130 | static void terminate(void); | ||
131 | static RETSIGTYPE sigterm(int sig); | ||
132 | +int mount_prog = MOUNTPROG; | ||
133 | |||
134 | /* | ||
135 | * Option table for mountd | ||
136 | @@ -55,6 +56,7 @@ static struct option longopts[] = | ||
137 | { "help", 0, 0, 'h' }, | ||
138 | { "allow-non-root", 0, 0, 'n' }, | ||
139 | { "port", required_argument, 0, 'P' }, | ||
140 | + { "prog", required_argument, 0, 'g' }, | ||
141 | { "promiscous", 0, 0, 'p' }, | ||
142 | { "re-export", 0, 0, 'r' }, | ||
143 | { "no-spoof-trace", 0, 0, 't' }, | ||
144 | @@ -63,9 +65,11 @@ static struct option longopts[] = | ||
145 | { "no-cross-mounts", 0, 0, 'x' }, | ||
146 | { "no-tcp", 0, 0, OPT_NOTCP }, | ||
147 | { "loopback-only", 0, 0, OPT_LOOPBACK }, | ||
148 | + { "mount-pid", required_argument, 0, 'N' }, | ||
149 | + { "rmtab", required_argument, 0, 'R' }, | ||
150 | { NULL, 0, 0, 0 } | ||
151 | }; | ||
152 | -static const char * shortopts = "Fd:f:hnpP:rtvz::"; | ||
153 | +static const char * shortopts = "Fd:f:g:hnN:pP:rRtvz::"; | ||
154 | |||
155 | /* | ||
156 | * Table of supported versions | ||
157 | @@ -318,6 +322,7 @@ main(int argc, char **argv) | ||
158 | int failsafe_level = 0; | ||
159 | int port = 0; | ||
160 | int c; | ||
161 | + char *mount_pid_file = NULL; | ||
162 | |||
163 | program_name = argv[0]; | ||
164 | |||
165 | @@ -340,9 +345,15 @@ main(int argc, char **argv) | ||
166 | case 'f': | ||
167 | auth_file = optarg; | ||
168 | break; | ||
169 | + case 'g': | ||
170 | + mount_prog = port = atoi(optarg); | ||
171 | + break; | ||
172 | case 'n': | ||
173 | allow_non_root = 1; | ||
174 | break; | ||
175 | + case 'N': | ||
176 | + mount_pid_file = strdup(optarg); | ||
177 | + break; | ||
178 | case 'P': | ||
179 | port = atoi(optarg); | ||
180 | if (port <= 0 || port > 65535) { | ||
181 | @@ -354,6 +365,9 @@ main(int argc, char **argv) | ||
182 | case 'p': | ||
183 | promiscuous = 1; | ||
184 | break; | ||
185 | + case 'R': | ||
186 | + _PATH_RMTAB = strdup(optarg); | ||
187 | + break; | ||
188 | case 'r': | ||
189 | re_export = 1; | ||
190 | break; | ||
191 | @@ -401,7 +415,7 @@ main(int argc, char **argv) | ||
192 | log_open("mountd", foreground); | ||
193 | |||
194 | /* Create services and register with portmapper */ | ||
195 | - rpc_init("mountd", MOUNTPROG, mountd_versions, mount_dispatch, port, 0); | ||
196 | + rpc_init("mountd", mount_prog, mountd_versions, mount_dispatch, port, 0); | ||
197 | |||
198 | if (_rpcpmstart) { | ||
199 | /* Always foreground mode */ | ||
200 | @@ -422,7 +436,9 @@ main(int argc, char **argv) | ||
201 | auth_init(auth_file); | ||
202 | |||
203 | /* Write pidfile */ | ||
204 | - setpidpath(_PATH_MOUNTD_PIDFILE); | ||
205 | + if (mount_pid_file == 0) | ||
206 | + mount_pid_file = _PATH_MOUNTD_PIDFILE; | ||
207 | + setpidpath(mount_pid_file); | ||
208 | writepid(getpid(), 1); | ||
209 | |||
210 | /* Failsafe mode */ | ||
211 | @@ -453,7 +469,9 @@ usage(FILE *fp, int n) | ||
212 | program_name); | ||
213 | fprintf(fp, " [--debug kind] [--help] [--allow-non-root]\n"); | ||
214 | fprintf(fp, " [--promiscuous] [--version] [--port portnum]\n"); | ||
215 | + fprintf(fp, " [--prog alternate_rpc_port_nubmer]\n"); | ||
216 | fprintf(fp, " [--exports-file=file] [--no-cross-mounts]\n"); | ||
217 | + fprintf(fp, " [--mount-pid file] [--rmtab file]\n"); | ||
218 | exit(n); | ||
219 | } | ||
220 | |||
221 | @@ -467,7 +485,7 @@ sigterm(int sig) | ||
222 | static void | ||
223 | terminate(void) | ||
224 | { | ||
225 | - rpc_exit(MOUNTPROG, mountd_versions); | ||
226 | + rpc_exit(mount_prog, mountd_versions); | ||
227 | } | ||
228 | |||
229 | RETSIGTYPE | ||
230 | Index: nfs-server-2.2beta47/rmtab.c | ||
231 | =================================================================== | ||
232 | --- nfs-server-2.2beta47.orig/rmtab.c | ||
233 | +++ nfs-server-2.2beta47/rmtab.c | ||
234 | @@ -14,6 +14,8 @@ static char * rmtab_gethost(struct svc_r | ||
235 | static int rmtab_insert(char *, char *); | ||
236 | static void rmtab_file(char); | ||
237 | |||
238 | +char *_PATH_RMTAB = _PATH_RMTAB_VAL; | ||
239 | + | ||
240 | /* | ||
241 | * global top to linklist | ||
242 | */ | ||
243 | Index: nfs-server-2.2beta47/rmtab.h | ||
244 | =================================================================== | ||
245 | --- nfs-server-2.2beta47.orig/rmtab.h | ||
246 | +++ nfs-server-2.2beta47/rmtab.h | ||
247 | @@ -11,8 +11,9 @@ | ||
248 | * Location of rmtab file. /etc/rmtab is the standard on most systems. | ||
249 | */ | ||
250 | #include <paths.h> | ||
251 | -#ifndef _PATH_RMTAB | ||
252 | -#define _PATH_RMTAB "/etc/rmtab" | ||
253 | +extern char *_PATH_RMTAB; | ||
254 | +#ifndef _PATH_RMTAB_VAL | ||
255 | +#define _PATH_RMTAB_VAL "/etc/rmtab" | ||
256 | #endif | ||
257 | |||
258 | extern void rmtab_add_client(dirpath, struct svc_req *); | ||