summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/017-wrs-dynamic-rpc.patch
blob: 18e12de789efd3dd30cb875bb3c989a03a69b2fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# Add the ability to choose alternate RPC ports at runtime and disable
# security so that it can run as a userland process
# Patch origin: Wind River

Index: nfs-server-2.2beta47/auth_init.c
===================================================================
--- nfs-server-2.2beta47.orig/auth_init.c
+++ nfs-server-2.2beta47/auth_init.c
@@ -409,6 +409,7 @@ auth_init(char *fname)
 		fname = EXPORTSFILE;
 	auth_file = fname;	/* Save for re-initialization */
 
+#ifdef ROOT_LEVEL_SECURITY
 	/* Check protection of exports file. */
 	switch(iCheckAccess(auth_file, EXPORTSOWNERUID, EXPORTSOWNERGID)) {
 	case FACCESSWRITABLE:
@@ -424,6 +425,7 @@ auth_init(char *fname)
 		Dprintf(L_ERROR, "exiting because of security violation.\n");
 		exit(1);
 	}
+#endif
 
 	if ((ef = fopen(fname, "r")) == NULL) {
 		Dprintf(L_ERROR, "Could not open exports file %s: %s\n",
Index: nfs-server-2.2beta47/nfsd.c
===================================================================
--- nfs-server-2.2beta47.orig/nfsd.c
+++ nfs-server-2.2beta47/nfsd.c
@@ -46,6 +46,7 @@ static char pathbuf_1[NFS_MAXPATHLEN + N
 
 extern char version[];
 static char *program_name;
+static int nfs_prog = NFS_PROGRAM;
 
 /*
  * Option table
@@ -60,6 +61,7 @@ static struct option longopts[] = {
       { "help",			0,			0,	'h' },
       { "log-transfers",	0,			0,	'l' },
       { "allow-non-root",	0,			0,	'n' },
+      { "prog",			required_argument,	0,	'g' },
       { "port",			required_argument,	0,	'P' },
       { "promiscuous",		0,			0,	'p' },
       { "re-export",		0,			0,	'r' },
@@ -73,9 +75,10 @@ static struct option longopts[] = {
       { "udp-only",		0,			0,	OPT_NOTCP },
       {	"loopback-only",	0,			0,	OPT_LOOPBACK },
       { "hashed-inodes",	0,			0,	'I' },
+      { "nfs-pid",	required_argument,			0,	'N' },
       { NULL,		0,	0, 0 }
 };
-static const char *	shortopts = "a:d:Ff:hlnP:prR:tvz::";
+static const char *	shortopts = "a:d:Ff:g:hlnN:P:prR:tvz::";
 
 /*
  * Table of supported versions
@@ -1003,6 +1006,8 @@ main(int argc, char **argv)
 	int	failsafe_level = 0;
 	int	c;
 	int	i, ncopies = 1;
+    char *nfs_pid_file = NULL;
+
 
 	program_name = argv[0];
 	chdir("/");
@@ -1026,9 +1031,15 @@ main(int argc, char **argv)
 		case 'f':
 			auth_file = optarg;
 			break;
+		case 'g':
+			nfs_prog = atoi(optarg);
+			break;
 		case 'l':
 			log_transfers = 1;
 			break;
+        case 'N':
+            nfs_pid_file = strdup(optarg);
+            break;
 		case 'n':
 			allow_non_root = 1;
 			break;
@@ -1114,7 +1125,7 @@ main(int argc, char **argv)
 	log_open("nfsd", foreground);
 
 	/* Initialize RPC stuff */
-	rpc_init("nfsd", NFS_PROGRAM, nfsd_versions, nfs_dispatch,
+	rpc_init("nfsd", nfs_prog, nfsd_versions, nfs_dispatch,
 				nfsport, NFS_MAXDATA);
 
 	if (_rpcpmstart) {
@@ -1145,7 +1156,10 @@ main(int argc, char **argv)
 	/* Initialize the AUTH module. */
 	auth_init(auth_file);
 
-	setpidpath(_PATH_NFSD_PIDFILE);
+    if (nfs_pid_file == 0)
+        nfs_pid_file = _PATH_NFSD_PIDFILE;
+    setpidpath(nfs_pid_file);
+
 	if (failsafe_level == 0) {
 		/* Start multiple copies of the server */
 		writepid(getpid(), 1);
@@ -1215,9 +1229,11 @@ usage(FILE *fp, int n)
 	fprintf(fp,
 "Usage: %s [-Fhnpv] [-d kind] [-f exports-file] [-P port] [--version]\n"
 "       [--debug kind] [--exports-file=file] [--port port]\n"
+"       [--prog alternate_rpc_port_nubmer]\n"
 "       [--allow-non-root] [--promiscuous] [--version] [--foreground]\n"
 "       [--re-export] [--log-transfers] [--public-root path]\n"
 "       [--no-spoof-trace] [--no-cross-mounts] [--hashed-inodes] [--help]\n"
+"       [--nfs-pid file]\n"
 						, program_name);
 	exit(n);
 }
@@ -1234,7 +1250,7 @@ sigterm(int sig)
 static void
 terminate(void)
 {
-	rpc_exit(NFS_PROGRAM, nfsd_versions);
+	rpc_exit(nfs_prog, nfsd_versions);
 	efs_shutdown();
 }
 
Index: nfs-server-2.2beta47/mountd.c
===================================================================
--- nfs-server-2.2beta47.orig/mountd.c
+++ nfs-server-2.2beta47/mountd.c
@@ -42,6 +42,7 @@ int hashed_inodes; /* dummy */
 static void	usage(FILE *, int);
 static void	terminate(void);
 static RETSIGTYPE sigterm(int sig);
+int mount_prog = MOUNTPROG;
 
 /*
  * Option table for mountd
@@ -55,6 +56,7 @@ static struct option longopts[] =
       { "help",			0,			0,	'h' },
       { "allow-non-root",	0,			0,	'n' },
       { "port",			required_argument,	0,	'P' },
+      { "prog",			required_argument,	0,	'g' },
       { "promiscous",		0,			0,	'p' },
       { "re-export",		0,			0,	'r' },
       {	"no-spoof-trace",	0,			0,	't' },
@@ -63,9 +65,11 @@ static struct option longopts[] =
       { "no-cross-mounts",	0,			0,	'x' },
       { "no-tcp",		0,			0,	OPT_NOTCP },
       {	"loopback-only",	0,			0,	OPT_LOOPBACK },
+      { "mount-pid",	required_argument,			0,	'N' },
+      { "rmtab",	required_argument,			0,	'R' },
       { NULL,			0,			0,	0 }
 };
-static const char *	shortopts = "Fd:f:hnpP:rtvz::";
+static const char *	shortopts = "Fd:f:g:hnN:pP:rRtvz::";
 
 /*
  * Table of supported versions
@@ -318,6 +322,7 @@ main(int argc, char **argv)
 	int failsafe_level = 0;
 	int port = 0;
 	int c;
+    char *mount_pid_file = NULL;
 
 	program_name = argv[0];
 
@@ -340,9 +345,15 @@ main(int argc, char **argv)
 		case 'f':
 			auth_file = optarg;
 			break;
+		case 'g':
+			mount_prog = port = atoi(optarg);
+			break;
 		case 'n':
 			allow_non_root = 1;
 			break;
+        case 'N':
+            mount_pid_file = strdup(optarg);
+            break;
 		case 'P':
 			port = atoi(optarg);
 			if (port <= 0 || port > 65535) {
@@ -354,6 +365,9 @@ main(int argc, char **argv)
 		case 'p':
 			promiscuous = 1;
 			break;
+        case 'R':
+            _PATH_RMTAB = strdup(optarg);
+            break;
 		case 'r':
 			re_export = 1;
 			break;
@@ -401,7 +415,7 @@ main(int argc, char **argv)
 	log_open("mountd", foreground);
 
 	/* Create services and register with portmapper */
-	rpc_init("mountd", MOUNTPROG, mountd_versions, mount_dispatch, port, 0);
+	rpc_init("mountd", mount_prog, mountd_versions, mount_dispatch, port, 0);
 
 	if (_rpcpmstart) {
 		/* Always foreground mode */
@@ -422,7 +436,9 @@ main(int argc, char **argv)
 	auth_init(auth_file);
 
 	/* Write pidfile */
-	setpidpath(_PATH_MOUNTD_PIDFILE);
+    if (mount_pid_file == 0)
+        mount_pid_file = _PATH_MOUNTD_PIDFILE;
+    setpidpath(mount_pid_file);
 	writepid(getpid(), 1);
 
 	/* Failsafe mode */
@@ -453,7 +469,9 @@ usage(FILE *fp, int n)
 				program_name);
 	fprintf(fp, "       [--debug kind] [--help] [--allow-non-root]\n");
 	fprintf(fp, "       [--promiscuous] [--version] [--port portnum]\n");
+	fprintf(fp, "       [--prog alternate_rpc_port_nubmer]\n");
 	fprintf(fp, "       [--exports-file=file] [--no-cross-mounts]\n");
+    fprintf(fp, "       [--mount-pid file] [--rmtab file]\n");
 	exit(n);
 }
 
@@ -467,7 +485,7 @@ sigterm(int sig)
 static void
 terminate(void)
 {
-	rpc_exit(MOUNTPROG, mountd_versions);
+	rpc_exit(mount_prog, mountd_versions);
 }
 
 RETSIGTYPE
Index: nfs-server-2.2beta47/rmtab.c
===================================================================
--- nfs-server-2.2beta47.orig/rmtab.c
+++ nfs-server-2.2beta47/rmtab.c
@@ -14,6 +14,8 @@ static char *	rmtab_gethost(struct svc_r
 static int	rmtab_insert(char *, char *);
 static void	rmtab_file(char);
 
+char *_PATH_RMTAB = _PATH_RMTAB_VAL;
+
 /*
  * global top to linklist
  */
Index: nfs-server-2.2beta47/rmtab.h
===================================================================
--- nfs-server-2.2beta47.orig/rmtab.h
+++ nfs-server-2.2beta47/rmtab.h
@@ -11,8 +11,9 @@
  * Location of rmtab file. /etc/rmtab is the standard on most systems.
  */
 #include <paths.h>
-#ifndef _PATH_RMTAB
-#define _PATH_RMTAB	"/etc/rmtab"
+extern char *_PATH_RMTAB;
+#ifndef _PATH_RMTAB_VAL
+#define _PATH_RMTAB_VAL	"/etc/rmtab"
 #endif
 
 extern void 		rmtab_add_client(dirpath, struct svc_req *);
OpenPOWER on IntegriCloud