Rename patches to match conventions, second round; *ouch*
[openwrt/svn-archive/archive.git] / net / nfs-server / patches / 03-debian_subset.patch
1 --- nfs-user-server-2.2beta47.orig/BUILD
2 +++ nfs-user-server-2.2beta47/BUILD
3 @@ -48,7 +48,7 @@
4 shift
5 done
6
7 -function read_yesno {
8 +read_yesno() {
9 ans=""
10 echo >&2
11 default=$2
12 @@ -84,7 +84,7 @@
13 echo $ans
14 }
15
16 -function read_ugid {
17 +read_ugid() {
18 ans=""
19 prompt="$2 [default $3 $4] "
20 default=$3
21 @@ -145,7 +145,7 @@
22
23 if ! $batch; then
24 echo -n "Please press return to continue"
25 - read
26 + read ans
27 fi
28
29 version=`cat .version`
30 --- nfs-user-server-2.2beta47.orig/Makefile.in
31 +++ nfs-user-server-2.2beta47/Makefile.in
32 @@ -95,20 +95,20 @@
33 LIBSRCS = fileblocks.c fsusage.c realpath.c strerror.c \
34 utimes.c mkdir.c rename.c getopt.c getopt_long.c \
35 alloca.c mountlist.c xmalloc.c \
36 - xstrdup.c strdup.c strstr.c nfsmounted.c faccess.c \
37 + xstrdup.c strdup.c strstr.c nfsmounted.c \
38 haccess.c failsafe.c signals.c
39 XDRFILES = mount.x nfs_prot.x
40 GENFILES = mount.h mount_xdr.c mount_svc.c nfs_prot.h nfs_prot_xdr.c \
41 ugid.h ugid_xdr.c ugid_clnt.c
42 HDRS = system.h nfsd.h auth.h fh.h logging.h fakefsuid.h \
43 - rpcmisc.h faccess.h rquotad.h rquota.h haccess.h
44 + rpcmisc.h rquotad.h rquota.h haccess.h
45 LIBHDRS = fsusage.h getopt.h mountlist.h failsafe.h signals.h
46 MANPAGES5 = exports
47 MANPAGES8p = mountd nfsd $(UGIDD_MAN)
48 MANPAGES8 = showmount
49 MANPAGES = $(MANPAGES5) $(MANPAGES8p) $(MANPAGES8)
50 LIBOBJS = version.o fsusage.o mountlist.o xmalloc.o xstrdup.o \
51 - nfsmounted.o faccess.o haccess.o failsafe.o \
52 + nfsmounted.o haccess.o failsafe.o \
53 signals.o @LIBOBJS@ @ALLOCA@
54 OBJS = logging.o fh.o devtab.o auth_init.o auth_clnt.o auth.o
55 NFSD_OBJS = nfsd.o rpcmisc.o nfs_dispatch.o getattr.o setattr.o \
56 @@ -116,7 +116,7 @@
57 MOUNTD_OBJS = mountd.o rpcmisc.o mount_dispatch.o mount_xdr.o rmtab.o \
58 $(OBJS)
59 SHOWMOUNT_OBJS = showmount.o mount_xdr.o
60 -UGIDD_OBJS = ugidd.o ugid_xdr.o logging.o
61 +UGIDD_OBJS = ugidd.o ugid_xdr.o logging.o rpcmisc.o
62 DAEMONS = $(rpcprefix)mountd $(rpcprefix)nfsd $(UGIDD_PROG)
63 CLIENTS = showmount
64
65 --- nfs-user-server-2.2beta47.orig/auth.c
66 +++ nfs-user-server-2.2beta47/auth.c
67 @@ -143,6 +143,21 @@
68 return okay;
69 }
70
71 +static inline int
72 +auth_atob(const char *name, struct in_addr *ap)
73 +{
74 + int m;
75 +
76 + if (!isdigit(*name))
77 + return 0;
78 + for (m = 0; isdigit(*name); name++)
79 + m = m * 10 + (unsigned char) *name - '0';
80 + if (m > 32)
81 + return 0;
82 + ap->s_addr = m ? ~((1 << (32 - m)) - 1) : 0;
83 + return 1;
84 +}
85 +
86 /*
87 * Get a client entry for a specific name or pattern.
88 * If necessary, this function performs a hostname lookup to
89 @@ -614,7 +629,9 @@
90 if (auth_aton(hname, &haddr, &ename)) {
91 if (*ename == '\0')
92 is_hostaddr = 1;
93 - else if (*ename == '/' && auth_aton(ename+1, &hmask, NULL))
94 + else if (*ename == '/' &&
95 + (auth_aton(ename+1, &hmask, NULL) ||
96 + auth_atob(ename+1, &hmask)))
97 is_netmask = 1;
98 }
99 is_special = is_wildcard + is_netgroup + is_netmask;
100 --- nfs-user-server-2.2beta47.orig/auth_init.c
101 +++ nfs-user-server-2.2beta47/auth_init.c
102 @@ -23,6 +23,7 @@
103 #define EXPORTSFILE "/etc/exports"
104 #endif
105
106 +#if 0
107 /* Support for file access control on /etc/exports by Alex Yuriev. */
108 #include "faccess.h"
109 #ifndef EXPORTSOWNERUID
110 @@ -31,6 +32,7 @@
111 #ifndef EXPORTSOWNERGID
112 #define EXPORTSOWNERGID ((gid_t) 0)
113 #endif
114 +#endif
115
116 exportnode * export_list = NULL;
117 int allow_non_root = 0;
118 @@ -395,6 +397,7 @@
119 auth_file = fname; /* Save for re-initialization */
120
121 /* Check protection of exports file. */
122 +#if 0 /* A man's house is his castle. */
123 switch(iCheckAccess(auth_file, EXPORTSOWNERUID, EXPORTSOWNERGID)) {
124 case FACCESSWRITABLE:
125 Dprintf(L_ERROR,
126 @@ -409,6 +412,7 @@
127 Dprintf(L_ERROR, "exiting because of security violation.\n");
128 exit(1);
129 }
130 +#endif
131
132 if ((ef = fopen(fname, "r")) == NULL) {
133 Dprintf(L_ERROR, "Could not open exports file %s: %s\n",
134 @@ -468,7 +472,7 @@
135
136 /* Build the RPC mount export list data structure. */
137 resex = (exportnode *) xmalloc(sizeof *resex);
138 - resex->ex_dir = mount_point;
139 + resex->ex_dir = xstrdup(path);
140 resex->ex_groups = NULL;
141
142 #ifndef NEW_STYLE_EXPORTS_FILE
143 --- nfs-user-server-2.2beta47.orig/configure.in
144 +++ nfs-user-server-2.2beta47/configure.in
145 @@ -53,7 +53,7 @@
146 AC_CHECK_LIB(crypt, main)
147 AC_CHECK_LIB(nys, main)
148 AC_REPLACE_FUNCS(strerror realpath mkdir rename utimes strdup strstr getopt getopt_long)
149 -AC_HAVE_FUNCS(getcwd seteuid setreuid getdtablesize setgroups lchown setsid setfsuid setfsgid innetgr quotactl authdes_getucred)
150 +AC_HAVE_FUNCS(getcwd seteuid setreuid getdtablesize setgroups lchown setsid setfsuid setfsgid innetgr quotactl authdes_getucred strsignal)
151 AC_AUTHDES_GETUCRED
152 AC_BROKEN_SETFSUID
153 AC_MOUNTLIST
154 --- nfs-user-server-2.2beta47.orig/exports.man
155 +++ nfs-user-server-2.2beta47/exports.man
156 @@ -8,7 +8,7 @@
157 The file
158 .I /etc/exports
159 serves as the access control list for file systems which may be
160 -exported to NFS clients. It it used by both the NFS mount daemon,
161 +exported to NFS clients. It is used by both the NFS mount daemon,
162 .IR mountd (8)
163 and the NFS file server daemon
164 .IR nfsd (8).
165 @@ -75,11 +75,12 @@
166 off, specify
167 .IR insecure .
168 .TP
169 +.IR ro
170 +Disallow the client to modify files and directories. The client is only
171 +allowed to issue read-only requests.
172 +.TP
173 .IR rw
174 -Allow the client to modify files and directories. The default is to
175 -restrict the client to read-only request, which can be made explicit
176 -by using the
177 -.IR ro " option.
178 +Allow the client to modify files and directories. This is the default.
179 .TP
180 .I noaccess
181 This makes everything below the directory inaccessible for the named
182 @@ -98,6 +99,14 @@
183 .TP
184 .IR link_absolute
185 Leave all symbolic link as they are. This is the default operation.
186 +.SS Anonymous Entries
187 +.PP
188 +Entries where hosts are not specified are known as anonymous entries. They
189 +have different default settings compared to normal entries. The differences
190 +include
191 +.IR all_squash ,
192 +.IR no_secure ", and"
193 +.IR ro .
194 .SS User ID Mapping
195 .PP
196 .I nfsd
197 --- nfs-user-server-2.2beta47.orig/failsafe.c
198 +++ nfs-user-server-2.2beta47/failsafe.c
199 @@ -10,8 +10,12 @@
200 #include "logging.h"
201 #include "signals.h"
202 #include <sys/wait.h>
203 +#ifdef HAVE_STRSIGNAL
204 +#include <string.h>
205 +#else
206
207 static const char * get_signame(int signo);
208 +#endif
209
210 void
211 failsafe(int level, int ncopies)
212 @@ -111,9 +115,17 @@
213 pid, running? "Continue" : "Exit");
214 } else {
215 Dprintf(L_WARNING, "failsafe: "
216 +#ifdef HAVE_STRSIGNAL
217 + "child %d terminated by: %s. "
218 +#else
219 "child %d terminated by %s. "
220 +#endif
221 "Restarting.",
222 +#ifdef HAVE_STRSIGNAL
223 + pid, strsignal(signo));
224 +#else
225 pid, get_signame(signo));
226 +#endif
227 child = -1; /* Restart */
228 }
229 } else if (WIFEXITED(status)) {
230 @@ -159,6 +171,7 @@
231 /* NOP */
232 }
233
234 +#ifndef HAVE_STRSIGNAL
235 static const char *
236 get_signame(int signo)
237 {
238 @@ -199,3 +212,4 @@
239 sprintf(namebuf, "signal #%d", signo);
240 return namebuf;
241 }
242 +#endif
243 --- nfs-user-server-2.2beta47.orig/mount_dispatch.c
244 +++ nfs-user-server-2.2beta47/mount_dispatch.c
245 @@ -131,7 +131,7 @@
246 dent = &dtbl[proc_index];
247
248 memset(&argument, 0, dent->arg_size);
249 - if (!svc_getargs(transp, (xdrproc_t) dent->xdr_argument, &argument)) {
250 + if (!svc_getargs(transp, (xdrproc_t) dent->xdr_argument, (caddr_t) &argument)) {
251 svcerr_decode(transp);
252 goto done;
253 }
254 @@ -148,7 +148,7 @@
255 if (!svc_sendreply(transp, dent->xdr_result, (caddr_t) resp)) {
256 svcerr_systemerr(transp);
257 }
258 - if (!svc_freeargs(transp, (xdrproc_t) dent->xdr_argument, &argument)) {
259 + if (!svc_freeargs(transp, (xdrproc_t) dent->xdr_argument, (caddr_t) &argument)) {
260 Dprintf(L_ERROR, "unable to free RPC arguments, exiting\n");
261 exit(1);
262 }
263 --- nfs-user-server-2.2beta47.orig/mount_xdr.c
264 +++ nfs-user-server-2.2beta47/mount_xdr.c
265 @@ -190,7 +190,7 @@
266 xdr_ppathcnf(XDR *xdrs, ppathcnf *objp)
267 {
268
269 - register long *buf=buf;
270 + int32_t *buf=buf;
271
272 int i=i;
273
274 --- nfs-user-server-2.2beta47.orig/mountd.c
275 +++ nfs-user-server-2.2beta47/mountd.c
276 @@ -310,6 +310,7 @@
277 int c;
278
279 program_name = argv[0];
280 + chdir("/");
281
282 /* Parse the command line options and arguments. */
283 opterr = 0;
284 --- nfs-user-server-2.2beta47.orig/nfs_dispatch.c
285 +++ nfs-user-server-2.2beta47/nfs_dispatch.c
286 @@ -147,7 +147,7 @@
287 nfsclient = NULL;
288
289 memset(&argument, 0, dent->arg_size);
290 - if (!svc_getargs(transp, (xdrproc_t) dent->xdr_argument, &argument)) {
291 + if (!svc_getargs(transp, (xdrproc_t) dent->xdr_argument, (caddr_t) &argument)) {
292 svcerr_decode(transp);
293 goto done;
294 }
295 @@ -173,7 +173,7 @@
296 svc_sendreply(transp, dent->xdr_result, (caddr_t) &result);
297 #endif
298
299 - if (!svc_freeargs(transp, (xdrproc_t) dent->xdr_argument, &argument)) {
300 + if (!svc_freeargs(transp, (xdrproc_t) dent->xdr_argument, (caddr_t) &argument)) {
301 Dprintf(L_ERROR, "unable to free RPC arguments, exiting\n");
302 exit(1);
303 }
304 --- nfs-user-server-2.2beta47.orig/nfs_prot_xdr.c
305 +++ nfs-user-server-2.2beta47/nfs_prot_xdr.c
306 @@ -98,7 +98,7 @@
307 xdr_fattr(XDR *xdrs, fattr *objp)
308 {
309
310 - register long *buf=buf;
311 + int32_t *buf=buf;
312
313
314 if (xdrs->x_op == XDR_ENCODE) {
315 @@ -273,7 +273,7 @@
316 xdr_sattr(XDR *xdrs, sattr *objp)
317 {
318
319 - register long *buf=buf;
320 + int32_t *buf=buf;
321
322
323 if (xdrs->x_op == XDR_ENCODE) {
324 @@ -553,7 +553,7 @@
325 xdr_writeargs(XDR *xdrs, writeargs *objp)
326 {
327
328 - register long *buf = buf;
329 + int32_t *buf = buf;
330
331
332 if (xdrs->x_op == XDR_ENCODE) {
333 @@ -777,7 +777,7 @@
334 xdr_statfsokres(XDR *xdrs, statfsokres *objp)
335 {
336
337 - register long *buf=buf;
338 + int32_t *buf=buf;
339
340
341 if (xdrs->x_op == XDR_ENCODE) {
342 --- nfs-user-server-2.2beta47.orig/nfsd.c
343 +++ nfs-user-server-2.2beta47/nfsd.c
344 @@ -36,6 +36,7 @@
345 #define CHK_READ 0
346 #define CHK_WRITE 1
347 #define CHK_NOACCESS 2
348 +#define CHK_ROOT 4
349
350 /* Make larger reads possible. Without crashing the machine :-) */
351 #undef NFS_MAXDATA
352 @@ -173,7 +174,8 @@
353 return NULL;
354 }
355
356 - auth_user(nfsmount, rqstp);
357 + if (!(flags & CHK_ROOT) || strcmp(nfsmount->path, fhc->path))
358 + auth_user(nfsmount, rqstp);
359
360 *statp = NFS_OK;
361 return fhc;
362 @@ -244,7 +246,7 @@
363 nfsstat status;
364 fhcache *fhc;
365
366 - fhc = auth_fh(rqstp, argp, &status, CHK_READ);
367 + fhc = auth_fh(rqstp, argp, &status, CHK_READ | CHK_ROOT);
368 if (fhc == NULL)
369 return status;
370
371 @@ -575,7 +577,12 @@
372 #endif
373
374 /* MvS: Some clients use chardev 0xFFFF for a FIFO. */
375 +#if defined(major) && defined(minor)
376 + if (S_ISCHR(argp->attributes.mode) &&
377 + major(dev) == 0xff && minor(dev) == 0xff) {
378 +#else
379 if (S_ISCHR(argp->attributes.mode) && dev == 0xFFFF) {
380 +#endif
381 is_borc = 0;
382 dev = 0;
383 argp->attributes.mode &= ~S_IFMT;
384 @@ -882,7 +889,9 @@
385
386 /* This code is from Mark Shand's version */
387 errno = 0;
388 - if (efs_lstat(h->path, &sbuf) < 0 || !(S_ISDIR(sbuf.st_mode)))
389 + if (efs_lstat(h->path, &sbuf) < 0)
390 + return (NFSERR_ACCES);
391 + if (!S_ISDIR(sbuf.st_mode))
392 return (NFSERR_NOTDIR);
393 if ((dirp = efs_opendir(h->path)) == NULL)
394 return ((errno ? nfs_errno() : NFSERR_NAMETOOLONG));
395 @@ -940,7 +949,7 @@
396 char *path;
397 struct fs_usage fs;
398
399 - fhc = auth_fh(rqstp, argp, &status, CHK_READ | CHK_NOACCESS);
400 + fhc = auth_fh(rqstp, argp, &status, CHK_READ | CHK_NOACCESS | CHK_ROOT);
401 if (fhc == NULL)
402 return status;
403 path = fhc->path;
404 --- nfs-user-server-2.2beta47.orig/rpcmisc.c
405 +++ nfs-user-server-2.2beta47/rpcmisc.c
406 @@ -64,25 +64,25 @@
407 asize = sizeof(saddr);
408 sock = 0;
409 if (getsockname(0, (struct sockaddr *) &saddr, &asize) == 0) {
410 - int ssize = sizeof (int);
411 + int ssize = sizeof (i);
412
413 if (saddr.sin_family != AF_INET)
414 goto not_inetd;
415 - if (getsockopt(0, SOL_SOCKET, SO_TYPE, &_rpcfdtype, &ssize) < 0)
416 + if (getsockopt(0, SOL_SOCKET, SO_TYPE, &i, &ssize) < 0)
417 goto not_inetd;
418 + _rpcfdtype = i;
419 background_logging(); /* no more logging to stderr */
420 closedown = time(NULL) + _RPCSVC_CLOSEDOWN;
421 _rpcpmstart = 1;
422 } else {
423 not_inetd:
424 - _rpcfdtype = 0;
425 for (i = 0; (vers = verstbl[i]) != 0; i++)
426 pmap_unset(prog, vers);
427 sock = RPC_ANYSOCK;
428 }
429
430 if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_DGRAM)) {
431 - if (_rpcfdtype == 0 && defport != 0)
432 + if (_rpcpmstart == 0 && defport != 0)
433 sock = makesock(defport, IPPROTO_UDP, bufsiz);
434 transp = svcudp_create(sock);
435 if (transp == NULL)
436 @@ -97,7 +97,7 @@
437 }
438
439 if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_STREAM)) {
440 - if (_rpcfdtype == 0 && defport != 0)
441 + if (_rpcpmstart == 0 && defport != 0)
442 sock = makesock(defport, IPPROTO_TCP, bufsiz);
443 transp = svctcp_create(sock, 0, 0);
444 if (transp == NULL)
445 @@ -220,11 +220,14 @@
446 }
447 #endif /* SO_SNDBUF */
448
449 - if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) == -1)
450 - Dprintf(L_FATAL, "Could not bind %s socket to %s:%d: %s\n",
451 + if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) == -1) {
452 + Dprintf(L_ERROR, "Could not bind %s socket to %s:%d: %s\n",
453 prot_name, inet_ntoa(sin.sin_addr),
454 ntohs(sin.sin_port),
455 strerror(errno));
456 + close(s);
457 + s = RPC_ANYSOCK;
458 + }
459
460 return (s);
461 }
462 --- nfs-user-server-2.2beta47.orig/showmount.c
463 +++ nfs-user-server-2.2beta47/showmount.c
464 @@ -200,7 +200,7 @@
465 memset(&exportlist, '\0', sizeof(exportlist));
466 clnt_stat = clnt_call(mclient, MOUNTPROC_EXPORT,
467 (xdrproc_t) xdr_void, NULL,
468 - (xdrproc_t) xdr_exports, &exportlist,
469 + (xdrproc_t) xdr_exports, (caddr_t) &exportlist,
470 total_timeout);
471 if (clnt_stat != RPC_SUCCESS) {
472 clnt_perror(mclient, "rpc mount export");
473 @@ -233,7 +233,7 @@
474 memset(&dumplist, '\0', sizeof(dumplist));
475 clnt_stat = clnt_call(mclient, MOUNTPROC_DUMP,
476 (xdrproc_t) xdr_void, NULL,
477 - (xdrproc_t) xdr_mountlist, &dumplist,
478 + (xdrproc_t) xdr_mountlist, (caddr_t) &dumplist,
479 total_timeout);
480 if (clnt_stat != RPC_SUCCESS) {
481 clnt_perror(mclient, "rpc mount dump");
482 --- nfs-user-server-2.2beta47.orig/ugid_clnt.c
483 +++ nfs-user-server-2.2beta47/ugid_clnt.c
484 @@ -16,7 +16,7 @@
485 static int clnt_res;
486
487 memset((char *)&clnt_res, 0, sizeof(clnt_res));
488 - if (clnt_call(clnt, AUTHENTICATE, (xdrproc_t) xdr_int, argp, (xdrproc_t) xdr_int, &clnt_res, TIMEOUT) != RPC_SUCCESS) {
489 + if (clnt_call(clnt, AUTHENTICATE, (xdrproc_t) xdr_int, (caddr_t) argp, (xdrproc_t) xdr_int, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) {
490 return (NULL);
491 }
492 return (&clnt_res);
493 @@ -28,7 +28,7 @@
494 static int clnt_res;
495
496 memset((char *)&clnt_res, 0, sizeof(clnt_res));
497 - if (clnt_call(clnt, NAME_UID, (xdrproc_t) xdr_ugname, argp, (xdrproc_t) xdr_int, &clnt_res, TIMEOUT) != RPC_SUCCESS) {
498 + if (clnt_call(clnt, NAME_UID, (xdrproc_t) xdr_ugname, (caddr_t) argp, (xdrproc_t) xdr_int, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) {
499 return (NULL);
500 }
501 return (&clnt_res);
502 @@ -40,7 +40,7 @@
503 static int clnt_res;
504
505 memset((char *)&clnt_res, 0, sizeof(clnt_res));
506 - if (clnt_call(clnt, GROUP_GID, (xdrproc_t) xdr_ugname, argp, (xdrproc_t) xdr_int, &clnt_res, TIMEOUT) != RPC_SUCCESS) {
507 + if (clnt_call(clnt, GROUP_GID, (xdrproc_t) xdr_ugname, (caddr_t) argp, (xdrproc_t) xdr_int, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) {
508 return (NULL);
509 }
510 return (&clnt_res);
511 @@ -52,7 +52,7 @@
512 static ugname clnt_res;
513
514 memset((char *)&clnt_res, 0, sizeof(clnt_res));
515 - if (clnt_call(clnt, UID_NAME, (xdrproc_t) xdr_int, argp, (xdrproc_t) xdr_ugname, &clnt_res, TIMEOUT) != RPC_SUCCESS) {
516 + if (clnt_call(clnt, UID_NAME, (xdrproc_t) xdr_int, (caddr_t) argp, (xdrproc_t) xdr_ugname, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) {
517 return (NULL);
518 }
519 return (&clnt_res);
520 @@ -64,7 +64,7 @@
521 static ugname clnt_res;
522
523 memset((char *)&clnt_res, 0, sizeof(clnt_res));
524 - if (clnt_call(clnt, GID_GROUP, (xdrproc_t) xdr_int, argp, (xdrproc_t) xdr_ugname, &clnt_res, TIMEOUT) != RPC_SUCCESS) {
525 + if (clnt_call(clnt, GID_GROUP, (xdrproc_t) xdr_int, (caddr_t) argp, (xdrproc_t) xdr_ugname, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) {
526 return (NULL);
527 }
528 return (&clnt_res);
529 --- nfs-user-server-2.2beta47.orig/ugid_map.c
530 +++ nfs-user-server-2.2beta47/ugid_map.c
531 @@ -602,7 +602,7 @@
532 * the server's port after clntudp_create, so we fetch it
533 * explicitly.
534 */
535 - clnt_control(clnt, CLGET_SERVER_ADDR, &addr);
536 + clnt_control(clnt, CLGET_SERVER_ADDR, (caddr_t) &addr);
537 if (!SECURE_PORT(addr.sin_port)) {
538 Dprintf(L_ERROR, "%s on %s runs on unprivileged port.\n",
539 name, inet_ntoa(addr.sin_addr));
540 --- nfs-user-server-2.2beta47.orig/ugidd.c
541 +++ nfs-user-server-2.2beta47/ugidd.c
542 @@ -20,6 +20,8 @@
543 #include "ugid.h"
544 #include "logging.h"
545 #include "haccess.h"
546 +#include "rpcmisc.h"
547 +#include "signals.h"
548 #ifdef HAVE_LIBWRAP_BUG
549 #include <syslog.h>
550 #endif
551 @@ -27,6 +29,8 @@
552
553 static void ugidprog_1(struct svc_req *rqstp, SVCXPRT *transp);
554 static void usage(void);
555 +static void terminate(void);
556 +static RETSIGTYPE sigterm(int sig);
557
558 #ifndef HAVE_RPCGEN_C
559 #define authenticate_1_svc authenticate_1
560 @@ -39,17 +43,23 @@
561
562 static struct option longopts[] = {
563 { "debug", 0, 0, 'd' },
564 + { "port", required_argument, 0, 'P' },
565 { NULL, 0, 0, 0 }
566 };
567
568 +static int ugidd_versions[] = {
569 + UGIDVERS,
570 + 0
571 +};
572 +
573 int
574 main(argc, argv)
575 int argc;
576 char **argv;
577 {
578 - SVCXPRT *transp;
579 int c, longind;
580 int foreground = 0;
581 + int port = 0;
582
583 #ifndef HOSTS_ACCESS
584 fprintf(stderr,
585 @@ -59,40 +69,34 @@
586 sleep(1);
587 #endif
588
589 - while ((c = getopt_long(argc, argv, "d", longopts, &longind)) != EOF) {
590 + chdir("/");
591 +
592 + while ((c = getopt_long(argc, argv, "dP:", longopts, &longind)) != EOF) {
593 switch (c) {
594 case 'd':
595 foreground = 1;
596 enable_logging("ugid");
597 break;
598 + case 'P':
599 + port = atoi(optarg);
600 + if (port <= 0 || port > 65535) {
601 + fprintf(stderr, "ugidd: bad port number: %s\n",
602 + optarg);
603 + usage();
604 + }
605 + break;
606 default:
607 usage();
608 }
609 }
610
611 - (void)pmap_unset(UGIDPROG, UGIDVERS);
612 + log_open("ugidd", foreground);
613
614 - transp = svcudp_create(RPC_ANYSOCK);
615 - if (transp == NULL) {
616 - (void)fprintf(stderr, "cannot create udp service.\n");
617 - exit(1);
618 - }
619 - if (!svc_register(transp, UGIDPROG, UGIDVERS, ugidprog_1, IPPROTO_UDP)) {
620 - fprintf(stderr, "unable to register (UGIDPROG, UGIDVERS, UDP)\n");
621 - exit(1);
622 - }
623 -
624 - transp = svctcp_create(RPC_ANYSOCK, 0, 0);
625 - if (transp == NULL) {
626 - fprintf(stderr, "cannot create tcp service.\n");
627 - exit(1);
628 - }
629 - if (!svc_register(transp, UGIDPROG, UGIDVERS, ugidprog_1, IPPROTO_TCP)) {
630 - fprintf(stderr, "unable to register (UGIDPROG, UGIDVERS, TCP)\n");
631 - exit(1);
632 - }
633 + /* Create services and register with portmapper */
634 + _rpcfdtype = SOCK_DGRAM;
635 + rpc_init("ugidd", UGIDPROG, ugidd_versions, ugidprog_1, port, 0);
636
637 - if (!foreground) {
638 + if (!foreground && !_rpcpmstart) {
639 if ((c = fork()) > 0)
640 exit(0);
641 if (c < 0) {
642 @@ -117,7 +121,8 @@
643 #endif
644 }
645
646 - log_open("ugidd", foreground);
647 + install_signal_handler(SIGTERM, sigterm);
648 + atexit(terminate);
649
650 svc_run();
651 Dprintf(L_ERROR, "svc_run returned\n");
652 @@ -127,7 +132,7 @@
653 static void
654 usage()
655 {
656 - fprintf(stderr, "rpc.ugidd: [-d]\n");
657 + fprintf(stderr, "rpc.ugidd: [-d] [-P port]\n");
658 exit (2);
659 }
660
661 @@ -188,7 +193,7 @@
662 return;
663 }
664 bzero((char *)&argument, sizeof(argument));
665 - if (!svc_getargs(transp, xdr_argument, &argument)) {
666 + if (!svc_getargs(transp, xdr_argument, (caddr_t) &argument)) {
667 svcerr_decode(transp);
668 return;
669 }
670 @@ -196,7 +201,7 @@
671 if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
672 svcerr_systemerr(transp);
673 }
674 - if (!svc_freeargs(transp, xdr_argument, &argument)) {
675 + if (!svc_freeargs(transp, xdr_argument, (caddr_t) &argument)) {
676 (void)fprintf(stderr, "unable to free arguments\n");
677 exit(1);
678 }
679 @@ -321,6 +326,19 @@
680 }
681
682
683 +static RETSIGTYPE
684 +sigterm(int sig)
685 +{
686 + exit(0);
687 +}
688 +
689 +static void
690 +terminate(void)
691 +{
692 + rpc_exit(UGIDPROG, ugidd_versions);
693 +}
694 +
695 +
696
697 #else /* ENABLE_UGID_DAEMON */
698