summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2014-01-23 08:32:44 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-01-28 00:52:36 +0000
commit57d269a584dca69df3e801cf326109ac056497f4 (patch)
treede66c873fc9e796650fe694bb5e665f866d0451f
parent8dd861d471b7168e58e26fcde852eb3e4e7e7b41 (diff)
downloadpoky-57d269a584dca69df3e801cf326109ac056497f4.tar.gz
unfs-server: Remove unfs-server recipe and patches
The unfs-server only supports NFS v2 and it is not useful any longer with the advent of 64 bit inodes and the fact that the server has only a 32 bit key for the NFS hash which is hardcoded back to the inode. This recipe is replaced with a user mode NFS server using v3. [YOCTO #5639] (From OE-Core rev: 13de86c54e2c02e548bd8805ea7df17ddad4e531) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/001-2.2b47-2.2b51.patch2349
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/002-destdir.patch73
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/003-manpages.patch33
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/004-strsignal.patch53
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/005-sys-time.patch34
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/006-reiserfs.patch1277
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/007-map.patch83
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/008-configure.patch18
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/009-multirw.patch20
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/010-realpath.patch35
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/011-fno-strict-aliasing.patch18
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/012-nostrip.patch18
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/013-mntpathlen.patch37
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/014-uninitialized.patch17
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/015-setattr.patch31
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/016-makefile.in.patch19
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/017-wrs-dynamic-rpc.patch263
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/018-remove-tcp-wrappers.patch25
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/019-pid-before-fork.patch130
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/020-undefined-chmod-fix.patch23
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/021-nolibwrap.patch25
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/022-add-close-on-exec-descriptors.patch66
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/023-no-rpc-register.patch34
-rw-r--r--meta/recipes-devtools/unfs-server/unfs-server_2.1+2.2beta47.bb78
24 files changed, 0 insertions, 4759 deletions
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/001-2.2b47-2.2b51.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/001-2.2b47-2.2b51.patch
deleted file mode 100644
index b2cdc5e2bc..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/001-2.2b47-2.2b51.patch
+++ /dev/null
@@ -1,2349 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8diff -urN nfs-server-2.2beta47/.version nfs-server-2.2beta51/.version
9--- nfs-server-2.2beta47/.version Tue Sep 7 09:47:27 1999
10+++ nfs-server-2.2beta51/.version Fri Nov 8 14:45:36 2002
11@@ -1 +1 @@
12-2.2beta46
13+2.2beta51
14diff -urN nfs-server-2.2beta47/ChangeLog nfs-server-2.2beta51/ChangeLog
15--- nfs-server-2.2beta47/ChangeLog Wed Nov 10 10:17:51 1999
16+++ nfs-server-2.2beta51/ChangeLog Fri Nov 8 14:45:36 2002
17@@ -1,8 +1,59 @@
18+Thu Nov 9 17:03:05 2000
19+
20+ * No longer use OPEN_MAX
21+
22+ * Reworked configure.in, BUILD script no longer needed
23+ (nor functioning)
24+
25+ * Be more anal about matching cached fh's and real files.
26+ In addition to the psi, we also store dev/ino/type now
27+ and match that in fh_find.
28+
29+ * Write pidfiles
30+
31+ * Support nosetuid
32+
33+Wed Feb 9 14:52:34 2000
34+
35+ * auth_init.c didn't properly parse options--rot_squash
36+ which is obviously a typo was parsed as ro.
37+ Thanks to Jan Steffan for complaining about this :-)
38+
39+Mon Jan 31 11:48:34 2000
40+
41+ * Fixed Y2K bug in logging.c.
42+ Thanks to Jonathan Hankins <jhankins@homewood.k12.al.us>.
43+
44+Thu Dec 9 11:14:21 1999
45+
46+ * Fix handling of NFS-mounted and /proc directories.
47+ They weren't properly hidden.
48+ Thanks to Dick Streefland <dick_streefland@tasking.com>
49+ for the report and a first patch.
50+
51 Wed Nov 10 10:17:16 1999
52
53 * Security fix for buffer overflow in fh_buildpath
54 No thanks to Mariusz who reported it to bugtraq
55 rather than me.
56+
57+Wed Nov 09 17:10:00 1999
58+
59+ * Workaround for broken Solaris clients that can't handle
60+ atime/mtime/ctime of 0.
61+ Thanks to Frank Wuebbelin for his problem report and
62+ testing the fix.
63+
64+ * Fixed typo in exports.man
65+
66+Tue Nov 2 10:31:14 1999
67+
68+ * Patch for mode 0100 and 0100 executables by
69+ Michael Deutschmann <michael@talamasca.wkpowerlink.com>
70+
71+ * Common startup stuff for all daemons.
72+ Inspired by code sent to me by someone (sorry, I forgot
73+ your name, and the mail's gone!)
74
75 Wed Sep 8 09:07:38 1999
76
77diff -urN nfs-server-2.2beta47/Makefile.in nfs-server-2.2beta51/Makefile.in
78--- nfs-server-2.2beta47/Makefile.in Tue Jun 22 14:53:10 1999
79+++ nfs-server-2.2beta51/Makefile.in Fri Nov 8 14:45:36 2002
80@@ -17,23 +17,30 @@
81
82 #### Start of system configuration section. ####
83
84-srcdir = @srcdir@
85-VPATH = @srcdir@
86+srcdir = @srcdir@
87+VPATH = @srcdir@
88
89-CC = @CC@
90-AR = ar
91-RANLIB = @RANLIB@
92-
93-INSTALL = @INSTALL@
94-INSTALL_PROGRAM = @INSTALL_PROGRAM@ -m 755
95-INSTALL_DATA = @INSTALL_DATA@
96-MAKEINFO = makeinfo
97-TEXI2DVI = texi2dvi
98-RPCGEN = @RPCGEN@ @RPCGEN_C@
99+CC = @CC@
100+AR = ar
101+RANLIB = @RANLIB@
102+
103+INSTALL = @INSTALL@
104+INSTALL_PROGRAM = @INSTALL_PROGRAM@ -m 755
105+INSTALL_DATA = @INSTALL_DATA@
106+MAKEINFO = makeinfo
107+TEXI2DVI = texi2dvi
108+RPCGEN = @RPCGEN@ @RPCGEN_C@
109
110 # General compile options and libs:
111-DEFS = @DEFS@ $(NFSD_DEFS)
112-LIBS = libnfs.a @LIBS@
113+DEFS = @DEFS@ $(NFSD_DEFS)
114+LIBS = libnfs.a @LIBS@
115+
116+# Ugidd support
117+UGIDD_PROG = @UGIDD_PROG@
118+UGIDD_MAN = @UGIDD_MAN@
119+
120+# New inode mapping scheme
121+DEVTAB_FILE = $(install_prefix)@PATH_DEVTAB@
122
123 # Compile options for nfsd:
124 # CALL_PROFILING
125@@ -80,9 +87,6 @@
126
127 #### End of system configuration section. ####
128
129-# include site-specific defintions generated by BUILD.
130-include site.mk
131-
132 SHELL = /bin/sh
133
134 SRCS = version.c logging.c fh.c devtab.c \
135@@ -96,19 +100,19 @@
136 utimes.c mkdir.c rename.c getopt.c getopt_long.c \
137 alloca.c mountlist.c xmalloc.c \
138 xstrdup.c strdup.c strstr.c nfsmounted.c faccess.c \
139- haccess.c failsafe.c signals.c
140+ haccess.c daemon.c signals.c
141 XDRFILES = mount.x nfs_prot.x
142 GENFILES = mount.h mount_xdr.c mount_svc.c nfs_prot.h nfs_prot_xdr.c \
143 ugid.h ugid_xdr.c ugid_clnt.c
144 HDRS = system.h nfsd.h auth.h fh.h logging.h fakefsuid.h \
145 rpcmisc.h faccess.h rquotad.h rquota.h haccess.h
146-LIBHDRS = fsusage.h getopt.h mountlist.h failsafe.h signals.h
147+LIBHDRS = fsusage.h getopt.h mountlist.h daemon.h signals.h
148 MANPAGES5 = exports
149 MANPAGES8p = mountd nfsd $(UGIDD_MAN)
150 MANPAGES8 = showmount
151 MANPAGES = $(MANPAGES5) $(MANPAGES8p) $(MANPAGES8)
152 LIBOBJS = version.o fsusage.o mountlist.o xmalloc.o xstrdup.o \
153- nfsmounted.o faccess.o haccess.o failsafe.o \
154+ nfsmounted.o faccess.o haccess.o daemon.o \
155 signals.o @LIBOBJS@ @ALLOCA@
156 OBJS = logging.o fh.o devtab.o auth_init.o auth_clnt.o auth.o
157 NFSD_OBJS = nfsd.o rpcmisc.o nfs_dispatch.o getattr.o setattr.o \
158@@ -174,15 +178,13 @@
159 ${srcdir}/mkinstalldirs $(bindir) $(man5dir) $(man8dir)
160
161 $(rpcprefix)mountd: $(MOUNTD_OBJS) libnfs.a
162- $(CC) $(LDFLAGS) -o $@ $(MOUNTD_OBJS) $(LIBS) \
163- $(LIBWRAP_DIR) $(LIBWRAP_LIB)
164+ $(CC) $(LDFLAGS) -o $@ $(MOUNTD_OBJS) $(LIBS)
165
166 $(rpcprefix)nfsd: $(NFSD_OBJS) libnfs.a
167 $(CC) $(LDFLAGS) -o $@ $(NFSD_OBJS) $(LIBS)
168
169 $(rpcprefix)ugidd: $(UGIDD_OBJS) libnfs.a
170- $(CC) $(LDFLAGS) -o $@ $(UGIDD_OBJS) $(LIBS) \
171- $(LIBWRAP_DIR) $(LIBWRAP_LIB)
172+ $(CC) $(LDFLAGS) -o $@ $(UGIDD_OBJS) $(LIBS)
173
174 showmount: $(SHOWMOUNT_OBJS) libnfs.a
175 $(CC) $(LDFLAGS) -o $@ $(SHOWMOUNT_OBJS) $(LIBS)
176diff -urN nfs-server-2.2beta47/aclocal.m4 nfs-server-2.2beta51/aclocal.m4
177--- nfs-server-2.2beta47/aclocal.m4 Fri Jun 11 12:04:22 1999
178+++ nfs-server-2.2beta51/aclocal.m4 Fri Nov 8 14:45:36 2002
179@@ -221,20 +221,14 @@
180 ])dnl
181 dnl *********** libwrap bug **************
182 define(AC_LIBWRAP_BUG,
183- [if test -f site.mk; then
184- . ./site.mk
185- fi
186- if test ! -z "$LIBWRAP_DIR"; then
187+ [if test "$ac_cv_lib_wrap_main" = yes; then
188 AC_MSG_CHECKING(for link problem with libwrap.a)
189 AC_CACHE_VAL(nfsd_cv_lib_wrap_bug,
190- [ac_save_LIBS=$LIBS
191- LIBS="$LIBS $LIBWRAP_DIR $LIBWRAP_LIB"
192- AC_TRY_LINK([
193+ [AC_TRY_LINK([
194 extern int deny_severity;
195 ],[
196 deny_severity=1;
197 ], nfsd_cv_lib_wrap_bug=no, nfsd_cv_lib_wrap_bug=yes)
198- LIBS=$ac_save_LIBS
199 ]) dnl
200 AC_MSG_RESULT($nfsd_cv_lib_wrap_bug)
201 test $nfsd_cv_lib_wrap_bug = yes && AC_DEFINE(HAVE_LIBWRAP_BUG)
202diff -urN nfs-server-2.2beta47/auth.c nfs-server-2.2beta51/auth.c
203--- nfs-server-2.2beta47/auth.c Mon Sep 13 16:56:03 1999
204+++ nfs-server-2.2beta51/auth.c Fri Nov 8 14:45:36 2002
205@@ -84,8 +84,9 @@
206 0, /* relative links */
207 0, /* noaccess */
208 1, /* cross_mounts */
209- (uid_t)-2, /* default uid */
210- (gid_t)-2, /* default gid */
211+ 1, /* allow setuid */
212+ 65534, /* default uid */
213+ 65534, /* default gid */
214 0, /* no NIS domain */
215 };
216
217@@ -99,8 +100,9 @@
218 0, /* relative links */
219 0, /* noaccess */
220 1, /* cross_mounts */
221- (uid_t)-2, /* default uid */
222- (gid_t)-2, /* default gid */
223+ 0, /* allow setuid */
224+ 65534, /* default uid */
225+ 65534, /* default gid */
226 0, /* no NIS domain */
227 };
228
229@@ -673,6 +675,7 @@
230 cpp = &unknown_clients;
231 } else {
232 cpp = &known_clients;
233+ cp->clnt_addr = *(struct in_addr *) hp->h_addr;
234 auth_hash_host(cp, hp);
235 }
236 cp->next = *cpp;
237diff -urN nfs-server-2.2beta47/auth.h nfs-server-2.2beta51/auth.h
238--- nfs-server-2.2beta47/auth.h Thu Apr 8 14:47:56 1999
239+++ nfs-server-2.2beta51/auth.h Fri Nov 8 14:45:36 2002
240@@ -23,14 +23,6 @@
241 extern char * public_root_path;
242 extern struct nfs_fh public_root;
243
244-#if defined(linux) && defined(i386) && !defined(HAVE_SETFSUID)
245-# define MAYBE_HAVE_SETFSUID
246-#endif
247-
248-#ifdef MAYBE_HAVE_SETFSUID
249-extern int have_setfsuid;
250-#endif
251-
252 /*
253 * These externs are set in the dispatcher (dispatch.c) and auth_fh
254 * (nfsd.c) so that we can determine access rights, export options,
255@@ -59,6 +51,7 @@
256 int link_relative;
257 int noaccess;
258 int cross_mounts;
259+ int allow_setuid;
260 uid_t nobody_uid;
261 gid_t nobody_gid;
262 char * clnt_nisdomain;
263@@ -112,7 +105,7 @@
264 extern void auth_free_lists(void);
265 extern nfs_client *auth_clnt(struct svc_req *rqstp);
266 extern nfs_mount *auth_path(nfs_client *, struct svc_req *, char *);
267-extern void auth_user(nfs_mount *, struct svc_req *);
268+extern int auth_user(nfs_mount *, struct svc_req *);
269
270 extern nfs_client *auth_get_client(char *);
271 extern nfs_mount *auth_match_mount(nfs_client *, char *);
272diff -urN nfs-server-2.2beta47/auth_clnt.c nfs-server-2.2beta51/auth_clnt.c
273--- nfs-server-2.2beta47/auth_clnt.c Wed Nov 10 10:18:06 1999
274+++ nfs-server-2.2beta51/auth_clnt.c Fri Nov 8 14:45:36 2002
275@@ -12,20 +12,17 @@
276 */
277
278
279+#include <sys/fsuid.h>
280 #include "system.h"
281 #include "nfsd.h"
282-#include "fakefsuid.h"
283-
284-#ifndef svc_getcaller
285-#define svc_getcaller(x) ((struct sockaddr_in *) &(x)->xp_rtaddr.buf)
286-#endif
287+#include "rpcmisc.h"
288
289
290-#if defined(HAVE_SETFSUID) || defined(MAYBE_HAVE_SETFSUID)
291-static void setfsids(uid_t, gid_t, gid_t *, int);
292+#if defined(HAVE_SETFSUID)
293+static int setfsids(uid_t, gid_t, gid_t *, int);
294 #endif
295 #ifndef HAVE_SETFSUID
296-static void seteids(uid_t, gid_t, gid_t *, int);
297+static int seteids(uid_t, gid_t, gid_t *, int);
298 #endif
299
300 uid_t auth_uid = 0; /* Current effective user ids */
301@@ -43,6 +40,17 @@
302 short *gid, short *nrgids, int *groups);
303 #endif
304
305+/*
306+ * The following crap is required for glibc 2.1 which has 32bit uids
307+ * in user land mapped to 16bit uids in the Linux kernel
308+ */
309+#if defined(HAVE_BROKEN_SETFSUID)
310+# define native_uid(u) ((unsigned short)(u))
311+# define native_gid(g) ((unsigned short)(g))
312+#else
313+# define native_uid(u) (u)
314+# define native_gid(g) (g)
315+#endif
316
317 /*
318 * For an RPC request, look up the NFS client info along with the
319@@ -92,8 +100,9 @@
320 }
321
322 if (logging_enabled(D_AUTH)) {
323- Dprintf(D_AUTH, "auth_path(%s): mount point %s, (%s%s%s%s%s)\n",
324- path, mp->path,
325+ Dprintf(D_AUTH, "auth_path(%s, %s): "
326+ "mount point %s, (%s%s%s%s%s)\n",
327+ inet_ntoa(cp->clnt_addr), path, mp->path,
328 mp->o.all_squash? "all_squash " : (
329 mp->o.root_squash? "root_squash " : ""),
330 (mp->o.uidmap == map_daemon)? "uidmap " : "",
331@@ -105,7 +114,8 @@
332 return mp;
333 }
334
335-void auth_user(nfs_mount *mp, struct svc_req *rqstp)
336+int
337+auth_user(nfs_mount *mp, struct svc_req *rqstp)
338 {
339 uid_t cuid;
340 gid_t cgid;
341@@ -160,23 +170,18 @@
342 else if (cred_len > NGRPS)
343 cred_len = NGRPS;
344
345- cuid = luid(cred_uid, mp, rqstp);
346- cgid = lgid(cred_gid, mp, rqstp);
347+ cuid = luid(native_uid(cred_uid), mp, rqstp);
348+ cgid = lgid(native_gid(cred_gid), mp, rqstp);
349 clen = cred_len;
350 for (i = 0; i < cred_len; i++)
351- cgids[i] = lgid(cred_gids[i], mp, rqstp);
352+ cgids[i] = lgid(native_gid(cred_gids[i]), mp, rqstp);
353 } else {
354 /* On systems that have 32bit uid_t in user space but
355 * 16bit in the kernel, we need to truncate the
356 * nobody ID (default -2).
357 */
358-#if !defined(HAVE_BROKEN_SETFSUID)
359- cuid = mp->o.nobody_uid;
360- cgid = mp->o.nobody_gid;
361-#else
362- cuid = (unsigned short) mp->o.nobody_uid;
363- cgid = (unsigned short) mp->o.nobody_gid;
364-#endif
365+ cuid = native_uid(mp->o.nobody_uid);
366+ cgid = native_gid(mp->o.nobody_gid);
367 /* Construct a list of one gid. */
368 cgids[0] = cgid;
369 clen = 1;
370@@ -193,14 +198,9 @@
371 * upper 16 bits set (including our default nobody uid -2).
372 */
373 #if defined(HAVE_SETFSUID)
374- setfsids(cuid, cgid, cgids, clen);
375+ return setfsids(cuid, cgid, cgids, clen);
376 #else
377-#if defined(MAYBE_HAVE_SETFSUID)
378- if (have_setfsuid)
379- setfsids(cuid, cgid, cgids, clen);
380- else
381-#endif
382- seteids(cuid, cgid, cgids, clen);
383+ return seteids(cuid, cgid, cgids, clen);
384 #endif
385 }
386
387@@ -210,6 +210,8 @@
388 void
389 auth_override_uid(uid_t uid)
390 {
391+ int res;
392+
393 /* extension hooks: */
394 efs_setfsuid(uid);
395
396@@ -217,19 +219,18 @@
397 uid = (unsigned short) uid;
398 #endif
399 #if defined(HAVE_SETFSUID)
400- setfsuid(uid);
401+ res = setfsuid(uid);
402 #else
403-#if defined(MAYBE_HAVE_SETFSUID)
404- if (have_setfsuid)
405- setfsuid(uid);
406- else
407-#endif
408- seteuid(uid);
409+ res = seteuid(uid);
410 #endif
411+ /* should never happen */
412+ if (res < 0)
413+ Dprintf(L_FATAL, "auth_override_uid(%d) failed: %s",
414+ uid, strerror(errno));
415 }
416
417-#if defined(HAVE_SETFSUID) || defined(MAYBE_HAVE_SETFSUID)
418-static void
419+#if defined(HAVE_SETFSUID)
420+static int
421 setfsids(uid_t cred_uid, gid_t cred_gid, gid_t *cred_gids, int cred_len)
422 {
423 /* extension hooks: */
424@@ -238,43 +239,47 @@
425
426 /* First, set the user ID. */
427 if (auth_uid != cred_uid) {
428- if (setfsuid(cred_uid) < 0)
429+ if (setfsuid(cred_uid) < 0) {
430 Dprintf(L_ERROR, "Unable to setfsuid %d: %s\n",
431 cred_uid, strerror(errno));
432- else
433- auth_uid = cred_uid;
434+ return 0;
435+ }
436+ auth_uid = cred_uid;
437 }
438
439 /* Next, the group ID. */
440 if (auth_gid != cred_gid) {
441- if (setfsgid(cred_gid) < 0)
442+ if (setfsgid(cred_gid) < 0) {
443 Dprintf(L_ERROR, "Unable to setfsgid %d: %s\n",
444 cred_gid, strerror(errno));
445- else
446- auth_gid = cred_gid;
447+ return 0;
448+ }
449+ auth_gid = cred_gid;
450 }
451
452 #ifdef HAVE_SETGROUPS
453 /* Finally, set the supplementary group IDs if possible. */
454- if (cred_len < 0 || cred_len > NGRPS)
455+ if (cred_len < 0 || cred_len > NGRPS) {
456 Dprintf(L_ERROR, "Negative or huge cred_len: %d\n", cred_len);
457- else if (cred_len != auth_gidlen
458- || memcmp(cred_gids, auth_gids, auth_gidlen*sizeof(gid_t))) {
459- if (setgroups(cred_len, cred_gids) < 0)
460+ return 0;
461+ }
462+ if (cred_len != auth_gidlen
463+ || memcmp(cred_gids, auth_gids, auth_gidlen*sizeof(gid_t))) {
464+ if (setgroups(cred_len, cred_gids) < 0) {
465 Dprintf(L_ERROR, "Unable to setgroups: %s\n",
466 strerror(errno));
467- else {
468- memcpy(auth_gids, cred_gids, cred_len*sizeof(gid_t));
469- auth_gidlen = cred_len;
470+ return 0;
471 }
472+ memcpy(auth_gids, cred_gids, cred_len*sizeof(gid_t));
473+ auth_gidlen = cred_len;
474 }
475 #endif /* HAVE_SETGROUPS */
476-
477+ return 1;
478 }
479 #endif
480
481 #if !defined(HAVE_SETFSUID)
482-static void
483+static int
484 seteids(uid_t cred_uid, gid_t cred_gid, gid_t *cred_gids, int cred_len)
485 {
486 /* extension hooks: */
487@@ -286,52 +291,62 @@
488 /* First set the group ID. */
489 if (auth_gid != cred_gid) {
490 if (auth_uid != ROOT_UID) {
491- if (seteuid(ROOT_UID) < 0)
492+ if (seteuid(ROOT_UID) < 0) {
493 Dprintf(L_ERROR, "Unable to seteuid(%d): %s\n",
494 ROOT_UID, strerror(errno));
495- else
496- auth_uid = ROOT_UID;
497+ return 0;
498+ }
499+ auth_uid = ROOT_UID;
500 }
501- if (setegid(cred_gid) < 0)
502+ if (setegid(cred_gid) < 0) {
503 Dprintf(L_ERROR, "Unable to setegid(%d): %s\n",
504 cred_gid, strerror(errno));
505- else
506- auth_gid = cred_gid;
507+ return 0;
508+ }
509+ auth_gid = cred_gid;
510 }
511
512 #ifdef HAVE_SETGROUPS
513 /* Next set the supplementary group IDs if possible. */
514- if (cred_len < 0 || cred_len > NGRPS)
515+ if (cred_len < 0 || cred_len > NGRPS) {
516 Dprintf(L_ERROR, "Negative or huge cred_len: %d\n", cred_len);
517- else if (cred_len != auth_gidlen
518- || memcmp(cred_gids, auth_gids, auth_gidlen*sizeof(gid_t))) {
519+ return 0;
520+ }
521+ if (cred_len != auth_gidlen
522+ || memcmp(cred_gids, auth_gids, auth_gidlen*sizeof(gid_t))) {
523 if (auth_uid != ROOT_UID) {
524- if (seteuid(ROOT_UID) < 0)
525+ if (seteuid(ROOT_UID) < 0) {
526 Dprintf(L_ERROR, "Unable to seteuid(%d): %s\n",
527 ROOT_UID, strerror(errno));
528- else
529- auth_uid = ROOT_UID;
530+ return 0;
531+ }
532+ auth_uid = ROOT_UID;
533 }
534- if (setgroups(cred_len, cred_gids) < 0)
535+ if (setgroups(cred_len, cred_gids) < 0) {
536 Dprintf(L_ERROR, "Unable to setgroups: %s\n",
537 strerror(errno));
538- else {
539- memcpy(auth_gids, cred_gids, cred_len*sizeof(gid_t));
540- auth_gidlen = cred_len;
541+ return 0;
542 }
543+ memcpy(auth_gids, cred_gids, cred_len*sizeof(gid_t));
544+ auth_gidlen = cred_len;
545 }
546 #endif /* HAVE_SETGROUPS */
547
548 /* Finally, set the user ID. */
549 if (auth_uid != cred_uid) {
550- if (auth_uid != ROOT_UID && seteuid(ROOT_UID) < 0)
551+ if (auth_uid != ROOT_UID && seteuid(ROOT_UID) < 0) {
552 Dprintf(L_ERROR, "Unable to seteuid(%d): %s\n",
553 ROOT_UID, strerror(errno));
554- if (seteuid(cred_uid) < 0)
555+ return 0;
556+ }
557+ if (seteuid(cred_uid) < 0) {
558 Dprintf(L_ERROR, "Unable to seteuid(%d): %s\n",
559 cred_uid, strerror(errno));
560- else
561- auth_uid = cred_uid;
562+ return 0;
563+ }
564+ auth_uid = cred_uid;
565 }
566+
567+ return 1;
568 }
569 #endif
570diff -urN nfs-server-2.2beta47/auth_init.c nfs-server-2.2beta51/auth_init.c
571--- nfs-server-2.2beta47/auth_init.c Mon Apr 19 14:01:21 1999
572+++ nfs-server-2.2beta51/auth_init.c Fri Nov 8 14:45:36 2002
573@@ -13,7 +13,6 @@
574 */
575
576 #include "nfsd.h"
577-#include "fakefsuid.h"
578 #include <pwd.h>
579
580 #define LINE_SIZE 1024
581@@ -263,55 +262,63 @@
582 cp++;
583 while (*cp != terminator) {
584 kwd = cp;
585- while (isalpha(*cp) || *cp == '_' || *cp == '=') {
586- /* break out of loop after = sign */
587- if (*cp++ == '=')
588- break;
589- }
590+ /* Gobble up keyword and "=" if there is one */
591+ while (isalpha(*cp) || *cp == '_')
592+ ++cp;
593+ if (*cp == '=')
594+ ++cp;
595+
596 klen = cp - kwd;
597
598 /* process keyword */
599- if (strncmp(kwd, "secure", 6) == 0)
600+#define ifkwd(n, string) \
601+ if (klen == (n) && !strncmp(kwd, string, (n)))
602+
603+ ifkwd(2, "ro")
604+ mp->o.read_only = 1;
605+ else ifkwd(2, "rw")
606+ mp->o.read_only = 0;
607+ else ifkwd(6, "secure")
608 mp->o.secure_port = 1;
609- else if (strncmp(kwd, "insecure", 8) == 0)
610+ else ifkwd(8, "insecure")
611 mp->o.secure_port = 0;
612- else if (strncmp(kwd, "root_squash", 11) == 0)
613+ else ifkwd(11, "root_squash")
614 mp->o.root_squash = 1;
615- else if (strncmp(kwd, "no_root_squash", 14) == 0)
616+ else ifkwd(14, "no_root_squash")
617 mp->o.root_squash = 0;
618- else if (strncmp(kwd, "ro", 2) == 0)
619- mp->o.read_only = 1;
620- else if (strncmp(kwd, "rw", 2) == 0)
621- mp->o.read_only = 0;
622- else if (strncmp(kwd, "link_relative", 13) == 0)
623+ else ifkwd(13, "link_relative")
624 mp->o.link_relative = 1;
625- else if (strncmp(kwd, "link_absolute", 13) == 0)
626+ else ifkwd(13, "link_absolute")
627 mp->o.link_relative = 0;
628- else if (strncmp(kwd, "map_daemon", 10) == 0)
629+ else ifkwd(10, "map_daemon")
630 mp->o.uidmap = map_daemon;
631- else if (strncmp(kwd, "map_nis=", 8) == 0)
632+ else ifkwd(8, "map_nis=")
633 parse_nis_uidmap(mp, &cp);
634- else if (strncmp(kwd, "map_static=", 11) == 0)
635+ else ifkwd(11, "map_static=")
636 parse_static_uidmap(mp, &cp);
637- else if (strncmp(kwd, "map_identity", 12) == 0)
638+ else ifkwd(12, "map_identity")
639 mp->o.uidmap = identity;
640- else if (strncmp(kwd, "all_squash", 10) == 0)
641+ else ifkwd(10, "all_squash")
642 mp->o.all_squash = 1;
643- else if (strncmp(kwd, "no_all_squash", 13) == 0)
644+ else ifkwd(13, "no_all_squash")
645 mp->o.all_squash = 0;
646- else if (strncmp(kwd, "noaccess", 8) == 0)
647+ else ifkwd(8, "noaccess")
648 mp->o.noaccess = 1;
649- else if (strncmp(kwd, "squash_uids=", 12) == 0)
650+ else ifkwd(12, "squash_uids=")
651 parse_squash(mp, 1, &cp);
652- else if (strncmp(kwd, "squash_gids=", 12) == 0)
653+ else ifkwd(12, "squash_gids=")
654 parse_squash(mp, 0, &cp);
655- else if (strncmp(kwd, "anonuid=", 8) == 0)
656+ else ifkwd(8, "anonuid=")
657 mp->o.nobody_uid = parse_num(&cp);
658- else if (strncmp(kwd, "anongid=", 8) == 0)
659+ else ifkwd(8, "anongid=")
660 mp->o.nobody_gid = parse_num(&cp);
661- else if (strncmp(kwd, "async", 5) == 0)
662+ else ifkwd(6, "setuid")
663+ mp->o.allow_setuid = 1;
664+ else ifkwd(8, "nosetuid")
665+ mp->o.allow_setuid = 0;
666+ else ifkwd(5, "async")
667 /* knfsd compatibility, ignore */;
668- else if (strncmp(kwd, "sync", 4) == 0)
669+ else ifkwd(4, "sync")
670 /* knfsd compatibility, ignore */;
671 else {
672 Dprintf(L_ERROR,
673@@ -566,11 +573,6 @@
674 auth_check_all_wildcards();
675 auth_sort_all_mountlists();
676 auth_log_all();
677-
678-#if defined(MAYBE_HAVE_SETFSUID) && !defined(HAVE_SETFSUID)
679- /* check if the a.out setfsuid syscall works on this machine */
680- have_setfsuid = (setfsuid(0) >= 0);
681-#endif
682
683 auth_initialized = 1;
684 }
685diff -urN nfs-server-2.2beta47/config.h.in nfs-server-2.2beta51/config.h.in
686--- nfs-server-2.2beta47/config.h.in Fri Jun 11 12:01:22 1999
687+++ nfs-server-2.2beta51/config.h.in Fri Nov 8 14:45:36 2002
688@@ -3,7 +3,7 @@
689 /* Define if on AIX 3.
690 System headers sometimes define this.
691 We just want to avoid a redefinition error message. */
692-#ifndef _ALL_SOURCE
693+#ifdef _ALL_SOURCE
694 #undef _ALL_SOURCE
695 #endif
696
697diff -urN nfs-server-2.2beta47/configure.in nfs-server-2.2beta51/configure.in
698--- nfs-server-2.2beta47/configure.in Fri Jun 11 11:58:10 1999
699+++ nfs-server-2.2beta51/configure.in Fri Nov 8 14:45:36 2002
700@@ -2,7 +2,36 @@
701 dnl Updated for autoconf 2.
702 dnl
703 AC_INIT(nfsd.c)
704-AC_CONFIG_HEADER(config.h)
705+AC_CONFIG_HEADER(config.h site.h)
706+
707+dnl **************************************************************
708+dnl * handle --enable options
709+dnl **************************************************************
710+AC_ARG_ENABLE(new-inodes,
711+ [ --enable-new-inodes Enable new-style inode inodes])
712+AC_ARG_WITH(devtab,
713+ [ --with-devtab=file Specify location for devtab [/var/lib/nfs/devtab]],
714+ PATH_DEVTAB=$withval,
715+ PATH_DEVTAB=/var/lib/nfs/devtab)
716+AC_ARG_ENABLE(ugid-dynamic,
717+ [ --enable-ugid-dynamic Enable uid mapping using rpc.ugidd (not recommended)])
718+AC_ARG_ENABLE(ugid-nis,
719+ [ --enable-ugid-nis Enable NIS-based uid mapping])
720+AC_ARG_ENABLE(host-access,
721+ [ --enable-host-access Enable host access checking])
722+AC_ARG_ENABLE(mount-logging,
723+ [ --disable-mount-logging Do not log mount operations to syslog],,
724+ enable_mount_logging=yes)
725+AC_ARG_WITH(exports-uid,
726+ [ --with-exports-uid=N Make sure that /etc/exports is owned by uid N],,
727+ with_exports_uid=0)
728+AC_ARG_WITH(exports-gid,
729+ [ --with-exports-gid=N Make sure that /etc/exports is owned by gid N],,
730+ with_exports_gid=0)
731+
732+dnl **************************************************************
733+dnl * Check for all kinds of stuff
734+dnl **************************************************************
735 AC_PROG_CC
736 # If we're using gcc, we want warning flags
737 test -n "$GCC" &&
738@@ -19,7 +48,7 @@
739 AC_MINIX
740 AC_ISC_POSIX
741 AC_PROG_INSTALL
742-AC_CROSS_CHECK
743+dnl AC_CROSS_CHECK
744 AC_STDC_HEADERS
745 AC_GNULIBC
746 AC_CONST
747@@ -52,14 +81,45 @@
748 AC_CHECK_LIB(rpc, main)
749 AC_CHECK_LIB(crypt, main)
750 AC_CHECK_LIB(nys, main)
751-AC_REPLACE_FUNCS(strerror realpath mkdir rename utimes strdup strstr getopt getopt_long)
752 AC_HAVE_FUNCS(getcwd seteuid setreuid getdtablesize setgroups lchown setsid setfsuid setfsgid innetgr quotactl authdes_getucred)
753 AC_AUTHDES_GETUCRED
754 AC_BROKEN_SETFSUID
755 AC_MOUNTLIST
756 AC_FSUSAGE
757+AC_CHECK_LIB(wrap, main)
758 AC_LIBWRAP_BUG
759 AC_BSD_SIGNALS
760+
761+dnl **************************************************************
762+dnl * Munge user specified options
763+dnl **************************************************************
764+if test "$enable_new_inodes" = yes; then
765+ AC_DEFINE(ENABLE_DEVTAB)
766+fi
767+if test "$enable_ugid_dynamic" = yes; then
768+ AC_DEFINE(ENABLE_UGID_DAEMON)
769+ UGIDD_PROG=\${rpcprefix}.ugidd
770+ UGIDD_MAN=ugidd
771+fi
772+if test "$enable_ugid_nis" = yes; then
773+ AC_DEFINE(ENABLE_UGID_NIS)
774+fi
775+if test "$enable_host_access" = yes; then
776+ AC_DEFINE(HOSTS_ACCESS)
777+fi
778+if test "$enable_mount_logging" = yes; then
779+ AC_DEFINE(WANT_LOG_MOUNTS)
780+fi
781+AC_DEFINE_UNQUOTED(EXPORTSOWNERUID, $with_exports_uid)
782+AC_DEFINE_UNQUOTED(EXPORTSOWNERGID, $with_exports_gid)
783+AC_SUBST(PATH_DEVTAB)
784+AC_SUBST(UGIDD_PROG)
785+AC_SUBST(UGIDD_MAN)
786+
787+dnl **************************************************************
788+dnl * Output CFLAGS and LDFLAGS
789+dnl **************************************************************
790 AC_SUBST(LDFLAGS)
791 AC_SUBST(CFLAGS)
792+
793 AC_OUTPUT(Makefile)
794diff -urN nfs-server-2.2beta47/daemon.c nfs-server-2.2beta51/daemon.c
795--- nfs-server-2.2beta47/daemon.c Thu Jan 1 01:00:00 1970
796+++ nfs-server-2.2beta51/daemon.c Fri Nov 8 14:45:52 2002
797@@ -0,0 +1,270 @@
798+/*
799+ * daemon.c
800+ *
801+ * Copyright (C) 1998, <okir@monad.swb.de>
802+ *
803+ * Implements common daemon stuff and
804+ * fail-safe mode for nfsd/mountd.
805+ */
806+
807+#include "system.h"
808+#include "logging.h"
809+#include "signals.h"
810+#include <sys/wait.h>
811+
812+static const char * pidfilename = 0;
813+static const char * get_signame(int signo);
814+
815+/*
816+ * Do the Crawley Thing
817+ */
818+void
819+daemonize(void)
820+{
821+ int c;
822+
823+ /* Ignore SIGHUP so the parent can exit while we're still
824+ * in limbo */
825+ ignore_signal(SIGHUP);
826+
827+ /* Now fork */
828+ c = fork();
829+ if (c < 0)
830+ Dprintf(L_FATAL, "unable to fork: %s", strerror(errno));
831+
832+ /* Parent process: exit */
833+ if (c > 0)
834+ exit(0);
835+
836+ /* Do the session stuff */
837+ close(0);
838+ close(1);
839+ close(2);
840+#ifdef HAVE_SETSID
841+ setsid();
842+#else
843+ if ((c = open("/dev/tty", O_RDWR)) >= 0) {
844+ ioctl(c, TIOCNOTTY, (char *) NULL);
845+ close(c);
846+ }
847+#endif
848+
849+ /* Stop stderr logging */
850+ background_logging();
851+}
852+
853+void
854+setpidpath(const char *filename)
855+{
856+ pidfilename = filename;
857+}
858+
859+void
860+writepid(pid_t pid, int clear)
861+{
862+ FILE *fp;
863+
864+ fp = fopen(pidfilename, clear? "w" : "a");
865+ if (fp == NULL)
866+ Dprintf(L_FATAL, "Unable to open %s: %m", pidfilename);
867+ fprintf(fp, "%d\n", pid);
868+ fclose(fp);
869+ return;
870+}
871+
872+void
873+failsafe(int level, int ncopies)
874+{
875+ int *servers, running, child, i;
876+ int pid, signo, status;
877+ time_t last_restart = 0, now;
878+ int restarts = 0, backoff = 60;
879+
880+ servers = (int *) xmalloc(ncopies * sizeof(int));
881+ memset(servers, 0, ncopies * sizeof(int));
882+
883+ /* Loop forever, until we get SIGTERM */
884+ running = 0;
885+ while (1) {
886+ /* Rewrite the pidfile */
887+ writepid(getpid(), 1);
888+ for (i = 0; i < ncopies; i++) {
889+ if (servers[i] != 0)
890+ writepid(servers[i], 0);
891+ }
892+
893+ while (running < ncopies) {
894+ if ((now = time(NULL)) == last_restart) {
895+ if (++restarts > 2 * ncopies) {
896+ Dprintf(L_ERROR,
897+ "Servers restarting too "
898+ "quickly, backing off.");
899+ if (backoff < 60 * 60)
900+ backoff <<= 1;
901+ sleep(backoff);
902+ }
903+ } else {
904+ last_restart = now;
905+ restarts = 0;
906+ backoff = 60;
907+ }
908+
909+ /* Locate a free pid slot */
910+ for (i = 0, child = -1; i < ncopies; i++) {
911+ if (servers[i] == 0) {
912+ child = i;
913+ break;
914+ }
915+ }
916+
917+ if (child < 0)
918+ Dprintf(L_FATAL, "failsafe: no pid slot?!");
919+
920+ Dprintf(D_GENERAL,
921+ "starting server thread %d...\n", child + 1);
922+
923+ pid = fork();
924+ if (pid < 0)
925+ Dprintf(L_FATAL,
926+ "Unable to fork for failsafe: %s",
927+ strerror(errno));
928+
929+ if (pid == 0) {
930+ /* Child process: continue with execution. */
931+ return;
932+ }
933+
934+ writepid(pid, 0);
935+ servers[child] = pid;
936+ running++;
937+ }
938+
939+ /* Ignore some signals */
940+ ignore_signal(SIGTERM);
941+ ignore_signal(SIGHUP);
942+ ignore_signal(SIGINT);
943+ ignore_signal(SIGCHLD);
944+
945+ if ((pid = wait(&status)) < 0) {
946+ Dprintf((errno == ECHILD)? L_FATAL : L_WARNING,
947+ "failsafe: wait(): %s", strerror(errno));
948+ continue;
949+ }
950+
951+ /* Locate the child */
952+ for (i = 0, child = -1; i < ncopies; i++) {
953+ if (servers[i] == pid) {
954+ child = i;
955+ break;
956+ }
957+ }
958+
959+ if (child < 0) {
960+ Dprintf(L_WARNING,
961+ "failsafe: unknown child (pid %d) terminated",
962+ pid);
963+ continue;
964+ }
965+
966+ /* Book-keeping */
967+ servers[child] = 0;
968+ running--;
969+
970+ if (WIFSIGNALED(status)) {
971+ signo = WTERMSIG(status);
972+ if (signo == SIGTERM) {
973+ Dprintf(L_NOTICE, "failsafe: "
974+ "child %d terminated by SIGTERM. %s.",
975+ pid, running? "Continue" : "Exit");
976+ } else {
977+ Dprintf(L_WARNING, "failsafe: "
978+ "child %d terminated by %s. "
979+ "Restarting.",
980+ pid, get_signame(signo));
981+ child = -1; /* Restart */
982+ }
983+ } else if (WIFEXITED(status)) {
984+ Dprintf(L_NOTICE, "failsafe: "
985+ "child %d exited, status %d.",
986+ pid, WEXITSTATUS(status));
987+ } else {
988+ Dprintf(L_ERROR, "failsafe: "
989+ "abnormal child termination, "
990+ "pid=%d status=%d. Restarting.",
991+ pid, status);
992+ child = -1; /* Restart */
993+ }
994+
995+ /* If child >= 0, we should not restart */
996+ if (child >= 0) {
997+ if (!running) {
998+ Dprintf(D_GENERAL,
999+ "No more children, exiting.");
1000+ exit(0);
1001+ }
1002+ for (i = child; i < ncopies-1; i++)
1003+ servers[i] = servers[i+1];
1004+ ncopies--; /* Make sure we start no new servers */
1005+ }
1006+ }
1007+}
1008+
1009+/*
1010+ * Failsafe session, catch core file.
1011+ *
1012+ * Not yet implemented.
1013+ * General outline: we need to fork first, because nfsd changes
1014+ * uids frequently, and the kernel won't write out a core file after
1015+ * that. The forked proc starts out with a clean dumpable flag though.
1016+ *
1017+ * After the fork, we might want to make sure we end up in some common
1018+ * directory that the failsafe loop knows about.
1019+ */
1020+void
1021+failsafe_loop(int level, void (*function)(void))
1022+{
1023+ /* NOP */
1024+}
1025+
1026+static const char *
1027+get_signame(int signo)
1028+{
1029+ static char namebuf[30];
1030+
1031+ switch (signo) {
1032+ case SIGHUP: return "SIGHUP";
1033+ case SIGINT: return "SIGINT";
1034+ case SIGQUIT: return "SIGQUIT";
1035+ case SIGILL: return "SIGILL";
1036+ case SIGTRAP: return "SIGTRAP";
1037+ case SIGIOT: return "SIGIOT";
1038+ case SIGBUS: return "SIGBUS";
1039+ case SIGFPE: return "SIGFPE";
1040+ case SIGKILL: return "SIGKILL";
1041+ case SIGUSR1: return "SIGUSR1";
1042+ case SIGSEGV: return "SIGSEGV";
1043+ case SIGUSR2: return "SIGUSR2";
1044+ case SIGPIPE: return "SIGPIPE";
1045+ case SIGALRM: return "SIGALRM";
1046+ case SIGTERM: return "SIGTERM";
1047+ case SIGCHLD: return "SIGCHLD";
1048+ case SIGCONT: return "SIGCONT";
1049+ case SIGSTOP: return "SIGSTOP";
1050+ case SIGTSTP: return "SIGTSTP";
1051+ case SIGTTIN: return "SIGTTIN";
1052+ case SIGTTOU: return "SIGTTOU";
1053+ case SIGURG: return "SIGURG";
1054+ case SIGXCPU: return "SIGXCPU";
1055+ case SIGXFSZ: return "SIGXFSZ";
1056+ case SIGVTALRM: return "SIGVTALRM";
1057+ case SIGPROF: return "SIGPROF";
1058+ case SIGWINCH: return "SIGWINCH";
1059+ case SIGIO: return "SIGIO";
1060+#ifdef SIGPWR
1061+ case SIGPWR: return "SIGPWR";
1062+#endif
1063+ }
1064+
1065+ sprintf(namebuf, "signal #%d", signo);
1066+ return namebuf;
1067+}
1068diff -urN nfs-server-2.2beta47/daemon.h nfs-server-2.2beta51/daemon.h
1069--- nfs-server-2.2beta47/daemon.h Thu Jan 1 01:00:00 1970
1070+++ nfs-server-2.2beta51/daemon.h Fri Nov 8 14:45:52 2002
1071@@ -0,0 +1,18 @@
1072+/*
1073+ * daemon.h
1074+ *
1075+ * Daemon support
1076+ */
1077+
1078+#ifndef CRAWLEY_H
1079+#define CRAWLEY_H
1080+
1081+#define _PATH_NFSD_PIDFILE "/var/run/nfsd.pid"
1082+#define _PATH_MOUNTD_PIDFILE "/var/run/mountd.pid"
1083+
1084+extern void daemonize(void);
1085+extern void setpidpath(const char *);
1086+extern void writepid(pid_t, int);
1087+extern void failsafe(int level, int ncopies);
1088+
1089+#endif /* CRAWLEY_H */
1090diff -urN nfs-server-2.2beta47/exports.man nfs-server-2.2beta51/exports.man
1091--- nfs-server-2.2beta47/exports.man Wed Nov 10 10:18:49 1999
1092+++ nfs-server-2.2beta51/exports.man Fri Nov 8 14:45:36 2002
1093@@ -45,6 +45,12 @@
1094 simultaneously. This is done by specifying an IP address and netmask pair
1095 as
1096 .IR address/netmask .
1097+.IP "world
1098+You can export a directory to the world (i.e. to all computers that
1099+are able to reach your NFS server network-wise) by using the empty
1100+hostname. When exporting to the world, the
1101+.BR root_squash ", " all_squash ", " ro " and " nosetuid
1102+options are turned on by default.
1103 .TP
1104 .B =public
1105 This is a special ``hostname'' that identifies the given directory name
1106@@ -81,6 +87,12 @@
1107 by using the
1108 .IR ro " option.
1109 .TP
1110+.I setuid
1111+This allows clients to assert the setuid and setgid bits on regular
1112+files. For non-anonymous exports, this option is on by default.
1113+For anonymous exports, the default is
1114+.IR nosetuid .
1115+.TP
1116 .I noaccess
1117 This makes everything below the directory inaccessible for the named
1118 client. This is useful when you want to export a directory hierarchy to
1119@@ -296,6 +308,22 @@
1120 .I /usr/X11R6
1121 entry apply. This is also true when the latter is a wildcard or netgroup
1122 entry.
1123+.PP
1124+You should also be careful about where you place spaces in the
1125+exports file. For instance, the following may appear as if you've
1126+exported
1127+.BR /pub " readonly to host " foozle ,
1128+but what this does in fact is export the directory to
1129+.B foozle
1130+with the default options,
1131+.I and
1132+export it to the world with the readonly option:
1133+.PP
1134+.nf
1135+.ta +3i
1136+# bad: export to the world
1137+/pub foozle (ro)
1138+.fi
1139 .SH FILES
1140 /etc/exports
1141 .SH DIAGNOSTICS
1142diff -urN nfs-server-2.2beta47/fh.c nfs-server-2.2beta51/fh.c
1143--- nfs-server-2.2beta47/fh.c Wed Nov 10 10:41:14 1999
1144+++ nfs-server-2.2beta51/fh.c Fri Nov 8 14:45:36 2002
1145@@ -95,17 +95,14 @@
1146 static int fh_list_size;
1147 static time_t curtime;
1148
1149-#ifndef FOPEN_MAX
1150-#define FOPEN_MAX 256
1151-#endif
1152-
1153 #ifndef FHTRACE
1154 #undef D_FHTRACE
1155 #define D_FHTRACE D_FHCACHE
1156 #endif
1157
1158-static fhcache * fd_cache[FOPEN_MAX] = { NULL };
1159+static fhcache ** fd_cache = NULL;
1160 static int fd_cache_size = 0;
1161+static int fd_cache_max = 0;
1162
1163 #ifndef NFSERR_INVAL /* that Sun forgot */
1164 #define NFSERR_INVAL 22
1165@@ -141,10 +138,13 @@
1166
1167 /* Forward declared local functions */
1168 static psi_t path_psi(char *, nfsstat *, struct stat *, int);
1169+static psi_t path_psi_m(char *, nfsstat *, struct stat *,
1170+ struct stat *, int);
1171 static int fh_flush_fds(void);
1172 static char * fh_dump(svc_fh *);
1173 static void fh_insert_fdcache(fhcache *fhc);
1174 static void fh_unlink_fdcache(fhcache *fhc);
1175+static void fh_complain(const char *msg, fhcache *fhc);
1176
1177 static void
1178 fh_move_to_front(fhcache *fhc)
1179@@ -192,6 +192,13 @@
1180 static void
1181 fh_insert_fdcache(fhcache *fhc)
1182 {
1183+#ifdef FHTRACE
1184+ Dprintf(D_FHTRACE, "insert fh %x into fdcache @%d\n", fhc->h.psi, fhc->fd);
1185+ if (fhc->fd < 0) {
1186+ fh_complain("fd cache bug: bad fd", fhc);
1187+ return;
1188+ }
1189+#endif
1190 if (fhc == fd_lru_head)
1191 return;
1192 if (fhc->fd_next || fhc->fd_prev)
1193@@ -203,9 +210,20 @@
1194 fhc->fd_next = fd_lru_head;
1195 fd_lru_head = fhc;
1196
1197+ if (fhc->fd >= fd_cache_max) {
1198+ int oldmax = fd_cache_max, newmax;
1199+
1200+ newmax = (fhc->fd + 8) & ~7;
1201+ fd_cache = (fhcache **) xrealloc(fd_cache, newmax * sizeof(fhcache *));
1202+ memset(fd_cache + oldmax, 0, (newmax - oldmax) * sizeof(fhcache *));
1203+ fd_cache_max = newmax;
1204+ }
1205+
1206 #ifdef FHTRACE
1207 if (fd_cache[fhc->fd] != NULL) {
1208- Dprintf(L_ERROR, "fd cache inconsistency!\n");
1209+ Dprintf(L_ERROR, "fd cache inconsistency (two fh's for same fd)");
1210+ fh_complain("new fh", fhc);
1211+ fh_complain("old fh", fd_cache[fhc->fd]);
1212 return;
1213 }
1214 #endif
1215@@ -225,7 +243,7 @@
1216 } else if (fd_lru_tail == fhc) {
1217 fd_lru_tail = prev;
1218 } else {
1219- Dprintf(L_ERROR, "fd cache inconsistency\n");
1220+ fh_complain("fd cache inconsistency (no next and not at tail)", fhc);
1221 return;
1222 }
1223 if (prev) {
1224@@ -233,13 +251,13 @@
1225 } else if (fd_lru_head == fhc) {
1226 fd_lru_head = next;
1227 } else {
1228- Dprintf(L_ERROR, "fd cache inconsistency\n");
1229+ fh_complain("fd cache inconsistency (no prev and not at head)", fhc);
1230 return;
1231 }
1232
1233 #ifdef FHTRACE
1234 if (fd_cache[fhc->fd] != fhc) {
1235- Dprintf(L_ERROR, "fd cache inconsistency!\n");
1236+ fh_complain("fd cache inconsistency (fd cache ptr mismatch)", fhc);
1237 return;
1238 }
1239 #endif
1240@@ -285,7 +303,7 @@
1241 hash_slot = &((*hash_slot)->hash_next);
1242 if (*hash_slot == NULL)
1243 Dprintf(L_ERROR,
1244- "internal inconsistency -- fhc(%x) not in hash table\n",
1245+ "internal inconsistency -- fhc(%x) not in hash table!\n",
1246 fhc);
1247 else
1248 *hash_slot = fhc->hash_next;
1249@@ -572,7 +590,7 @@
1250 efs_seekdir(dir, cookie_stack[i]);
1251 while ((dp = efs_readdir(dir))) {
1252 char *name = dp->d_name;
1253- int n = strlen(name);
1254+ int n = strlen(name); /* or: dp->d_reclen */
1255
1256 if (pathlen + n + 1 >= NFS_MAXPATHLEN
1257 || (name[0] == '.'
1258@@ -738,7 +756,16 @@
1259 static psi_t
1260 path_psi(char *path, nfsstat *status, struct stat *sbp, int svalid)
1261 {
1262- struct stat sbuf;
1263+ struct stat smounted;
1264+
1265+ return path_psi_m(path, status, sbp, &smounted, svalid);
1266+}
1267+
1268+static psi_t
1269+path_psi_m(char *path, nfsstat *status,
1270+ struct stat *sbp, struct stat *mbp, int svalid)
1271+{
1272+ struct stat sbuf, ddbuf;
1273
1274 if (sbp == NULL)
1275 sbp = &sbuf;
1276@@ -746,10 +773,10 @@
1277 *status = nfs_errno();
1278 return (0);
1279 }
1280+ *mbp = *sbp;
1281 if (S_ISDIR(sbp->st_mode) && strcmp(path, "/") != 0) {
1282 /* Special case for directories--test for mount point. */
1283- struct stat ddbuf;
1284- char *fname;
1285+ char *fname;
1286
1287 /* Find start of last component of path. */
1288 #if 1
1289@@ -819,6 +846,19 @@
1290 return (pseudo_inode(sbp->st_ino, sbp->st_dev));
1291 }
1292
1293+/*
1294+ * Match attributes to make sure we're still referring to the original file
1295+ */
1296+static inline int
1297+fh_attrmatch(struct fhcache *fhc, struct stat *attr)
1298+{
1299+ if (fhc->dev == attr->st_dev
1300+ && fhc->ino == attr->st_ino
1301+ && fhc->type == (attr->st_mode & S_IFMT))
1302+ return 1;
1303+ return 0;
1304+}
1305+
1306 fhcache *
1307 fh_find(svc_fh *h, int mode)
1308 {
1309@@ -838,6 +878,9 @@
1310 ex_state = active;
1311 time(&curtime);
1312 while ((fhc = fh_lookup(h->psi)) != NULL) {
1313+ struct stat sbuf, *s = NULL;
1314+ nfsstat dummy;
1315+
1316 Dprintf(D_FHCACHE, "fh_find: psi=%lx... found '%s', fd=%d\n",
1317 (unsigned long) h->psi,
1318 fhc->path ? fhc->path : "<unnamed>",
1319@@ -857,33 +900,27 @@
1320 * If it doesn't try to rebuild the path.
1321 */
1322 if (check) {
1323- struct stat *s = &fhc->attrs;
1324- psi_t psi;
1325- nfsstat dummy;
1326-
1327+ s = &sbuf;
1328 if (efs_lstat(fhc->path, s) < 0) {
1329 Dprintf(D_FHTRACE,
1330 "fh_find: stale fh: lstat: %m\n");
1331 } else {
1332- fhc->flags |= FHC_ATTRVALID;
1333- /* If pseudo-inos don't match, we fhc->path
1334- * may be a mount point (hence lstat() returns
1335+ /* If device/ino don't match, fhc->path may
1336+ * be a mount point (hence lstat() returns
1337 * a different inode number than the readdir()
1338 * stuff used in path_psi)
1339 */
1340- psi = pseudo_inode(s->st_ino, s->st_dev);
1341- if (h->psi == psi)
1342+ if (fh_attrmatch(fhc, s))
1343 goto fh_return;
1344
1345- /* Try again by computing the path psi */
1346- psi = path_psi(fhc->path, &dummy, s, 1);
1347- if (h->psi == psi)
1348+ /* Get the dev/ino of the underlying
1349+ * mount point. */
1350+ path_psi(fhc->path, &dummy, s, 1);
1351+ if (fh_attrmatch(fhc, s))
1352 goto fh_return;
1353
1354- Dprintf(D_FHTRACE, "fh_find: stale fh: "
1355- "dev/ino %x/%lx psi %lx",
1356- s->st_dev, s->st_ino,
1357- (unsigned long) psi);
1358+ Dprintf(D_FHTRACE, "fh_find: stale fh: %lx",
1359+ (unsigned long) h->psi);
1360 }
1361
1362 fh_discard:
1363@@ -896,6 +933,12 @@
1364 }
1365
1366 fh_return:
1367+ /* Valid attributes; cache them */
1368+ if (s != NULL) {
1369+ memcpy(&fhc->attrs, s, sizeof(*s));
1370+ fhc->flags |= FHC_ATTRVALID;
1371+ }
1372+
1373 /* The cached fh seems valid */
1374 if (fhc != fh_head.next)
1375 fh_move_to_front(fhc);
1376@@ -905,7 +948,8 @@
1377 }
1378
1379 Dprintf(D_FHCACHE, "fh_find: psi=%lx... not found\n",
1380- (unsigned long) h->psi);
1381+ (unsigned long) h->psi);
1382+
1383 if (mode == FHFIND_FCACHED) {
1384 ex_state = inactive;
1385 return NULL;
1386@@ -918,6 +962,7 @@
1387 fhc = flush->prev;
1388 fh_delete(flush);
1389 }
1390+
1391 fhc = (fhcache *) xmalloc(sizeof *fhc);
1392 if (mode == FHFIND_FCREATE) {
1393 /* File will be created */
1394@@ -937,11 +982,31 @@
1395 }
1396 fhc->path = path;
1397 }
1398+
1399 fhc->flags = 0;
1400 if (fhc->path && efs_lstat(fhc->path, &fhc->attrs) >= 0) {
1401- if (re_export && nfsmounted(fhc->path, &fhc->attrs))
1402+ if (nfsmounted(fhc->path, &fhc->attrs)) {
1403 fhc->flags |= FHC_NFSMOUNTED;
1404+#if 0
1405+ /* We must allow the client to send us the
1406+ * file handle for the NFS mount point itself,
1407+ * but not for entries within an NFS mount.
1408+ * XXX: needs fixing.
1409+ */
1410+ if (!re_export) {
1411+ Dprintf(D_FHTRACE,
1412+ "Attempt to use %s (non-exportable)\n",
1413+ fhc->path);
1414+ free(fhc);
1415+ ex_state = inactive;
1416+ return NULL;
1417+ }
1418+#endif
1419+ }
1420 fhc->flags |= FHC_ATTRVALID;
1421+ fhc->dev = fhc->attrs.st_dev;
1422+ fhc->ino = fhc->attrs.st_ino;
1423+ fhc->type = fhc->attrs.st_mode & S_IFMT;
1424 }
1425 fhc->fd = -1;
1426 fhc->last_used = curtime;
1427@@ -993,6 +1058,14 @@
1428 return buf;
1429 }
1430
1431+static void
1432+fh_complain(const char *msg, fhcache *fhc)
1433+{
1434+ Dprintf(L_ERROR, "%s: ptr=%p fd=%d path=%s\n", msg,
1435+ fhc, fhc->fd,
1436+ fhc->path? fhc->path : "<unnamed>");
1437+}
1438+
1439 /*
1440 * This routine is only used by the mount daemon.
1441 * It creates the initial file handle.
1442@@ -1000,23 +1073,25 @@
1443 int
1444 fh_create(nfs_fh *fh, char *path)
1445 {
1446- svc_fh key;
1447- fhcache *h;
1448- psi_t psi;
1449- nfsstat status;
1450- char *s;
1451+ struct stat stb;
1452+ svc_fh key;
1453+ fhcache *h;
1454+ psi_t psi;
1455+ nfsstat status;
1456+ char *s;
1457
1458 memset(&key, 0, sizeof(key));
1459 status = NFS_OK;
1460- if ((psi = path_psi("/", &status, NULL, 0)) == 0)
1461+ if ((psi = path_psi("/", &status, &stb, 0)) == 0)
1462 return ((int) status);
1463+
1464 s = path;
1465 while ((s = strchr(s + 1, '/')) != NULL) {
1466 if (++(key.hash_path[0]) >= HP_LEN)
1467 return ((int) NFSERR_NAMETOOLONG);
1468 key.hash_path[key.hash_path[0]] = hash_psi(psi);
1469 *s = '\0';
1470- if ((psi = path_psi(path, &status, NULL, 0)) == 0)
1471+ if ((psi = path_psi(path, &status, &stb, 0)) == 0)
1472 return ((int) status);
1473 *s = '/';
1474 }
1475@@ -1024,7 +1099,7 @@
1476 if (++(key.hash_path[0]) >= HP_LEN)
1477 return ((int) NFSERR_NAMETOOLONG);
1478 key.hash_path[key.hash_path[0]] = hash_psi(psi);
1479- if ((psi = path_psi(path, &status, NULL, 0)) == 0)
1480+ if ((psi = path_psi(path, &status, &stb, 0)) == 0)
1481 return ((int) status);
1482 }
1483 key.psi = psi;
1484@@ -1037,9 +1112,12 @@
1485
1486 /* assert(h != NULL); */
1487 if (h->path == NULL) {
1488- h->fd = -1;
1489- h->path = xstrdup(path);
1490+ h->fd = -1;
1491+ h->path = xstrdup(path);
1492 h->flags = 0;
1493+ h->dev = stb.st_dev;
1494+ h->ino = stb.st_ino;
1495+ h->type = stb.st_mode & S_IFMT;
1496 }
1497 memcpy(fh, &key, sizeof(key));
1498 return ((int) status);
1499@@ -1064,6 +1142,44 @@
1500 return ((nfs_fh*)&(h->h));
1501 }
1502
1503+
1504+static inline int
1505+access_override(int omode, int perm, struct stat *buf)
1506+{
1507+ /* Be suspicous of flags, particularly O_CREAT/O_TRUNC. A previous
1508+ * comment said:
1509+ *
1510+ * "[Not checking this] would truncate read-only files on creat()
1511+ * calls. Of course, ftruncate(fd, 0) should still be legal for
1512+ * the user when the file was chmoded *after* opening it, but we
1513+ * have no way to tell, and a semi-succeding `cp foo readonly-file'
1514+ * is much more unintuitive and destructive than a failing
1515+ * ftruncate()."
1516+ */
1517+ if (omode & ~O_ACCMODE)
1518+ return 0;
1519+
1520+ /* Users can do anything to their own files. Harmless (since they
1521+ * could chown anyway), and helps to mask NFSes statelessness.
1522+ *
1523+ * (in passing, this also handles mode 0100 execution)
1524+ */
1525+ if (buf->st_uid == auth_uid)
1526+ return 1;
1527+
1528+ /* Henceforth, we are considering granting read access to facilitate
1529+ * exec access. This is read only */
1530+ if (omode != O_RDONLY)
1531+ return 0;
1532+
1533+ /* Mode 0110 execution */
1534+ if (buf->st_gid == auth_gid)
1535+ return (buf->st_mode & S_IXGRP) != 0;
1536+
1537+ /* Mode 0111 execution */
1538+ return (buf->st_mode & S_IXOTH) != 0;
1539+}
1540+
1541 int
1542 path_open(char *path, int omode, int perm)
1543 {
1544@@ -1113,30 +1229,15 @@
1545 * lishes two things: first, it gives the file owner r/w access to
1546 * the file whatever the permissions are, so that files are still
1547 * accessible after an fchown(fd, 0). The second part of the
1548- * condition allows read access to mode 0111 executables.
1549- *
1550- * The old conditon read like this:
1551- * if (fd < 0 && oerrno == EACCES) {
1552- * if (oerrno == EACCES && (buf.st_uid == auth_uid
1553- * || (omode == O_RDONLY && (buf.st_mode & S_IXOTH)))) {
1554- * override uid; etc...
1555- * }
1556- * }
1557- * This would truncate read-only files on creat() calls. Now
1558- * ftruncate(fd, 0) should still be legal for the user when the
1559- * file was chmoded *after* opening it, but we have no way to tell,
1560- * and a semi-succeding `cp foo readonly-file' is much more
1561- * unintuitive and destructive than a failing ftruncate().
1562+ * condition allows read access to `execute-only' files.
1563 */
1564- if (fd < 0 && oerrno == EACCES && !(omode & (O_CREAT|O_TRUNC))) {
1565- if ((buf.st_uid == auth_uid && (omode & O_ACCMODE) == omode)
1566- || ((buf.st_mode & S_IXOTH) && omode == O_RDONLY)) {
1567- auth_override_uid(ROOT_UID);
1568- fd = efs_open(path, omode, perm);
1569- oerrno = errno;
1570- auth_override_uid(auth_uid);
1571- }
1572+ if (fd < 0 && oerrno == EACCES && access_override(omode, perm, &buf)) {
1573+ auth_override_uid(ROOT_UID);
1574+ fd = efs_open(path, omode, perm);
1575+ oerrno = errno;
1576+ auth_override_uid(auth_uid);
1577 }
1578+
1579
1580 if (fd < 0) {
1581 Dprintf(D_FHCACHE,
1582@@ -1241,7 +1342,7 @@
1583 char *sindx;
1584 int is_dd;
1585 nfsstat ret;
1586- struct stat sbuf;
1587+ struct stat sbuf, smount;
1588 char pathbuf[PATH_MAX + NAME_MAX + 1], *fname;
1589
1590 /* should not happen */
1591@@ -1318,7 +1419,7 @@
1592
1593 *new_fh = dopa->dir;
1594 key = (svc_fh *) new_fh;
1595- if ((key->psi = path_psi(pathbuf, &ret, sbp, 0)) == 0)
1596+ if ((key->psi = path_psi_m(pathbuf, &ret, sbp, &smount, 0)) == 0)
1597 return (ret);
1598
1599 if (is_dd) {
1600@@ -1344,6 +1445,10 @@
1601 h->h.hash_path[0]);
1602 return NFSERR_STALE;
1603 }
1604+ if (sbp->st_dev != smount.st_dev) {
1605+ Dprintf(D_FHTRACE, "fh_compose: %s hit%s mount point\n",
1606+ pathbuf, nfsmounted(pathbuf, &smount)? " NFS" : "");
1607+ }
1608 #endif
1609
1610 /* New code added by Don Becker */
1611@@ -1356,7 +1461,8 @@
1612 if (!h) return NFSERR_STALE;
1613 #endif
1614 if (h->path)
1615- Dprintf(L_ERROR, "Internal inconsistency: double entry (path '%s', now '%s').\n",
1616+ Dprintf(L_ERROR,
1617+ "internal inconsistency: double entry (path '%s', now '%s').\n",
1618 h->path, pathbuf);
1619 }
1620 Dprintf(D_FHCACHE, "fh_compose: using handle %x ('%s', fd=%d)\n",
1621@@ -1365,9 +1471,18 @@
1622
1623 /* assert(h != NULL); */
1624 if (h->path == 0) {
1625- h->path = xstrdup(pathbuf);
1626+ h->path = xstrdup(pathbuf);
1627 h->flags = 0;
1628- if (!re_export && nfsmounted(pathbuf, sbp))
1629+ h->dev = sbp->st_dev;
1630+ h->ino = sbp->st_ino;
1631+ h->type = sbp->st_mode & S_IFMT;
1632+
1633+ /* Note: in the case of a mount point,
1634+ * sbp contains the stats of the mount point, while
1635+ * ddbuf has the dev/ino of the underlying directory
1636+ */
1637+ if (sbp->st_dev != smount.st_dev
1638+ && nfsmounted(pathbuf, &smount))
1639 h->flags |= FHC_NFSMOUNTED;
1640 #ifdef FHTRACE
1641 Dprintf(D_FHTRACE, "fh_compose: created handle %s\n", h->path);
1642diff -urN nfs-server-2.2beta47/fh.h nfs-server-2.2beta51/fh.h
1643--- nfs-server-2.2beta47/fh.h Mon Nov 23 12:15:43 1998
1644+++ nfs-server-2.2beta51/fh.h Fri Nov 8 14:45:36 2002
1645@@ -97,7 +97,13 @@
1646 struct fhcache * hash_next;
1647 struct fhcache * fd_next;
1648 struct fhcache * fd_prev;
1649+
1650+ /* These are fixed during the lifetime of this object */
1651 svc_fh h;
1652+ dev_t dev;
1653+ ino_t ino;
1654+ mode_t type; /* st_mode & S_IFMT */
1655+
1656 int fd;
1657 int omode;
1658 char * path;
1659diff -urN nfs-server-2.2beta47/getattr.c nfs-server-2.2beta51/getattr.c
1660--- nfs-server-2.2beta47/getattr.c Fri Oct 30 18:10:11 1998
1661+++ nfs-server-2.2beta51/getattr.c Fri Nov 8 14:45:36 2002
1662@@ -115,6 +115,16 @@
1663 attr->fsid = 1;
1664 attr->fileid = fh_psi((nfs_fh *)&(fhc->h));
1665 #endif
1666+
1667+ /* This may be needed by some Suns... testing */
1668+#define MINTIME (24 * 2600)
1669+ if (s->st_atime < MINTIME)
1670+ s->st_atime = MINTIME;
1671+ if (s->st_mtime < MINTIME)
1672+ s->st_mtime = MINTIME;
1673+ if (s->st_ctime < MINTIME)
1674+ s->st_ctime = MINTIME;
1675+
1676 attr->atime.seconds = s->st_atime;
1677 attr->atime.useconds = 0;
1678 attr->mtime.seconds = s->st_mtime;
1679diff -urN nfs-server-2.2beta47/logging.c nfs-server-2.2beta51/logging.c
1680--- nfs-server-2.2beta47/logging.c Fri Oct 30 17:11:22 1998
1681+++ nfs-server-2.2beta51/logging.c Fri Nov 8 14:45:36 2002
1682@@ -147,8 +147,9 @@
1683 (void) time(&now);
1684 tm = localtime(&now);
1685 fprintf(log_fp, "%s %02d/%02d/%02d %02d:%02d %s",
1686- log_name, tm->tm_mon + 1, tm->tm_mday, tm->tm_year,
1687- tm->tm_hour, tm->tm_min, buff);
1688+ log_name, tm->tm_mon + 1, tm->tm_mday,
1689+ tm->tm_year % 100,
1690+ tm->tm_hour, tm->tm_min, buff);
1691 if (strchr(buff, '\n') == NULL)
1692 fputc('\n', log_fp);
1693 }
1694@@ -182,7 +183,8 @@
1695 tm = localtime(&unix_cred->aup_time);
1696 snprintf(buffer + len, total - len,
1697 "%d/%d/%d %02d:%02d:%02d %s %d.%d",
1698- tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
1699+ tm->tm_year %100,
1700+ tm->tm_mon + 1, tm->tm_mday,
1701 tm->tm_hour, tm->tm_min, tm->tm_sec,
1702 unix_cred->aup_machname,
1703 unix_cred->aup_uid,
1704diff -urN nfs-server-2.2beta47/mountd.c nfs-server-2.2beta51/mountd.c
1705--- nfs-server-2.2beta47/mountd.c Wed Jun 2 14:10:33 1999
1706+++ nfs-server-2.2beta51/mountd.c Fri Nov 8 14:45:36 2002
1707@@ -32,7 +32,7 @@
1708 #include "rpcmisc.h"
1709 #include "rmtab.h"
1710 #include "haccess.h"
1711-#include "failsafe.h"
1712+#include "daemon.h"
1713 #include "signals.h"
1714 #include <rpc/pmap_clnt.h>
1715
1716@@ -44,6 +44,8 @@
1717 /*
1718 * Option table for mountd
1719 */
1720+#define OPT_NOTCP 300
1721+#define OPT_LOOPBACK 301
1722 static struct option longopts[] =
1723 {
1724 { "debug", required_argument, 0, 'd' },
1725@@ -56,6 +58,8 @@
1726 { "no-spoof-trace", 0, 0, 't' },
1727 { "version", 0, 0, 'v' },
1728 { "fail-safe", optional_argument, 0, 'z' },
1729+ { "no-tcp", 0, 0, OPT_NOTCP },
1730+ { "loopback-only", 0, 0, OPT_LOOPBACK },
1731
1732 { NULL, 0, 0, 0 }
1733 };
1734@@ -358,6 +362,12 @@
1735 break;
1736 case 0:
1737 break;
1738+ case OPT_NOTCP:
1739+ udp_only = 1;
1740+ break;
1741+ case OPT_LOOPBACK:
1742+ loopback_only = 1;
1743+ break;
1744 case '?':
1745 default:
1746 usage(stderr, 1);
1747@@ -384,38 +394,27 @@
1748 /* Create services and register with portmapper */
1749 rpc_init("mountd", MOUNTPROG, mountd_versions, mount_dispatch, port, 0);
1750
1751- if (!foreground && !_rpcpmstart) {
1752-#ifndef RPC_SVC_FG
1753- /* We first fork off a child. */
1754- if ((c = fork()) > 0)
1755- exit(0);
1756- if (c < 0) {
1757- Dprintf(L_FATAL, "mountd: cannot fork: %s\n",
1758- strerror(errno));
1759- }
1760- /* No more logging to stderr */
1761- background_logging();
1762+ if (_rpcpmstart) {
1763+ /* Always foreground mode */
1764+ foreground = 1;
1765
1766- /* Now we remove ourselves from the foreground. */
1767- (void) close(0);
1768- (void) close(1);
1769- (void) close(2);
1770-#ifdef TIOCNOTTY
1771- if ((c = open("/dev/tty", O_RDWR)) >= 0) {
1772- (void) ioctl(c, TIOCNOTTY, (char *) NULL);
1773- (void) close(c);
1774- }
1775-#else
1776- setsid();
1777-#endif
1778-#endif /* not RPC_SVC_FG */
1779+ /* ... but no logging */
1780+ background_logging();
1781 }
1782
1783+ /* Become a daemon */
1784+ if (!foreground)
1785+ daemonize();
1786+
1787 /* Initialize the FH module. */
1788 fh_init();
1789
1790 /* Initialize the AUTH module. */
1791 auth_init(auth_file);
1792+
1793+ /* Write pidfile */
1794+ setpidpath(_PATH_MOUNTD_PIDFILE);
1795+ writepid(getpid(), 1);
1796
1797 /* Failsafe mode */
1798 if (failsafe_level)
1799diff -urN nfs-server-2.2beta47/mountd.man nfs-server-2.2beta51/mountd.man
1800--- nfs-server-2.2beta47/mountd.man Wed Jun 2 14:12:21 1999
1801+++ nfs-server-2.2beta51/mountd.man Fri Nov 8 14:45:36 2002
1802@@ -14,6 +14,8 @@
1803 .B "[\ \-\-allow\-non\-root\ ]"
1804 .B "[\ \-\-re\-export\ ]"
1805 .B "[\ \-\-no\-spoof\-trace\ ]"
1806+.B "[\ \-\-no\-tcp ]"
1807+.B "[\ \-\-loopback\-only ]"
1808 .B "[\ \-\-version\ ]"
1809 .ad b
1810 .SH DESCRIPTION
1811@@ -123,6 +125,18 @@
1812 .TP
1813 .BR \-v " or " \-\-version
1814 Report the current version number of the program.
1815+.TP
1816+.BR \-\-no\-tcp
1817+Force
1818+.I mountd
1819+to register only the UDP transport, but no TCP.
1820+This is an experimental option.
1821+.TP
1822+.BR \-\-loopback\-only
1823+Force
1824+.I mountd
1825+to bind to the loopback interface.
1826+This is an experimental option.
1827 .SS Access Control
1828 For enhanced security, access to
1829 .I mountd
1830diff -urN nfs-server-2.2beta47/nfsd.c nfs-server-2.2beta51/nfsd.c
1831--- nfs-server-2.2beta47/nfsd.c Wed Nov 10 10:33:28 1999
1832+++ nfs-server-2.2beta51/nfsd.c Fri Nov 8 14:45:36 2002
1833@@ -21,7 +21,7 @@
1834 #include "getopt.h"
1835 #include "fsusage.h"
1836 #include "rpcmisc.h"
1837-#include "failsafe.h"
1838+#include "daemon.h"
1839 #include "signals.h"
1840 #ifdef __linux__ /* XXX - MvS: for UNIX sockets. */
1841 # include <sys/un.h>
1842@@ -30,7 +30,6 @@
1843 # include <syslog.h>
1844 #endif
1845
1846-#define MULTIPLE_SERVERS
1847
1848 /* Flags for auth_fh */
1849 #define CHK_READ 0
1850@@ -51,6 +50,8 @@
1851 /*
1852 * Option table
1853 */
1854+#define OPT_NOTCP 300
1855+#define OPT_LOOPBACK 301
1856 static struct option longopts[] = {
1857 { "auth-deamon", required_argument, 0, 'a' },
1858 { "debug", required_argument, 0, 'd' },
1859@@ -68,6 +69,9 @@
1860 { "version", 0, 0, 'v' },
1861 { "no-cross-mounts", 0, 0, 'x' },
1862 { "fail-safe", optional_argument, 0, 'z' },
1863+ { "no-tcp", 0, 0, OPT_NOTCP },
1864+ { "udp-only", 0, 0, OPT_NOTCP },
1865+ { "loopback-only", 0, 0, OPT_LOOPBACK },
1866
1867 { NULL, 0, 0, 0 }
1868 };
1869@@ -173,7 +177,10 @@
1870 return NULL;
1871 }
1872
1873- auth_user(nfsmount, rqstp);
1874+ if (!auth_user(nfsmount, rqstp)) {
1875+ *statp = NFSERR_ACCES;
1876+ return NULL;
1877+ }
1878
1879 *statp = NFS_OK;
1880 return fhc;
1881@@ -211,7 +218,11 @@
1882
1883 if ((nfsmount = auth_path(nfsclient, rqstp, path)) == NULL)
1884 return NFSERR_ACCES;
1885- auth_user(nfsmount, rqstp);
1886+
1887+ /* XXX: really need to call it again here?
1888+ * Already invoked in auth_fh */
1889+ if (!auth_user(nfsmount, rqstp))
1890+ return NFSERR_ACCES;
1891
1892 return (NFS_OK);
1893 }
1894@@ -575,7 +586,8 @@
1895 #endif
1896
1897 /* MvS: Some clients use chardev 0xFFFF for a FIFO. */
1898- if (S_ISCHR(argp->attributes.mode) && dev == 0xFFFF) {
1899+ if (S_ISCHR(argp->attributes.mode)
1900+ && (dev == 0xFFFF || dev == (dev_t) -1)) {
1901 is_borc = 0;
1902 dev = 0;
1903 argp->attributes.mode &= ~S_IFMT;
1904@@ -623,7 +635,7 @@
1905 flags = (argp->attributes.size == 0 ?
1906 CREATE_OMODE | O_TRUNC : CREATE_OMODE);
1907 if (!exists)
1908- flags |= O_CREAT;
1909+ flags |= O_CREAT|O_EXCL;
1910 tmpfd = path_open(pathbuf, flags,
1911 argp->attributes.mode & ~S_IFMT);
1912 if (tmpfd < 0)
1913@@ -965,9 +977,7 @@
1914 int nfsport = 0;
1915 int failsafe_level = 0;
1916 int c;
1917-#ifdef MULTIPLE_SERVERS
1918 int i, ncopies = 1;
1919-#endif
1920
1921 program_name = argv[0];
1922 chdir("/");
1923@@ -1031,12 +1041,17 @@
1924 break;
1925 case 0:
1926 break;
1927+ case OPT_NOTCP:
1928+ udp_only = 1;
1929+ break;
1930+ case OPT_LOOPBACK:
1931+ loopback_only = 1;
1932+ break;
1933 case '?':
1934 default:
1935 usage(stderr, 1);
1936 }
1937
1938-#ifdef MULTIPLE_SERVERS
1939 if (optind == argc-1 && isdigit(argv[optind][0])) {
1940 ncopies = atoi(argv[optind++]);
1941 if (ncopies <= 0) {
1942@@ -1051,7 +1066,6 @@
1943 ncopies = 1;
1944 }
1945 }
1946-#endif
1947
1948 /* No more arguments allowed. */
1949 if (optind != argc)
1950@@ -1075,72 +1089,54 @@
1951 rpc_init("nfsd", NFS_PROGRAM, nfsd_versions, nfs_dispatch,
1952 nfsport, NFS_MAXDATA);
1953
1954- /* No more than 1 copy when run from inetd */
1955- if (_rpcpmstart && ncopies > 1) {
1956- Dprintf(L_WARNING,
1957- "nfsd: warning: can run only "
1958- "one server in inetd mode\n");
1959- ncopies = 1;
1960+ if (_rpcpmstart) {
1961+ /* Always do foreground mode */
1962+ foreground = 1;
1963+
1964+ /* ... but don't log to stderr */
1965+ background_logging();
1966+
1967+ /* No more than 1 copy when run from inetd */
1968+ if (ncopies > 1) {
1969+ Dprintf(L_WARNING,
1970+ "nfsd: warning: can run only "
1971+ "one server in inetd mode\n");
1972+ ncopies = 1;
1973+ }
1974 }
1975
1976-#ifndef MULTIPLE_SERVERS_READWRITE
1977 if (ncopies > 1)
1978 read_only = 1;
1979-#endif
1980
1981- /* We first fork off a child. */
1982- if (!foreground) {
1983- if ((c = fork()) > 0)
1984- exit(0);
1985- if (c < 0) {
1986- Dprintf(L_FATAL, "nfsd: cannot fork: %s\n",
1987- strerror(errno));
1988- }
1989- }
1990+ /*
1991+ * We first fork off a child and detach from tty
1992+ */
1993+ if (!foreground)
1994+ daemonize();
1995
1996 /* Initialize the AUTH module. */
1997 auth_init(auth_file);
1998
1999+ setpidpath(_PATH_NFSD_PIDFILE);
2000 if (failsafe_level == 0) {
2001 /* Start multiple copies of the server */
2002+ writepid(getpid(), 1);
2003 for (i = 1; i < ncopies; i++) {
2004+ pid_t pid;
2005+
2006 Dprintf(D_GENERAL, "Forking server thread...\n");
2007- if ((c = fork()) < 0) {
2008+ if ((pid = fork()) < 0) {
2009 Dprintf(L_ERROR, "Unable to fork: %s",
2010 strerror(errno));
2011- } else if (c == 0) {
2012- /* Child process */
2013- break;
2014+ } else if (pid != 0) {
2015+ writepid(pid, 0);
2016+ } else {
2017+ break; /* Child process */
2018 }
2019 }
2020 } else {
2021 /* Init for failsafe mode */
2022 failsafe(failsafe_level, ncopies);
2023- }
2024-
2025- /* Now that we've done all the required forks, we make do all the
2026- * session magic.
2027- */
2028- if (!foreground) {
2029- /* No more logging to stderr */
2030- background_logging();
2031-
2032- /* Now we remove ourselves from the foreground. */
2033- close(0);
2034- close(1);
2035- close(2);
2036-#ifdef HAVE_SETSID
2037- setsid();
2038-#else
2039- {
2040- int fd;
2041-
2042- if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
2043- ioctl(fd, TIOCNOTTY, (char *) NULL);
2044- close(fd);
2045- }
2046- }
2047-#endif
2048 }
2049
2050 /*
2051diff -urN nfs-server-2.2beta47/nfsd.man nfs-server-2.2beta51/nfsd.man
2052--- nfs-server-2.2beta47/nfsd.man Wed Jun 2 14:13:37 1999
2053+++ nfs-server-2.2beta51/nfsd.man Fri Nov 8 14:45:36 2002
2054@@ -8,7 +8,7 @@
2055 .B "[\ \-d\ facility\ ]"
2056 .B "[\ \-P\ port\ ]"
2057 .B "[\ \-R\ dirname\ ]"
2058-.B "[\ \-Fhlnprstv\ ]"
2059+.B "[\ \-Fhlnprstuv\ ]"
2060 .B "[\ \-\-debug\ facility\ ]"
2061 .B "[\ \-\-exports\-file=file\ ]"
2062 .B "[\ \-\-foreground\ ]"
2063@@ -18,6 +18,8 @@
2064 .B "[\ \-\-public\-root\ dirname\ ]"
2065 .\".B "[\ \-\-synchronous\-writes\ ]"
2066 .B "[\ \-\-no\-spoof\-trace\ ]"
2067+.B "[\ \-\-no\-tcp ]"
2068+.B "[\ \-\-loopback-only ]"
2069 .B "[\ \-\-port\ port\ ]"
2070 .B "[\ \-\-log-transfers\ ]"
2071 .B "[\ \-\-version\ ]"
2072@@ -56,7 +58,7 @@
2073 .PP
2074 When run from
2075 .IR inetd ,
2076-.i nfsd
2077+.I nfsd
2078 will terminate after a certain period of inactivity.
2079 .SH OPTIONS
2080 .TP
2081@@ -167,6 +169,14 @@
2082 .BR \-v " or " \-\-version
2083 Report the current version number of the program.
2084 .TP
2085+.BR \-\-no\-tcp
2086+Force nfsd to only register a UDP transport, but not TCP.
2087+This is an experimental option.
2088+.TP
2089+.BR \-\-loopback\-only
2090+Force nfsd to bind to the loopback interface.
2091+This is an experimental option.
2092+.TP
2093 .BR numcopies
2094 This is an experimental feature that lets you run several instances of
2095 .I nfsd
2096@@ -174,15 +184,8 @@
2097 .B numcopies
2098 greater than one,
2099 .I nfsd
2100-will fork as many times as specified by this value.
2101-However, the servers do not share a common file handle
2102-cache, which makes certain file operations impossible.
2103-.IP
2104-For this reason,
2105-.I nfsd
2106-will disallow all write operations when invoked with this option. Although
2107-this is very limiting, this feature may still prove useful for exporting
2108-public FTP areas or Usenet News spools.
2109+will fork as many times as specified by this value so it is able to
2110+handle that many NFS requests in parallel.
2111 .SS WebNFS Support
2112 WebNFS is an extension to the normal NFS protocol developed by Sun
2113 that is particularly well-suited for file retrieval over the
2114@@ -268,6 +271,19 @@
2115 .I nfsd
2116 writes out a transfer record whenever it encounters a READ or WRITE
2117 request at offset zero.
2118+.SS Generating a debug trace
2119+When suspecting a bug in nfsd, it is helpful to look at a debug trace
2120+of what's going on. You can create such a trace by first killing nfsd,
2121+and then restarting it as
2122+.PP
2123+.nf
2124+.ta +3i
2125+/usr/sbin/rpc.nfsd -F -d all
2126+.fi
2127+.PP
2128+Instead of
2129+.BR all ,
2130+you can use less verbose debug facilities as described above.
2131 .SH "SEE ALSO"
2132 exports(5), mountd(8), ugidd(8C)
2133 .SH AUTHORS
2134diff -urN nfs-server-2.2beta47/rmtab.c nfs-server-2.2beta51/rmtab.c
2135--- nfs-server-2.2beta47/rmtab.c Fri Feb 6 09:43:25 1998
2136+++ nfs-server-2.2beta51/rmtab.c Fri Nov 8 14:45:36 2002
2137@@ -8,6 +8,7 @@
2138
2139 #include "nfsd.h"
2140 #include "rmtab.h"
2141+#include "rpcmisc.h"
2142
2143 static char * rmtab_gethost(struct svc_req *);
2144 static int rmtab_insert(char *, char *);
2145diff -urN nfs-server-2.2beta47/rpcmisc.c nfs-server-2.2beta51/rpcmisc.c
2146--- nfs-server-2.2beta47/rpcmisc.c Tue Sep 7 10:42:58 1999
2147+++ nfs-server-2.2beta51/rpcmisc.c Fri Nov 8 14:45:36 2002
2148@@ -39,6 +39,8 @@
2149 int _rpcfdtype = 0;
2150 int _rpcsvcdirty = 0;
2151 const char * auth_daemon = 0;
2152+int udp_only = 0;
2153+int loopback_only = 0;
2154
2155 #ifdef AUTH_DAEMON
2156 static bool_t (*tcp_rendevouser)(SVCXPRT *, struct rpc_msg *);
2157@@ -96,7 +98,7 @@
2158 }
2159 }
2160
2161- if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_STREAM)) {
2162+ if ((_rpcfdtype == 0 && !udp_only) || (_rpcfdtype == SOCK_STREAM)) {
2163 if (_rpcfdtype == 0 && defport != 0)
2164 sock = makesock(defport, IPPROTO_TCP, bufsiz);
2165 transp = svctcp_create(sock, 0, 0);
2166@@ -199,6 +201,9 @@
2167 sin.sin_family = AF_INET;
2168 sin.sin_addr.s_addr = INADDR_ANY;
2169 sin.sin_port = htons(port);
2170+
2171+ if (loopback_only)
2172+ sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
2173
2174 #ifdef DEBUG
2175 {
2176diff -urN nfs-server-2.2beta47/rpcmisc.h nfs-server-2.2beta51/rpcmisc.h
2177--- nfs-server-2.2beta47/rpcmisc.h Tue Sep 7 10:37:38 1999
2178+++ nfs-server-2.2beta51/rpcmisc.h Fri Nov 8 14:45:36 2002
2179@@ -9,6 +9,8 @@
2180 extern int _rpcpmstart;
2181 extern int _rpcfdtype;
2182 extern int _rpcsvcdirty;
2183+extern int udp_only;
2184+extern int loopback_only;
2185 extern const char * auth_daemon;
2186
2187 extern void rpc_init(const char *name, int prog, int *verstbl,
2188@@ -16,5 +18,13 @@
2189 int defport, int bufsize);
2190 extern void rpc_exit(int prog, int *verstbl);
2191 extern void rpc_closedown(void);
2192+
2193+/*
2194+ * Some older systems don't have svc_getcaller.
2195+ * Some, like glibc 2.2, have it but it returns some type that's
2196+ * not a sockaddr_in anymore.
2197+ */
2198+#undef svc_getcaller
2199+#define svc_getcaller(xprt) ((struct sockaddr_in *) (&(xprt)->xp_raddr))
2200
2201 #endif /* RPCMISC_H */
2202diff -urN nfs-server-2.2beta47/setattr.c nfs-server-2.2beta51/setattr.c
2203--- nfs-server-2.2beta47/setattr.c Fri Oct 30 18:29:42 1998
2204+++ nfs-server-2.2beta51/setattr.c Fri Nov 8 14:45:36 2002
2205@@ -103,6 +103,10 @@
2206 if (flags & SATTR_CHMOD) {
2207 unsigned int mode = attr->mode;
2208
2209+ /* If setuid is not allowed, silently squash them */
2210+ if (!nfsmount->o.allow_setuid && S_ISREG(s->st_mode))
2211+ mode &= ~(S_ISUID|S_ISGID) | s->st_mode;
2212+
2213 if (mode != -1 && mode != 0xFFFF /* ultrix bug */
2214 && (mode & 07777) != (s->st_mode & 07777)) {
2215 if (efs_chmod(path, mode) < 0)
2216diff -urN nfs-server-2.2beta47/showmount.c nfs-server-2.2beta51/showmount.c
2217--- nfs-server-2.2beta47/showmount.c Wed Jun 12 22:31:04 1996
2218+++ nfs-server-2.2beta51/showmount.c Fri Nov 8 14:45:36 2002
2219@@ -162,17 +162,13 @@
2220 break;
2221 }
2222
2223- if (hostname[0] >= '0' && hostname[0] <= '9') {
2224- server_addr.sin_family = AF_INET;
2225- server_addr.sin_addr.s_addr = inet_addr(hostname);
2226- }
2227- else {
2228+ server_addr.sin_family = AF_INET;
2229+ if (!inet_aton(hostname, &server_addr.sin_addr)) {
2230 if ((hp = gethostbyname(hostname)) == NULL) {
2231 fprintf(stderr, "%s: can't get address for %s\n",
2232 program_name, hostname);
2233 exit(1);
2234 }
2235- server_addr.sin_family = AF_INET;
2236 memcpy(&server_addr.sin_addr, hp->h_addr, hp->h_length);
2237 }
2238
2239diff -urN nfs-server-2.2beta47/site.h.in nfs-server-2.2beta51/site.h.in
2240--- nfs-server-2.2beta47/site.h.in Thu Jan 1 01:00:00 1970
2241+++ nfs-server-2.2beta51/site.h.in Fri Nov 8 14:45:57 2002
2242@@ -0,0 +1,50 @@
2243+/*
2244+ * Site-specific configuration options generated by BUILD.
2245+ * Please do not edit.
2246+ */
2247+
2248+/*
2249+ * If ENABLE_DEVTAB is defined, nfsd will use the new inode
2250+ * number generation scheme for avoiding inode number clashes
2251+ * on big hard disks.
2252+ */
2253+#undef ENABLE_DEVTAB
2254+
2255+/*
2256+ * If MULTIPLE_SERVER_READWRITE is defined, you will be able
2257+ * to run several nfsd process in parallel servicing all NFS
2258+ * requests.
2259+ */
2260+#define MULTIPLE_SERVERS_READWRITE
2261+
2262+/*
2263+ * If ENABLE_UGID_DAEMON is defined, the real rpc.ugidd is built,
2264+ * nfsd is built to support ugidd queries.
2265+ * Otherwise, a dummy program is created
2266+ */
2267+#undef ENABLE_UGID_DAEMON
2268+
2269+/*
2270+ * If ENABLE_UGID_NIS is defined, nfsd will support user mapping
2271+ * vie the client's NIS server.
2272+ */
2273+#undef ENABLE_UGID_NIS
2274+
2275+/*
2276+ * if HOSTS_ACCESS is defined, ugidd uses host access control
2277+ * provided by libwrap.a from tcp_wrappers
2278+ */
2279+#define HOSTS_ACCESS
2280+
2281+/*
2282+ * Define correct ownership of export control file
2283+ */
2284+#define EXPORTSOWNERUID 0
2285+#define EXPORTSOWNERGID 0
2286+
2287+/*
2288+ * If WANT_LOG_MOUNTS is defined, every mount request will be logged
2289+ * to syslogd with the name of source site and a path that was
2290+ * it requested
2291+ */
2292+#define WANT_LOG_MOUNTS
2293diff -urN nfs-server-2.2beta47/ugidd.c nfs-server-2.2beta51/ugidd.c
2294--- nfs-server-2.2beta47/ugidd.c Wed Dec 10 12:34:16 1997
2295+++ nfs-server-2.2beta51/ugidd.c Fri Nov 8 14:45:36 2002
2296@@ -43,9 +43,7 @@
2297 };
2298
2299 int
2300-main(argc, argv)
2301-int argc;
2302-char **argv;
2303+main(int argc, char **argv)
2304 {
2305 SVCXPRT *transp;
2306 int c, longind;
2307@@ -92,32 +90,11 @@
2308 exit(1);
2309 }
2310
2311- if (!foreground) {
2312- if ((c = fork()) > 0)
2313- exit(0);
2314- if (c < 0) {
2315- fprintf(stderr, "ugidd: cannot fork: %s\n",
2316- strerror(errno));
2317- exit(-1);
2318- }
2319- close(0);
2320- close(1);
2321- close(2);
2322-#ifdef HAVE_SETSID
2323- setsid();
2324-#else
2325- {
2326- int fd;
2327-
2328- if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
2329- ioctl(fd, TIOCNOTTY, (char *) NULL);
2330- close(fd);
2331- }
2332- }
2333-#endif
2334- }
2335-
2336 log_open("ugidd", foreground);
2337+
2338+ /* Become a daemon */
2339+ if (!foreground)
2340+ daemonize();
2341
2342 svc_run();
2343 Dprintf(L_ERROR, "svc_run returned\n");
2344diff -urN nfs-server-2.2beta47/version.c nfs-server-2.2beta51/version.c
2345--- nfs-server-2.2beta47/version.c Wed Nov 10 10:33:33 1999
2346+++ nfs-server-2.2beta51/version.c Fri Nov 8 14:45:36 2002
2347@@ -1 +1 @@
2348-char version[] = "Universal NFS Server 2.2beta47";
2349+char version[] = "Universal NFS Server 2.2beta51";
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/002-destdir.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/002-destdir.patch
deleted file mode 100644
index df290f2277..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/002-destdir.patch
+++ /dev/null
@@ -1,73 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/Makefile.in 2002/11/07 16:56:07 1.1
9+++ nfs-server/Makefile.in 2002/11/07 17:08:41
10@@ -74,10 +74,10 @@
11
12 bindir = $(exec_prefix)/sbin
13 #vardir = $(install_prefix)/var/lib/nfs
14-infodir = $(prefix)/info
15-man5dir = $(prefix)/man/man5
16+infodir = $(prefix)/share/info
17+man5dir = $(prefix)/share/man/man5
18 man5ext = .5
19-man8dir = $(prefix)/man/man8
20+man8dir = $(prefix)/share/man/man8
21 man8ext = .8
22
23 # Prefix to be prepended to each installed RPC program, normally `rpc.'.
24@@ -145,37 +145,37 @@
25 .PHONY: install installdirs
26 install: $(DAEMONS) $(CLIENTS) installdirs
27 @for prog in $(DAEMONS) $(CLIENTS); do \
28- echo "installing $$prog in $(bindir)"; \
29- $(INSTALL_PROGRAM) $$prog $(bindir)/$$prog; \
30+ echo "installing $$prog in $(DESTDIR)$(bindir)"; \
31+ $(INSTALL_PROGRAM) $$prog $(DESTDIR)$(bindir)/$$prog; \
32 done
33 @for manp in $(MANPAGES5); do \
34- echo "installing $$manp$(man5ext) in $(man5dir)"; \
35+ echo "installing $$manp$(man5ext) in $(DESTDIR)$(man5dir)"; \
36 $(INSTALL_DATA) $(srcdir)/$$manp.man \
37- $(man5dir)/$$manp$(man5ext); \
38+ $(DESTDIR)$(man5dir)/$$manp$(man5ext); \
39 done
40 @for manp in $(MANPAGES8p); do \
41- echo "installing $$manp$(man8ext) in $(man8dir)"; \
42+ echo "installing $$manp$(man8ext) in $(DESTDIR)$(man8dir)"; \
43 $(INSTALL_DATA) $(srcdir)/$$manp.man \
44- $(man8dir)/$$manp$(man8ext); \
45+ $(DESTDIR)$(man8dir)/$$manp$(man8ext); \
46 if [ 'x$(rpcprefix)' != 'x' ]; then \
47 rm -f $(man8dir)/$(rpcprefix)$$manp$(man8ext); \
48 ln -s $$manp$(man8ext) \
49- $(man8dir)/$(rpcprefix)$$manp$(man8ext); \
50+ $(DESTDIR)$(man8dir)/$(rpcprefix)$$manp$(man8ext); \
51 fi; \
52 done
53 @for manp in $(MANPAGES8); do \
54- echo "installing $$manp$(man8ext) in $(man8dir)"; \
55+ echo "installing $$manp$(man8ext) in $(DESTDIR)$(man8dir)"; \
56 $(INSTALL_DATA) $(srcdir)/$$manp.man \
57- $(man8dir)/$$manp$(man8ext); \
58+ $(DESTDIR)$(man8dir)/$$manp$(man8ext); \
59 done
60 @if [ -n "$(DEVTAB_FILE)" -a ! -f "$(DEVTAB_FILE)" ]; then \
61 echo "Initializing $(DEVTAB_FILE)"; \
62- $(INSTALL) -m 755 -d `dirname $(DEVTAB_FILE)`; \
63- echo "# Device mapping for unfsd" > "$(DEVTAB_FILE)"; \
64+ $(INSTALL) -m 755 -d `dirname $(DESTDIR)$(DEVTAB_FILE)`; \
65+ echo "# Device mapping for unfsd" > $(DESTDIR)"$(DEVTAB_FILE)"; \
66 fi
67
68 installdirs:
69- ${srcdir}/mkinstalldirs $(bindir) $(man5dir) $(man8dir)
70+ ${srcdir}/mkinstalldirs $(DESTDIR)$(bindir) $(DESTDIR)$(man5dir) $(DESTDIR)$(man8dir)
71
72 $(rpcprefix)mountd: $(MOUNTD_OBJS) libnfs.a
73 $(CC) $(LDFLAGS) -o $@ $(MOUNTD_OBJS) $(LIBS)
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/003-manpages.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/003-manpages.patch
deleted file mode 100644
index 412dbf6cb1..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/003-manpages.patch
+++ /dev/null
@@ -1,33 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/exports.man 2002/11/07 17:15:59 1.1
9+++ nfs-server/exports.man 2002/11/07 17:17:19
10@@ -110,6 +110,14 @@
11 .TP
12 .IR link_absolute
13 Leave all symbolic link as they are. This is the default operation.
14+.SS Anonymous Entries
15+.PP
16+Entries where hosts are not specified are known as anonymous entries. They
17+have different default settings compared to normal entries. The differences
18+include
19+.IR all_squash ,
20+.IR no_secure ", and"
21+.IR ro .
22 .SS User ID Mapping
23 .PP
24 .I nfsd
25@@ -231,7 +239,7 @@
26 # Mapping for client foobar:
27 # remote local
28 uid 0-99 - # squash these
29-uid 100-500 1000 # map 100-500 to 1000-1500
30+uid 100-500 1000 # map 100-500 to 1000-1400
31 gid 0-49 - # squash these
32 gid 50-100 700 # map 50-100 to 700-750
33 .fi
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/004-strsignal.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/004-strsignal.patch
deleted file mode 100644
index 6982b47209..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/004-strsignal.patch
+++ /dev/null
@@ -1,53 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/failsafe.c 2002/11/07 17:12:46 1.1
9+++ nfs-server/failsafe.c 2002/11/07 17:15:16
10@@ -10,8 +10,12 @@
11 #include "logging.h"
12 #include "signals.h"
13 #include <sys/wait.h>
14+#ifdef HAVE_STRSIGNAL
15+#include <string.h>
16+#else
17
18 static const char * get_signame(int signo);
19+#endif
20
21 void
22 failsafe(int level, int ncopies)
23@@ -111,9 +115,17 @@
24 pid, running? "Continue" : "Exit");
25 } else {
26 Dprintf(L_WARNING, "failsafe: "
27+#ifdef HAVE_STRSIGNAL
28+ "child %d terminated by: %s. "
29+#else
30 "child %d terminated by %s. "
31+#endif
32 "Restarting.",
33+#ifdef HAVE_STRSIGNAL
34+ pid, strsignal(signo));
35+#else
36 pid, get_signame(signo));
37+#endif
38 child = -1; /* Restart */
39 }
40 } else if (WIFEXITED(status)) {
41@@ -159,6 +171,7 @@
42 /* NOP */
43 }
44
45+#ifndef HAVE_STRSIGNAL
46 static const char *
47 get_signame(int signo)
48 {
49@@ -199,3 +212,4 @@
50 sprintf(namebuf, "signal #%d", signo);
51 return namebuf;
52 }
53+#endif
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/005-sys-time.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/005-sys-time.patch
deleted file mode 100644
index 17208d8e74..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/005-sys-time.patch
+++ /dev/null
@@ -1,34 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/system.h 2002/11/07 17:10:47 1.1
9+++ nfs-server/system.h 2002/11/07 17:11:53
10@@ -66,20 +66,16 @@
11 # include <grp.h> /* for setgroups */
12 #endif
13
14-#ifdef TIME_WITH_SYS_TIME
15+#ifdef HAVE_SYS_TIME_H
16 # include <sys/time.h>
17 # include <time.h>
18-#else /* not TIME_WITH_SYS_TIME */
19-# ifdef HAVE_SYS_TIME_H
20-# include <sys/time.h>
21-# else /* not HAVE_SYS_TIME_H */
22-# include <time.h>
23+#else /* not HAVE_SYS_TIME_H */
24+# include <time.h>
25 struct timeval {
26 long tv_sec;
27 long tv_usec;
28 };
29-# endif /* not HAVE_SYS_TIME_H */
30-#endif /* not TIME_WITH_SYS_TIME */
31+#endif /* not HAVE_SYS_TIME_H */
32 #ifdef HAVE_SYS_FILE_H
33 # include <sys/file.h>
34 #endif
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/006-reiserfs.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/006-reiserfs.patch
deleted file mode 100644
index 22dcc42b69..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/006-reiserfs.patch
+++ /dev/null
@@ -1,1277 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/Makefile.in
9+++ nfs-server/Makefile.in 2002/11/08 13:59:16
10@@ -100,7 +100,7 @@
11 utimes.c mkdir.c rename.c getopt.c getopt_long.c \
12 alloca.c mountlist.c xmalloc.c \
13 xstrdup.c strdup.c strstr.c nfsmounted.c faccess.c \
14- haccess.c daemon.c signals.c
15+ haccess.c daemon.c signals.c teahash3.c
16 XDRFILES = mount.x nfs_prot.x
17 GENFILES = mount.h mount_xdr.c mount_svc.c nfs_prot.h nfs_prot_xdr.c \
18 ugid.h ugid_xdr.c ugid_clnt.c
19@@ -112,7 +112,7 @@
20 MANPAGES8 = showmount
21 MANPAGES = $(MANPAGES5) $(MANPAGES8p) $(MANPAGES8)
22 LIBOBJS = version.o fsusage.o mountlist.o xmalloc.o xstrdup.o \
23- nfsmounted.o faccess.o haccess.o daemon.o \
24+ nfsmounted.o faccess.o haccess.o daemon.o teahash3.o \
25 signals.o @LIBOBJS@ @ALLOCA@
26 OBJS = logging.o fh.o devtab.o auth_init.o auth_clnt.o auth.o
27 NFSD_OBJS = nfsd.o rpcmisc.o nfs_dispatch.o getattr.o setattr.o \
28--- nfs-server/auth.c
29+++ nfs-server/auth.c 2002/11/08 13:59:16
30@@ -83,6 +83,7 @@
31 0, /* read-only */
32 0, /* relative links */
33 0, /* noaccess */
34+ 0, /* hashed inodes */
35 1, /* cross_mounts */
36 1, /* allow setuid */
37 65534, /* default uid */
38@@ -100,6 +101,7 @@
39 0, /* relative links */
40 0, /* noaccess */
41 1, /* cross_mounts */
42+ 0, /* hashed inodes */
43 0, /* allow setuid */
44 65534, /* default uid */
45 65534, /* default gid */
46@@ -991,6 +993,7 @@
47 if (mp == 0) {
48 mp = (nfs_mount*) xmalloc(sizeof(nfs_mount));
49 memset(mp, 0, sizeof(*mp));
50+ mp->mount_dev = 0;
51 mp->origin = cp;
52 mp->client = cp;
53 mp->path = xstrdup(path);
54@@ -1169,6 +1172,8 @@
55 default_options.nobody_gid = anon_gid;
56 anonymous_options.nobody_uid = anon_uid;
57 anonymous_options.nobody_gid = anon_gid;
58+ default_options.cross_mounts = cross_mounts;
59+ default_options.hashed_inodes = hashed_inodes;
60
61 memset(cached_clients, 0, sizeof(cached_clients));
62 cached_next = 0;
63--- nfs-server/auth.h
64+++ nfs-server/auth.h 2002/11/08 13:59:16
65@@ -43,15 +43,16 @@
66
67 typedef struct nfs_options {
68 ugid_mapping_t uidmap; /* uid/gid mapping behavior */
69- int root_squash;
70- int all_squash;
71- int some_squash; /* speed up luid() etc. */
72- int secure_port;
73- int read_only;
74- int link_relative;
75- int noaccess;
76- int cross_mounts;
77- int allow_setuid;
78+ unsigned root_squash : 1;
79+ unsigned all_squash : 1;
80+ unsigned some_squash : 1; /* speed up luid() etc. */
81+ unsigned secure_port : 1;
82+ unsigned read_only : 1;
83+ unsigned link_relative : 1;
84+ unsigned noaccess : 1;
85+ unsigned cross_mounts : 1;
86+ unsigned hashed_inodes : 1;
87+ unsigned allow_setuid : 1;
88 uid_t nobody_uid;
89 gid_t nobody_gid;
90 char * clnt_nisdomain;
91@@ -64,6 +65,7 @@
92 int length;
93 char * path;
94 nfs_options o;
95+ dev_t mount_dev;
96 /* Original NFS client */
97 struct nfs_client * origin;
98 } nfs_mount;
99@@ -121,6 +123,8 @@
100 extern void auth_check_all_netmasks(void);
101 extern void auth_sort_all_mountlists(void);
102 extern void auth_log_all(void);
103+extern int auth_checkdev(nfs_mount *, dev_t dev);
104+extern int auth_checkpathdev(char *, dev_t dev);
105
106 /* This function lets us set our euid/fsuid temporarily */
107 extern void auth_override_uid(uid_t);
108--- nfs-server/auth_clnt.c
109+++ nfs-server/auth_clnt.c 2002/11/08 13:59:16
110@@ -89,6 +89,13 @@
111 return NULL;
112 }
113
114+ if (!mp->o.cross_mounts && !mp->mount_dev) {
115+ struct stat st;
116+ if (!lstat(mp->path, &st) < 0)
117+ return NULL;
118+ mp->mount_dev = st.st_dev;
119+ }
120+
121 /* Check request originated on a privileged port. */
122 if (!allow_non_root && mp->o.secure_port
123 && !SECURE_PORT(svc_getcaller(rqstp->rq_xprt)->sin_port)) {
124@@ -350,3 +357,28 @@
125 return 1;
126 }
127 #endif
128+
129+int auth_checkpathdev(char *path, dev_t dev)
130+{
131+ nfs_mount *mp = auth_match_mount(nfsclient, path);
132+ if (!mp)
133+ return 0;
134+ return auth_checkdev(mp, dev);
135+}
136+
137+int auth_checkdev(nfs_mount *mp, dev_t dev)
138+{
139+ if (!mp->mount_dev)
140+ return 1;
141+ if (mp->mount_dev != dev) {
142+ struct stat st;
143+ /* Restat in case the cd switched */
144+ if (efs_lstat(mp->path, &st) < 0) {
145+ Dprintf(L_ERROR, "Unable to stat mount point %s\n", mp->path);
146+ return 0;
147+ }
148+ mp->mount_dev = st.st_dev;
149+ }
150+ return mp->mount_dev == dev;
151+}
152+
153--- nfs-server/auth_init.c
154+++ nfs-server/auth_init.c 2002/11/08 13:59:16
155@@ -320,6 +320,14 @@
156 /* knfsd compatibility, ignore */;
157 else ifkwd(4, "sync")
158 /* knfsd compatibility, ignore */;
159+ else ifkwd(13, "hashed_inodes")
160+ mp->o.hashed_inodes = 1;
161+ else ifkwd(16, "no_hashed_inodes")
162+ mp->o.hashed_inodes = 0;
163+ else ifkwd(12, "cross_mounts")
164+ mp->o.cross_mounts = 1;
165+ else ifkwd(15, "no_cross_mounts")
166+ mp->o.cross_mounts = 0;
167 else {
168 Dprintf(L_ERROR,
169 "Unknown keyword \"%.*s\" in export file\n",
170--- nfs-server/exports.man
171+++ nfs-server/exports.man 2002/11/08 13:59:16
172@@ -208,6 +208,17 @@
173 .IR no_all_squash ,
174 which is the default setting.
175 .TP
176+.IR hashed_inodes
177+Use a special scheme to generate inode numbers that may work better with
178+reiserfs filesystems.
179+.IR no_hashed_inodes
180+which uses a direct mapping is the default.
181+.TP
182+.IR cross_mounts
183+Do not cross mount points in exports. Turning this off with
184+.IR no_cross_mounts
185+avoids inode number space conflicts when there are too many files.
186+.TP
187 .IR map_daemon
188 This option turns on dynamic uid/gid mapping. Each uid in an NFS request
189 will be translated to the equivalent server uid, and each uid in an
190--- nfs-server/fh.c
191+++ nfs-server/fh.c 2002/11/08 14:11:31
192@@ -4,8 +4,9 @@
193 *
194 * Interfaces:
195 * pseudo_inode
196- * mostly used internally, but also called from unfsd.c
197- * when reporting directory contents.
198+ * mostly used internally, for hash tables
199+ * visible_inode
200+ * generate visible inode shown to the client in the fattr.
201 * fh_init
202 * Initializes the queues and 'flush' timer
203 * fh_pr
204@@ -47,6 +48,8 @@
205 * Note: the original code mistakenly assumes that the overall path
206 * length remains within the value given by PATH_MAX... that leads
207 * to interesting buffer overflows all over the place.
208+ *
209+ * Depends that dev_t only uses 16bits.
210 */
211
212 #include <assert.h>
213@@ -137,9 +140,9 @@
214 };
215
216 /* Forward declared local functions */
217-static psi_t path_psi(char *, nfsstat *, struct stat *, int);
218+static psi_t path_psi(char *, nfsstat *, struct stat *, int, int *);
219 static psi_t path_psi_m(char *, nfsstat *, struct stat *,
220- struct stat *, int);
221+ struct stat *, int, int *);
222 static int fh_flush_fds(void);
223 static char * fh_dump(svc_fh *);
224 static void fh_insert_fdcache(fhcache *fhc);
225@@ -173,19 +176,22 @@
226 fh_list_size++;
227
228 /* Insert into hash tab. */
229- hash_slot = &(fh_hashed[fhc->h.psi % HASH_TAB_SIZE]);
230+ hash_slot = &(fh_hashed[pseudo_inode(fhc->h.ino,fhc->h.dev) % HASH_TAB_SIZE]);
231 fhc->hash_next = *hash_slot;
232 *hash_slot = fhc;
233 }
234
235 static fhcache *
236-fh_lookup(psi_t psi)
237+fh_lookup(ino_t ino, dev_t dev)
238 {
239 register fhcache *fhc;
240
241- fhc = fh_hashed[psi % HASH_TAB_SIZE];
242- while (fhc != NULL && fhc->h.psi != psi)
243+ fhc = fh_hashed[pseudo_inode(ino,dev) % HASH_TAB_SIZE];
244+ while (fhc != NULL) {
245+ if (fhc->h.ino == ino && fhc->h.dev == dev)
246+ break;
247 fhc = fhc->hash_next;
248+ }
249 return (fhc);
250 }
251
252@@ -193,7 +199,8 @@
253 fh_insert_fdcache(fhcache *fhc)
254 {
255 #ifdef FHTRACE
256- Dprintf(D_FHTRACE, "insert fh %x into fdcache @%d\n", fhc->h.psi, fhc->fd);
257+ Dprintf(D_FHTRACE, "insert fh %x,%x into fdcache @%d\n",
258+ fhc->h.ino, fhc->h.dev, fhc->fd);
259 if (fhc->fd < 0) {
260 fh_complain("fd cache bug: bad fd", fhc);
261 return;
262@@ -289,8 +296,9 @@
263 #endif
264
265 Dprintf(D_FHTRACE|D_FHCACHE,
266- "fh_delete: deleting handle %x ('%s', fd=%d)\n",
267- fhc, fhc->path ? fhc->path : "<unnamed>", fhc->fd);
268+ "fh_delete: deleting handle %x [%x,%x] ('%s', fd=%d)\n",
269+ fhc, fhc->h.dev, fhc->h.ino, fhc->path ? fhc->path : "<unnamed>",
270+ fhc->fd);
271
272 /* Remove from current posn */
273 fhc->prev->next = fhc->next;
274@@ -298,7 +306,7 @@
275 fh_list_size--;
276
277 /* Remove from hash tab */
278- hash_slot = &(fh_hashed[fhc->h.psi % HASH_TAB_SIZE]);
279+ hash_slot = &(fh_hashed[pseudo_inode(fhc->h.ino,fhc->h.dev) % HASH_TAB_SIZE]);
280 while (*hash_slot != NULL && *hash_slot != fhc)
281 hash_slot = &((*hash_slot)->hash_next);
282 if (*hash_slot == NULL)
283@@ -528,6 +536,7 @@
284 index -= 8;
285 }
286
287+#if 0
288 /* If we have an XXL inode number, spew out warning (but at most
289 * once a second) */
290 if (inode & ~mask) {
291@@ -541,14 +550,34 @@
292 }
293 inode &= mask;
294 }
295-
296+#endif
297 return (psi_t) (prefix | inode);
298 #endif
299 }
300
301+/* Inode as handed out by attr calls. */
302+psi_t
303+visible_inode(ino_t ino, dev_t dev, nfs_mount *mount)
304+{
305+ if (!mount->o.cross_mounts)
306+ return ino;
307+
308+ if (mount->o.hashed_inodes) {
309+ extern __u32 teahash3(/*u32 k[2], *//*u8*/const char *msg, int len);
310+
311+ struct {
312+ ino_t ino;
313+ dev_t dev;
314+ } tup = { ino,dev };
315+ return teahash3((char *) &tup, sizeof tup);
316+ }
317+
318+ return pseudo_inode(ino, dev);
319+}
320+
321 #if 1
322 static char *
323-fh_buildpath(svc_fh *h)
324+fh_buildpath(svc_fh *h, dev_t basedev)
325 {
326 char pathbuf[PATH_MAX + NAME_MAX + 1], *path;
327 long cookie_stack[HP_LEN + 1];
328@@ -565,13 +594,17 @@
329
330 if (efs_stat("/", &sbuf) < 0)
331 return (NULL);
332- psi = pseudo_inode(sbuf.st_ino, sbuf.st_dev);
333 if (h->hash_path[0] == 0) {
334- if (psi != h->psi)
335- return (NULL);
336- return xstrdup("/");
337+ if (sbuf.st_ino == h->ino && sbuf.st_dev == h->dev)
338+ ;
339+ else
340+ return NULL;
341+ strcpy(pathbuf,"/");
342+ path = xstrdup(pathbuf);
343+ return (path);
344 }
345
346+ psi = pseudo_inode(sbuf.st_ino, sbuf.st_dev);
347 if (hash_psi(psi) != h->hash_path[1])
348 return (NULL);
349
350@@ -599,11 +632,18 @@
351
352 psi = pseudo_inode(dp->d_ino, sbuf.st_dev);
353 if (i == h->hash_path[0] + 1) {
354- if (psi != h->psi)
355+ if (sbuf.st_dev != h->dev || dp->d_ino != h->ino)
356 continue;
357 /* GOT IT */
358 strcpy(pathbuf + pathlen, dp->d_name);
359- path = xstrdup(pathbuf);
360+ if (!basedev || sbuf.st_dev == basedev ||
361+ auth_checkpathdev(pathbuf, sbuf.st_dev)) {
362+ path = xstrdup(pathbuf);
363+ } else {
364+ dprintf(L_ERROR, "fh_buildpath: basedev %x != dev %x for %s\n",
365+ (unsigned)basedev,(unsigned)sbuf.st_dev,pathbuf);
366+ path = NULL;
367+ }
368 efs_closedir(dir);
369 auth_override_uid(auth_uid);
370 return (path);
371@@ -754,16 +794,16 @@
372 #endif
373
374 static psi_t
375-path_psi(char *path, nfsstat *status, struct stat *sbp, int svalid)
376+path_psi(char *path, nfsstat *status, struct stat *sbp, int svalid, int *mp)
377 {
378 struct stat smounted;
379
380- return path_psi_m(path, status, sbp, &smounted, svalid);
381+ return path_psi_m(path, status, sbp, &smounted, svalid, mp);
382 }
383
384 static psi_t
385 path_psi_m(char *path, nfsstat *status,
386- struct stat *sbp, struct stat *mbp, int svalid)
387+ struct stat *sbp, struct stat *mbp, int svalid, int *mp)
388 {
389 struct stat sbuf, ddbuf;
390
391@@ -815,6 +855,8 @@
392 DIR *dirp;
393 struct dirent *dp;
394
395+ if (mp) *mp = 1;
396+
397 errno = 0;
398 dirp = efs_opendir(dname);
399 fname[-1] = '/'; /* Restore path */
400@@ -860,9 +902,70 @@
401 }
402
403 fhcache *
404-fh_find(svc_fh *h, int mode)
405+fh_newfh(svc_fh *h, int mode, dev_t basedev)
406+{
407+ fhcache *fhc, *flush;
408+
409+ ex_state = active;
410+ for (flush = fh_tail.prev; fh_list_size > FH_CACHE_LIMIT; flush = fhc) {
411+ /* Don't flush current head. */
412+ if (flush == &fh_head)
413+ break;
414+ fhc = flush->prev;
415+ fh_delete(flush);
416+ }
417+ fhc = (fhcache *) xmalloc(sizeof *fhc);
418+ if (mode == FHFIND_FCREATE) {
419+ /* File will be created */
420+ fhc->path = NULL;
421+ } else {
422+ /* File must exist. Attempt to construct from hash_path */
423+ char *path;
424+
425+ if ((path = fh_buildpath(h, basedev)) == NULL) {
426+#ifdef FHTRACE
427+ Dprintf(D_FHTRACE, "fh_find: stale fh (hash path)\n");
428+ Dprintf(D_FHTRACE, "\tdata: %s\n", fh_dump(h));
429+#endif
430+ free(fhc);
431+ ex_state = inactive;
432+ return NULL;
433+ }
434+ fhc->path = path;
435+ }
436+ fhc->flags = 0;
437+ if (fhc->path && efs_lstat(fhc->path, &fhc->attrs) >= 0) {
438+ if (re_export && nfsmounted(fhc->path, &fhc->attrs))
439+ fhc->flags |= FHC_NFSMOUNTED;
440+ fhc->flags |= FHC_ATTRVALID;
441+ }
442+ fhc->fd = -1;
443+ fhc->last_used = curtime;
444+ fhc->h = *h;
445+ fhc->last_clnt = NULL;
446+ fhc->last_mount = NULL;
447+ fhc->last_uid = (uid_t)-1;
448+ fhc->fd_next = fhc->fd_prev = NULL;
449+ fh_inserthead(fhc);
450+ Dprintf(D_FHCACHE,
451+ "fh_find: created new handle %x (path `%s' ino:%x dev:%x)\n",
452+ fhc, fhc->path ? fhc->path : "<unnamed>", fhc->h.ino, fhc->h.dev);
453+ ex_state = inactive;
454+ if (fh_list_size > FH_CACHE_LIMIT)
455+ flush_cache(0);
456+#ifdef FHTRACE
457+ if (fhc->h.hash_path[0] == 0xFF) {
458+ Dprintf(L_ERROR, "newly created fh instantly flushed?!");
459+ return NULL;
460+ }
461+#endif
462+ return (fhc);
463+}
464+
465+fhcache *
466+fh_find(svc_fh *h, int mode, dev_t basedev)
467 {
468- register fhcache *fhc, *flush;
469+ register fhcache *fhc;
470 int check;
471
472 check = (mode & FHFIND_CHECK);
473@@ -877,12 +980,12 @@
474
475 ex_state = active;
476 time(&curtime);
477- while ((fhc = fh_lookup(h->psi)) != NULL) {
478+ while ((fhc = fh_lookup(h->ino,h->dev)) != NULL) {
479 struct stat sbuf, *s = NULL;
480 nfsstat dummy;
481
482- Dprintf(D_FHCACHE, "fh_find: psi=%lx... found '%s', fd=%d\n",
483- (unsigned long) h->psi,
484+ Dprintf(D_FHCACHE, "fh_find: (%u,%u)... found '%s', fd=%d\n",
485+ h->ino, h->dev,
486 fhc->path ? fhc->path : "<unnamed>",
487 fhc->fd);
488
489@@ -905,6 +1008,7 @@
490 Dprintf(D_FHTRACE,
491 "fh_find: stale fh: lstat: %m\n");
492 } else {
493+ int mp = 0;
494 /* If device/ino don't match, fhc->path may
495 * be a mount point (hence lstat() returns
496 * a different inode number than the readdir()
497@@ -915,19 +1019,26 @@
498
499 /* Get the dev/ino of the underlying
500 * mount point. */
501- path_psi(fhc->path, &dummy, s, 1);
502- if (fh_attrmatch(fhc, s))
503- goto fh_return;
504+ if (path_psi(fhc->path, &dummy, s, 1, &mp) &&
505+ fh_attrmatch(fhc, s)) {
506+ if (!mp)
507+ Dprintf(D_FHTRACE,"fh_find: should be mount point %x,%x\n",
508+ h->dev,h->ino);
509+
510+ }
511
512- Dprintf(D_FHTRACE, "fh_find: stale fh: %lx",
513- (unsigned long) h->psi);
514+ Dprintf(D_FHTRACE, "fh_find: stale fh: "
515+ "dev/ino %x/%lx ino:%x dev:%x",
516+ s->st_dev, s->st_ino,
517+ (unsigned)h->ino, (unsigned)h->dev);
518 }
519
520 fh_discard:
521 #ifdef FHTRACE
522 Dprintf(D_FHTRACE, "\tdata: %s\n", fh_dump(h));
523 #endif
524- Dprintf(D_FHCACHE, "fh_find: delete cached handle\n");
525+ Dprintf(D_FHCACHE, "fh_find: delete cached handle %x,%x <%x>\n",
526+ fhc->h.dev,fhc->h.ino,fhc->path ? fhc->path : "no path");
527 fh_delete(fhc);
528 break;
529 }
530@@ -947,88 +1058,13 @@
531 return (fhc);
532 }
533
534- Dprintf(D_FHCACHE, "fh_find: psi=%lx... not found\n",
535- (unsigned long) h->psi);
536-
537- if (mode == FHFIND_FCACHED) {
538- ex_state = inactive;
539- return NULL;
540- }
541-
542- for (flush = fh_tail.prev; fh_list_size > FH_CACHE_LIMIT; flush = fhc) {
543- /* Don't flush current head. */
544- if (flush == &fh_head)
545- break;
546- fhc = flush->prev;
547- fh_delete(flush);
548- }
549-
550- fhc = (fhcache *) xmalloc(sizeof *fhc);
551- if (mode == FHFIND_FCREATE) {
552- /* File will be created */
553- fhc->path = NULL;
554- } else {
555- /* File must exist. Attempt to construct from hash_path */
556- char *path;
557-
558- if ((path = fh_buildpath(h)) == NULL) {
559-#ifdef FHTRACE
560- Dprintf(D_FHTRACE, "fh_find: stale fh (hash path)\n");
561- Dprintf(D_FHTRACE, "\tdata: %s\n", fh_dump(h));
562-#endif
563- free(fhc);
564- ex_state = inactive;
565- return NULL;
566- }
567- fhc->path = path;
568- }
569-
570- fhc->flags = 0;
571- if (fhc->path && efs_lstat(fhc->path, &fhc->attrs) >= 0) {
572- if (nfsmounted(fhc->path, &fhc->attrs)) {
573- fhc->flags |= FHC_NFSMOUNTED;
574-#if 0
575- /* We must allow the client to send us the
576- * file handle for the NFS mount point itself,
577- * but not for entries within an NFS mount.
578- * XXX: needs fixing.
579- */
580- if (!re_export) {
581- Dprintf(D_FHTRACE,
582- "Attempt to use %s (non-exportable)\n",
583- fhc->path);
584- free(fhc);
585- ex_state = inactive;
586- return NULL;
587- }
588-#endif
589- }
590- fhc->flags |= FHC_ATTRVALID;
591- fhc->dev = fhc->attrs.st_dev;
592- fhc->ino = fhc->attrs.st_ino;
593- fhc->type = fhc->attrs.st_mode & S_IFMT;
594- }
595- fhc->fd = -1;
596- fhc->last_used = curtime;
597- fhc->h = *h;
598- fhc->last_clnt = NULL;
599- fhc->last_mount = NULL;
600- fhc->last_uid = (uid_t)-1;
601- fhc->fd_next = fhc->fd_prev = NULL;
602- fh_inserthead(fhc);
603- Dprintf(D_FHCACHE,
604- "fh_find: created new handle %x (path `%s' psi %08x)\n",
605- fhc, fhc->path ? fhc->path : "<unnamed>", fhc->h.psi);
606 ex_state = inactive;
607- if (fh_list_size > FH_CACHE_LIMIT)
608- flush_cache(0);
609-#ifdef FHTRACE
610- if (fhc->h.hash_path[0] == 0xFF) {
611- Dprintf(L_ERROR, "newly created fh instantly flushed?!");
612+
613+ Dprintf(D_FHCACHE, "fh_find: (%u,%u) ... not found\n",
614+ h->ino, h->dev);
615+ if (mode == FHFIND_FCACHED)
616 return NULL;
617- }
618-#endif
619- return (fhc);
620+ return fh_newfh(h, mode, basedev);
621 }
622
623 /*
624@@ -1040,7 +1076,7 @@
625 {
626 fhcache *h;
627
628- if ((h = fh_find((svc_fh *) fh, FHFIND_FCACHED)) == NULL)
629+ if ((h = fh_find((svc_fh *) fh, FHFIND_FCACHED, 0)) == NULL)
630 return fh_dump((svc_fh *) fh);
631 return (h->path);
632 }
633@@ -1050,10 +1086,10 @@
634 {
635 static char buf[65];
636 char *sp;
637- int i, n = fh->hash_path[0];
638+ int i, n = fh->hash_path[0], l;
639
640- sprintf(buf, "%08x %02x ", fh->psi, fh->hash_path[0]);
641- for (i = 1, sp = buf + 12; i <= n && i < HP_LEN; i++, sp += 2)
642+ l = sprintf(buf, "%08x %04x %02x ", fh->ino, fh->dev, fh->hash_path[0]);
643+ for (i = 1, sp = buf + l; i <= n && i < HP_LEN; i++, sp += 2)
644 sprintf(sp, "%02x", fh->hash_path[i]);
645 return buf;
646 }
647@@ -1082,7 +1118,7 @@
648
649 memset(&key, 0, sizeof(key));
650 status = NFS_OK;
651- if ((psi = path_psi("/", &status, &stb, 0)) == 0)
652+ if ((psi = path_psi("/", &status, &stb, 0, NULL)) == 0)
653 return ((int) status);
654
655 s = path;
656@@ -1091,7 +1127,7 @@
657 return ((int) NFSERR_NAMETOOLONG);
658 key.hash_path[key.hash_path[0]] = hash_psi(psi);
659 *s = '\0';
660- if ((psi = path_psi(path, &status, &stb, 0)) == 0)
661+ if ((psi = path_psi(path, &status, &stb, 0, NULL)) == 0)
662 return ((int) status);
663 *s = '/';
664 }
665@@ -1099,11 +1135,12 @@
666 if (++(key.hash_path[0]) >= HP_LEN)
667 return ((int) NFSERR_NAMETOOLONG);
668 key.hash_path[key.hash_path[0]] = hash_psi(psi);
669- if ((psi = path_psi(path, &status, &stb, 0)) == 0)
670+ if ((psi = path_psi(path, &status, &stb, 0, NULL)) == 0)
671 return ((int) status);
672 }
673- key.psi = psi;
674- h = fh_find(&key, FHFIND_FCREATE);
675+ key.dev = stb.st_dev;
676+ key.ino = stb.st_ino;
677+ h = fh_find(&key, FHFIND_FCREATE, 0);
678
679 #ifdef FHTRACE
680 if (!h)
681@@ -1123,6 +1160,7 @@
682 return ((int) status);
683 }
684
685+#if 0
686 char *
687 fh_path(nfs_fh *fh, nfsstat *status)
688 {
689@@ -1135,6 +1173,7 @@
690 *status = NFS_OK;
691 return (h->path);
692 }
693+#endif
694
695 nfs_fh *
696 fh_handle(fhcache *h)
697@@ -1349,7 +1388,7 @@
698 if (sbp == NULL)
699 sbp = &sbuf;
700
701- if ((dirh = fh_find((svc_fh *) &dopa->dir, FHFIND_FEXISTS)) == NULL)
702+ if ((dirh = fh_find((svc_fh *) &dopa->dir, FHFIND_FEXISTS, 0)) == NULL)
703 return NFSERR_STALE;
704
705 /*
706@@ -1419,8 +1458,22 @@
707
708 *new_fh = dopa->dir;
709 key = (svc_fh *) new_fh;
710- if ((key->psi = path_psi_m(pathbuf, &ret, sbp, &smount, 0)) == 0)
711+
712+ if (path_psi_m(pathbuf, &ret, sbp, &smount, 0, NULL) == 0)
713 return (ret);
714+ key->ino = sbp->st_ino;
715+ key->dev = sbp->st_dev;
716+
717+ if (sbp->st_dev != dirh->h.dev) {
718+ nfs_mount *mp = dirh->last_mount;
719+ if (!mp)
720+ Dprintf(L_ERROR, "no last mount in fh_compose for %s\n", pathbuf);
721+ else if (auth_checkdev(mp, sbp->st_dev) == 0) {
722+ Dprintf(L_ERROR, "access to no cross path below mountpoint (<%s>, %x<->%x)\n",
723+ pathbuf, mp->mount_dev, sbp->st_dev);
724+ return NFSERR_STALE;
725+ }
726+ }
727
728 if (is_dd) {
729 /* Don't cd .. from root, or mysterious ailments will
730@@ -1430,11 +1483,12 @@
731 } else {
732 if (++(key->hash_path[0]) >= HP_LEN)
733 return NFSERR_NAMETOOLONG;
734- key->hash_path[key->hash_path[0]] = hash_psi(dirh->h.psi);
735+ key->hash_path[key->hash_path[0]] = hash_psi(pseudo_inode(dirh->h.ino,
736+ dirh->h.dev));
737 }
738 /* FIXME: when crossing a mount point, we'll find the real
739 * dev/ino in sbp and can store it in h... */
740- h = fh_find(key, FHFIND_FCREATE);
741+ h = fh_find(key, FHFIND_FCREATE, 0);
742
743 #ifdef FHTRACE
744 if (h == NULL)
745@@ -1456,7 +1510,7 @@
746 /* We must have cached an old file under the same inode # */
747 Dprintf(D_FHTRACE, "Disposing of fh with bad path.\n");
748 fh_delete(h);
749- h = fh_find(key, FHFIND_FCREATE);
750+ h = fh_find(key, FHFIND_FCREATE, dirh->last_mount ? dirh->last_mount->mount_dev : 0);
751 #ifdef FHTRACE
752 if (!h) return NFSERR_STALE;
753 #endif
754@@ -1511,12 +1565,14 @@
755 return (NFS_OK);
756 }
757
758+#if 0
759 psi_t
760 fh_psi(nfs_fh *fh)
761 {
762 svc_fh *h = (svc_fh *) fh;
763 return (h->psi);
764 }
765+#endif
766
767 void
768 fh_remove(char *path)
769@@ -1524,12 +1580,13 @@
770 psi_t psi;
771 nfsstat status;
772 fhcache *fhc;
773+ struct stat st;
774
775- psi = path_psi(path, &status, NULL, 0);
776+ psi = path_psi(path, &status, &st, 0, NULL);
777 if (psi == 0)
778 return;
779 ex_state = active;
780- fhc = fh_lookup(psi);
781+ fhc = fh_lookup(st.st_ino,st.st_dev);
782 if (fhc != NULL)
783 fh_delete(fhc);
784
785@@ -1634,6 +1691,11 @@
786 fh_init(void)
787 {
788 static int initialized = 0;
789+
790+ if (sizeof(svc_fh) > 32) {
791+ fprintf(stderr, "filehandle wrong size %d\n", sizeof(svc_fh));
792+ exit(10);
793+ }
794
795 if (initialized)
796 return;
797--- nfs-server/fh.h
798+++ nfs-server/fh.h 2002/11/08 13:59:16
799@@ -20,6 +20,7 @@
800 #define FHC_XONLY_PATH 001 /* NOT USED ANYMORE */
801 #define FHC_ATTRVALID 002
802 #define FHC_NFSMOUNTED 004
803+#define FHC_CROSS 010
804
805 /* Modes for fh_find */
806 #define FHFIND_FEXISTS 0 /* file must exist */
807@@ -65,11 +66,12 @@
808 *
809 * hash_path[hash_path[0]+1] ... hash_path[HP_LEN-1] == 0
810 */
811-#define HP_LEN (NFS_FHSIZE - sizeof(psi_t))
812+#define HP_LEN (NFS_FHSIZE-sizeof(u_int32_t)-sizeof(u_int16_t))
813 typedef struct {
814- psi_t psi;
815+ u_int32_t ino;
816+ u_int16_t dev;
817 __u8 hash_path[HP_LEN];
818-} svc_fh;
819+} svc_fh __attribute__((packed));
820
821 typedef enum { inactive, active } mutex;
822
823@@ -100,6 +102,7 @@
824
825 /* These are fixed during the lifetime of this object */
826 svc_fh h;
827+ psi_t psi;
828 dev_t dev;
829 ino_t ino;
830 mode_t type; /* st_mode & S_IFMT */
831@@ -122,10 +125,11 @@
832 /* Global function prototypes. */
833 extern nfsstat nfs_errno(void);
834 extern psi_t pseudo_inode(ino_t inode, dev_t dev);
835+extern psi_t visible_inode(ino_t inode, dev_t dev, nfs_mount *);
836 extern void fh_init(void);
837 extern char *fh_pr(nfs_fh *fh);
838 extern int fh_create(nfs_fh *fh, char *path);
839-extern fhcache *fh_find(svc_fh *h, int create);
840+extern fhcache *fh_find(svc_fh *h, int create, dev_t basedev);
841 extern char *fh_path(nfs_fh *fh, nfsstat *status);
842 extern int path_open(char *path, int omode, int perm);
843 extern int fh_fd(fhcache *fhc, nfsstat *status, int omode);
844@@ -139,6 +143,7 @@
845 extern void fh_flush(int force);
846 extern RETSIGTYPE flush_cache(int sig);
847 extern int nfsmounted(const char *path, struct stat *sbp);
848+extern fhcache *fh_newfh(svc_fh *fh, int mode, dev_t basedev);
849
850 #ifdef ENABLE_DEVTAB
851 extern unsigned int devtab_index(dev_t);
852--- nfs-server/getattr.c
853+++ nfs-server/getattr.c 2002/11/08 13:59:16
854@@ -43,7 +43,7 @@
855 {
856 fhcache *fhc;
857
858- if ((fhc = fh_find((svc_fh*)fh, FHFIND_FEXISTS)) == NULL) {
859+ if ((fhc = fh_find((svc_fh*)fh, FHFIND_FEXISTS, 0)) == NULL) {
860 Dprintf(D_CALL, "getattr: failed! No such file.\n");
861 return (NFSERR_STALE);
862 }
863@@ -103,18 +103,8 @@
864 #else
865 attr->blocks = st_blocks(s);
866 #endif
867-#if 0
868- if (nfsmount->o.cross_mounts) {
869- attr->fsid = 1;
870- attr->fileid = fh_psi((nfs_fh *)&(fhc->h));
871- } else {
872- attr->fsid = s->st_dev;
873- attr->fileid = covered_ino(fhc->path);
874- }
875-#else
876- attr->fsid = 1;
877- attr->fileid = fh_psi((nfs_fh *)&(fhc->h));
878-#endif
879+ attr->fsid = 1; // XXX
880+ attr->fileid = visible_inode(fhc->h.ino, fhc->h.dev, nfsmount);
881
882 /* This may be needed by some Suns... testing */
883 #define MINTIME (24 * 2600)
884--- nfs-server/mountd.c
885+++ nfs-server/mountd.c 2002/11/08 13:59:16
886@@ -36,6 +36,8 @@
887 #include "signals.h"
888 #include <rpc/pmap_clnt.h>
889
890+int cross_mounts = 1;
891+int hashed_inodes; /* dummy */
892
893 static void usage(FILE *, int);
894 static void terminate(void);
895@@ -58,9 +60,9 @@
896 { "no-spoof-trace", 0, 0, 't' },
897 { "version", 0, 0, 'v' },
898 { "fail-safe", optional_argument, 0, 'z' },
899+ { "no-cross-mounts", 0, 0, 'x' },
900 { "no-tcp", 0, 0, OPT_NOTCP },
901 { "loopback-only", 0, 0, OPT_LOOPBACK },
902-
903 { NULL, 0, 0, 0 }
904 };
905 static const char * shortopts = "Fd:f:hnpP:rtvz::";
906@@ -80,6 +82,7 @@
907 int need_reinit = 0;
908 int need_flush = 0;
909 extern char version[];
910+nfs_client *nfsclient; /* dummy */
911
912 /*
913 * NULL
914@@ -319,6 +322,9 @@
915 opterr = 0;
916 while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != EOF)
917 switch (c) {
918+ case 'x':
919+ cross_mounts = 0;
920+ break;
921 case 'F':
922 foreground = 1;
923 break;
924@@ -444,7 +450,7 @@
925 program_name);
926 fprintf(fp, " [--debug kind] [--help] [--allow-non-root]\n");
927 fprintf(fp, " [--promiscuous] [--version] [--port portnum]\n");
928- fprintf(fp, " [--exports-file=file]\n");
929+ fprintf(fp, " [--exports-file=file] [--no-cross-mounts]\n");
930 exit(n);
931 }
932
933--- nfs-server/nfsd.c
934+++ nfs-server/nfsd.c 2002/11/08 14:20:57
935@@ -72,7 +72,7 @@
936 { "no-tcp", 0, 0, OPT_NOTCP },
937 { "udp-only", 0, 0, OPT_NOTCP },
938 { "loopback-only", 0, 0, OPT_LOOPBACK },
939-
940+ { "hashed-inodes", 0, 0, 'I' },
941 { NULL, 0, 0, 0 }
942 };
943 static const char * shortopts = "a:d:Ff:hlnP:prR:tvz::";
944@@ -91,6 +91,7 @@
945 int need_flush = 0; /* flush fh cache */
946 int read_only = 0; /* Global ro forced */
947 int cross_mounts = 1; /* Transparently cross mnts */
948+int hashed_inodes = 0;
949 int log_transfers = 0; /* Log transfers */
950 static svc_fh public_fh; /* Public NFSv2 FH */
951
952@@ -122,12 +123,17 @@
953 {
954 static int total = 0, cached = 0;
955 fhcache *fhc;
956+ int newfh = 0;
957
958- /* Try to map FH. If not cached, reconstruct path with root priv */
959- fhc = fh_find((svc_fh *)fh, FHFIND_FEXISTS|FHFIND_CHECK);
960- if (fhc == NULL) {
961- *statp = NFSERR_STALE;
962- return NULL;
963+ /* Try to map FH. */
964+ fhc = fh_find((svc_fh *)fh, FHFIND_FCACHED|FHFIND_CHECK, 0);
965+ if (!fhc) {
966+ fhc = fh_newfh((svc_fh*)fh, FHFIND_FEXISTS|FHFIND_CHECK, 0);
967+ if (!fhc) {
968+ *statp = NFSERR_STALE;
969+ return NULL;
970+ }
971+ newfh = 1;
972 }
973
974 /* Try to retrieve last client who accessed this fh */
975@@ -163,6 +169,16 @@
976 100 * (double) cached / total);
977 */
978
979+ /* Trust the crossmount check of the parent directory for creates */
980+ if (newfh &&
981+ (fhc->flags & FHC_ATTRVALID) &&
982+ auth_checkdev(nfsmount, fhc->attrs.st_dev) == 0) {
983+ Dprintf(L_ERROR, "auth_fh: fh crossed mount %s: %x<->%x\n",
984+ fhc->path ? fhc->path : "???", nfsmount->mount_dev, fhc->attrs.st_dev);
985+ *statp = NFSERR_STALE; /* or ACCES? */
986+ return NULL;
987+ }
988+
989 if (nfsmount->o.noaccess &&
990 ((flags & CHK_NOACCESS) || strcmp(nfsmount->path, fhc->path))) {
991 struct in_addr addr = svc_getcaller(rqstp->rq_xprt)->sin_addr;
992@@ -195,6 +211,7 @@
993 fhcache *fhc;
994 nfsstat status;
995 char *path = buf, *sp;
996+ struct stat st;
997
998 /* Authenticate directory file handle */
999 if ((fhc = auth_fh(rqstp, &dopa->dir, &status, flags)) == NULL)
1000@@ -219,6 +236,9 @@
1001 if ((nfsmount = auth_path(nfsclient, rqstp, path)) == NULL)
1002 return NFSERR_ACCES;
1003
1004+ if (efs_lstat(path, &st) >= 0 && !auth_checkdev(nfsmount, st.st_dev))
1005+ return NFSERR_ACCES;
1006+
1007 /* XXX: really need to call it again here?
1008 * Already invoked in auth_fh */
1009 if (!auth_user(nfsmount, rqstp))
1010@@ -318,7 +338,8 @@
1011 int ispublic = 0;
1012
1013 /* First check whether this is the public FH */
1014- if (((svc_fh *) fh)->psi == 0 && !memcmp(fh, &public_fh, FHSIZE)) {
1015+ if (((svc_fh *) fh)->dev == 0 && ((svc_fh*)fh)->ino == 0 &&
1016+ !memcmp(fh, &public_fh, FHSIZE)) {
1017 if (public_root_path == NULL)
1018 return NFSERR_ACCES;
1019 memcpy(&argp->dir, &public_root, NFS_FHSIZE);
1020@@ -333,6 +354,7 @@
1021 if (!(fhc = auth_fh(rqstp, fh, &status, CHK_READ)))
1022 return status;
1023
1024+ /* FIXME: does too many stats */
1025 status = fh_compose(argp, &dp->file, &sbuf, -1, -1, ispublic);
1026 if (status != NFS_OK)
1027 return status;
1028@@ -896,6 +918,9 @@
1029 errno = 0;
1030 if (efs_lstat(h->path, &sbuf) < 0 || !(S_ISDIR(sbuf.st_mode)))
1031 return (NFSERR_NOTDIR);
1032+ if (!auth_checkdev(h->last_mount, sbuf.st_dev))
1033+ dotsonly = 1;
1034+
1035 if ((dirp = efs_opendir(h->path)) == NULL)
1036 return ((errno ? nfs_errno() : NFSERR_NAMETOOLONG));
1037
1038@@ -923,7 +948,7 @@
1039 }
1040
1041 e = *ep = (entry *) xmalloc(sizeof(entry));
1042- e->fileid = pseudo_inode(dp->d_ino, sbuf.st_dev);
1043+ e->fileid = visible_inode(dp->d_ino, sbuf.st_dev, h->last_mount);
1044 e->name = xmalloc(NLENGTH(dp) + 1);
1045 strcpy(e->name, dp->d_name);
1046 dloc = htonl(efs_telldir(dirp));
1047@@ -1033,6 +1058,9 @@
1048 case 'x':
1049 cross_mounts = 0;
1050 break;
1051+ case 'I':
1052+ hashed_inodes = 1;
1053+ break;
1054 case 'z':
1055 if (optarg)
1056 failsafe_level = atoi(optarg);
1057@@ -1189,7 +1217,7 @@
1058 " [--debug kind] [--exports-file=file] [--port port]\n"
1059 " [--allow-non-root] [--promiscuous] [--version] [--foreground]\n"
1060 " [--re-export] [--log-transfers] [--public-root path]\n"
1061-" [--no-spoof-trace] [--help]\n"
1062+" [--no-spoof-trace] [--no-cross-mounts] [--hashed-inodes] [--help]\n"
1063 , program_name);
1064 exit(n);
1065 }
1066--- nfs-server/nfsd.h
1067+++ nfs-server/nfsd.h 2002/11/08 13:59:16
1068@@ -51,6 +51,7 @@
1069 extern int need_reinit;
1070 extern int need_flush;
1071 extern time_t nfs_dispatch_time;
1072+extern int cross_mounts, hashed_inodes;
1073
1074 /* Include the other module definitions. */
1075 #include "auth.h"
1076--- nfs-server/setattr.c
1077+++ nfs-server/setattr.c 2002/11/08 13:59:16
1078@@ -17,6 +17,7 @@
1079
1080 #define IGNORE_TIME ((unsigned int) -1)
1081
1082+#if 0
1083 /*
1084 * Set file attributes based on file handle
1085 */
1086@@ -33,6 +34,7 @@
1087 }
1088 return setattr(path, attr, s, rqstp, flags);
1089 }
1090+#endif
1091
1092 /*
1093 * Set file attributes given the path. The flags argument
1094--- nfs-server/teahash3.c
1095+++ nfs-server/teahash3.c 2002/11/08 13:59:16
1096@@ -0,0 +1,168 @@
1097+/* Taken from the reiserfs source code and hacked slightly by AK.
1098+ * This is GPLed. */
1099+/*
1100+ * Keyed 32-bit hash function using TEA in a Davis-Meyer function
1101+ * H0 = Key
1102+ * Hi = E Mi(Hi-1) + Hi-1
1103+ *
1104+ * (see Applied Cryptography, 2nd edition, p448).
1105+ *
1106+ * Jeremy Fitzhardinge <jeremy@zip.com.au> 1998
1107+ *
1108+ * Jeremy has agreed to the contents of reiserfs/README. -Hans
1109+ */
1110+
1111+#include <assert.h>
1112+
1113+#if 0
1114+/* OK for Intel */
1115+typedef unsigned long u32;
1116+typedef const unsigned char u8;
1117+#else
1118+#include <inttypes.h>
1119+typedef uint32_t u32;
1120+typedef uint8_t u8;
1121+#endif
1122+
1123+
1124+#define DELTA 0x9E3779B9
1125+#define FULLROUNDS 10 /* 32 is overkill, 16 is strong crypto */
1126+#define PARTROUNDS 6 /* 6 gets complete mixing */
1127+
1128+/* a, b, c, d - data; h0, h1 - accumulated hash */
1129+#define TEACORE(rounds) \
1130+ do { \
1131+ u32 sum = 0; \
1132+ int n = rounds; \
1133+ u32 b0, b1; \
1134+ \
1135+ b0 = h0; \
1136+ b1 = h1; \
1137+ \
1138+ do \
1139+ { \
1140+ sum += DELTA; \
1141+ b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b); \
1142+ b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d); \
1143+ } while(--n); \
1144+ \
1145+ h0 += b0; \
1146+ h1 += b1; \
1147+ } while(0)
1148+
1149+u32 teahash3(/*u32 k[2], *//*u8*/const char *msg, int len)
1150+{
1151+ u32 k[] = { 0x9464a485, 0x542e1a94, 0x3e846bff, 0xb75bcfc3};
1152+
1153+ u32 h0 = k[0], h1 = k[1];
1154+ u32 a, b, c, d;
1155+ u32 pad;
1156+ int i;
1157+
1158+ assert(len >= 0 && len < 256);
1159+
1160+ pad = (u32)len | ((u32)len << 8);
1161+ pad |= pad << 16;
1162+
1163+ while(len >= 16)
1164+ {
1165+ a = (u32)msg[ 0] |
1166+ (u32)msg[ 1] << 8 |
1167+ (u32)msg[ 2] << 16|
1168+ (u32)msg[ 3] << 24;
1169+ b = (u32)msg[ 4] |
1170+ (u32)msg[ 5] << 8 |
1171+ (u32)msg[ 6] << 16|
1172+ (u32)msg[ 7] << 24;
1173+ c = (u32)msg[ 8] |
1174+ (u32)msg[ 9] << 8 |
1175+ (u32)msg[10] << 16|
1176+ (u32)msg[11] << 24;
1177+ d = (u32)msg[12] |
1178+ (u32)msg[13] << 8 |
1179+ (u32)msg[14] << 16|
1180+ (u32)msg[15] << 24;
1181+
1182+ TEACORE(PARTROUNDS);
1183+
1184+ len -= 16;
1185+ msg += 16;
1186+ }
1187+
1188+ if (len >= 12)
1189+ {
1190+ assert(len < 16);
1191+
1192+ a = (u32)msg[ 0] |
1193+ (u32)msg[ 1] << 8 |
1194+ (u32)msg[ 2] << 16|
1195+ (u32)msg[ 3] << 24;
1196+ b = (u32)msg[ 4] |
1197+ (u32)msg[ 5] << 8 |
1198+ (u32)msg[ 6] << 16|
1199+ (u32)msg[ 7] << 24;
1200+ c = (u32)msg[ 8] |
1201+ (u32)msg[ 9] << 8 |
1202+ (u32)msg[10] << 16|
1203+ (u32)msg[11] << 24;
1204+
1205+ d = pad;
1206+ for(i = 12; i < len; i++)
1207+ {
1208+ d <<= 8;
1209+ d |= msg[i];
1210+ }
1211+ }
1212+ else if (len >= 8)
1213+ {
1214+ assert(len < 12);
1215+
1216+ a = (u32)msg[ 0] |
1217+ (u32)msg[ 1] << 8 |
1218+ (u32)msg[ 2] << 16|
1219+ (u32)msg[ 3] << 24;
1220+ b = (u32)msg[ 4] |
1221+ (u32)msg[ 5] << 8 |
1222+ (u32)msg[ 6] << 16|
1223+ (u32)msg[ 7] << 24;
1224+
1225+ c = d = pad;
1226+ for(i = 8; i < len; i++)
1227+ {
1228+ c <<= 8;
1229+ c |= msg[i];
1230+ }
1231+ }
1232+ else if (len >= 4)
1233+ {
1234+ assert(len < 8);
1235+
1236+ a = (u32)msg[ 0] |
1237+ (u32)msg[ 1] << 8 |
1238+ (u32)msg[ 2] << 16|
1239+ (u32)msg[ 3] << 24;
1240+
1241+ b = c = d = pad;
1242+ for(i = 4; i < len; i++)
1243+ {
1244+ b <<= 8;
1245+ b |= msg[i];
1246+ }
1247+ }
1248+ else
1249+ {
1250+ assert(len < 4);
1251+
1252+ a = b = c = d = pad;
1253+ for(i = 0; i < len; i++)
1254+ {
1255+ a <<= 8;
1256+ a |= msg[i];
1257+ }
1258+ }
1259+
1260+ TEACORE(FULLROUNDS);
1261+
1262+/* return 0;*/
1263+ return h0^h1;
1264+}
1265--- nfs-server/ugid_map.c
1266+++ nfs-server/ugid_map.c 2002/11/08 13:59:16
1267@@ -276,8 +276,10 @@
1268 if ((gid == 0 && mountp->o.root_squash) || mountp->o.all_squash)
1269 retgid = mountp->o.nobody_gid;
1270
1271+#if 0
1272 Dprintf(D_UGID, "lgid(%s, %d) = %d\n",
1273 inet_ntoa(mountp->client->clnt_addr), gid, retgid);
1274+#endif
1275 return retgid;
1276 }
1277
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/007-map.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/007-map.patch
deleted file mode 100644
index e031fef2f8..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/007-map.patch
+++ /dev/null
@@ -1,83 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/auth.c
9+++ nfs-server/auth.c 2002/11/08 12:49:13
10@@ -595,7 +595,6 @@
11 cp->clnt_addr.s_addr = INADDR_ANY;
12 cp->flags = 0;
13 cp->m = NULL;
14- cp->umap = NULL;
15
16 if (hname == NULL) {
17 if (anonymous_client != NULL) {
18@@ -1200,10 +1199,9 @@
19 free (mp->path);
20 if (mp->o.clnt_nisdomain)
21 free(mp->o.clnt_nisdomain);
22+ if (mp->umap)
23+ ugid_free_map(mp->umap);
24 free (mp);
25- }
26- if (cp->umap != NULL) {
27- ugid_free_map(cp->umap);
28 }
29 free (cp);
30 }
31--- nfs-server/auth.h
32+++ nfs-server/auth.h 2002/11/08 12:50:24
33@@ -66,6 +66,11 @@
34 char * path;
35 nfs_options o;
36 dev_t mount_dev;
37+ /*
38+ * This is the uid/gid map.
39+ * See ugid_map.c for details
40+ */
41+ struct ugid_map * umap;
42 /* Original NFS client */
43 struct nfs_client * origin;
44 } nfs_mount;
45@@ -77,12 +82,6 @@
46 char * clnt_name;
47 unsigned short flags;
48 nfs_mount * m;
49-
50- /*
51- * This is the uid/gid map.
52- * See ugid_map.c for details
53- */
54- struct ugid_map * umap;
55 } nfs_client;
56
57 #define AUTH_CLNT_WILDCARD 0x0001
58--- nfs-server/ugid_map.c
59+++ nfs-server/ugid_map.c 2002/11/08 12:49:14
60@@ -401,12 +401,11 @@
61 static ugid_map *
62 ugid_get_map(nfs_mount *mountp)
63 {
64- nfs_client *clientp = mountp->client;
65 struct ugid_map *umap;
66 unsigned int how;
67
68- if (clientp->umap == NULL) {
69- clientp->umap = umap = (ugid_map *) xmalloc(sizeof(ugid_map));
70+ if (mountp->umap == NULL) {
71+ mountp->umap = umap = (ugid_map *) xmalloc(sizeof(ugid_map));
72 memset(umap, 0, sizeof(ugid_map));
73
74 for (how = 0; how < 4; how++) {
75@@ -415,7 +414,7 @@
76 }
77 }
78
79- return clientp->umap;
80+ return mountp->umap;
81 }
82
83 static void
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/008-configure.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/008-configure.patch
deleted file mode 100644
index 98405ea45f..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/008-configure.patch
+++ /dev/null
@@ -1,18 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/configure.in 2002/11/08 14:24:55 1.1
9+++ nfs-server/configure.in 2002/11/08 14:25:27
10@@ -98,7 +98,7 @@
11 fi
12 if test "$enable_ugid_dynamic" = yes; then
13 AC_DEFINE(ENABLE_UGID_DAEMON)
14- UGIDD_PROG=\${rpcprefix}.ugidd
15+ UGIDD_PROG=\${rpcprefix}ugidd
16 UGIDD_MAN=ugidd
17 fi
18 if test "$enable_ugid_nis" = yes; then
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/009-multirw.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/009-multirw.patch
deleted file mode 100644
index a4cf1f59c2..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/009-multirw.patch
+++ /dev/null
@@ -1,20 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/nfsd.c
9+++ nfs-server/nfsd.c
10@@ -1133,8 +1133,8 @@
11 }
12 }
13
14- if (ncopies > 1)
15- read_only = 1;
16+ /* if (ncopies > 1)
17+ read_only = 1; */
18
19 /*
20 * We first fork off a child and detach from tty
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/010-realpath.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/010-realpath.patch
deleted file mode 100644
index 2e53b37e46..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/010-realpath.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/configure.in
9+++ nfs-server/configure.in
10@@ -81,7 +81,7 @@
11 AC_CHECK_LIB(rpc, main)
12 AC_CHECK_LIB(crypt, main)
13 AC_CHECK_LIB(nys, main)
14-AC_HAVE_FUNCS(getcwd seteuid setreuid getdtablesize setgroups lchown setsid setfsuid setfsgid innetgr quotactl authdes_getucred)
15+AC_HAVE_FUNCS(getcwd seteuid setreuid getdtablesize setgroups lchown setsid setfsuid setfsgid innetgr quotactl authdes_getucred realpath)
16 AC_AUTHDES_GETUCRED
17 AC_BROKEN_SETFSUID
18 AC_MOUNTLIST
19--- nfs-server/realpath.c
20+++ nfs-server/realpath.c
21@@ -53,6 +53,8 @@
22
23 #define MAX_READLINKS 32
24
25+#ifndef HAVE_REALPATH
26+
27 #ifdef __STDC__
28 char *realpath(const char *path, char resolved_path [])
29 #else
30@@ -173,3 +175,5 @@
31 strcpy (resolved_path, got_path);
32 return resolved_path;
33 }
34+
35+#endif /* HAVE_REALPATH */
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/011-fno-strict-aliasing.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/011-fno-strict-aliasing.patch
deleted file mode 100644
index 1d0535b58c..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/011-fno-strict-aliasing.patch
+++ /dev/null
@@ -1,18 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/Makefile.in
9+++ nfs-server/Makefile.in
10@@ -225,7 +225,7 @@
11 $(RPCGEN) -l -o $@ $?
12
13 nfs_prot_xdr.o: nfs_prot_xdr.c
14- $(COMPILE) $(RPC_WARNFLAGS) -c nfs_prot_xdr.c
15+ $(COMPILE) $(RPC_WARNFLAGS) -fno-strict-aliasing -c nfs_prot_xdr.c
16 mount_xdr.o: mount_xdr.c
17 $(COMPILE) $(RPC_WARNFLAGS) -c mount_xdr.c
18 mount_svc.o: mount_svc.c
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/012-nostrip.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/012-nostrip.patch
deleted file mode 100644
index d04e0d15cb..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/012-nostrip.patch
+++ /dev/null
@@ -1,18 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/Makefile.in.xx 2006-01-12 12:43:09.000000000 +0100
9+++ nfs-server/Makefile.in 2006-01-12 12:43:10.000000000 +0100
10@@ -64,7 +64,7 @@
11 NFSD_DEFS =
12
13 CFLAGS = @CFLAGS@
14-LDFLAGS = @LDFLAGS@ -s
15+LDFLAGS = @LDFLAGS@
16 WARNFLAGS = @WARNFLAGS@
17 RPC_WARNFLAGS = @RPC_WARNFLAGS@
18 TRANSPORTFLAGS = @RPCGEN_I@ -s udp -s tcp
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/013-mntpathlen.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/013-mntpathlen.patch
deleted file mode 100644
index b161fe4e55..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/013-mntpathlen.patch
+++ /dev/null
@@ -1,37 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/mountd.c 2006/01/12 14:00:13 1.13
9+++ nfs-server/mountd.c 2006/01/12 14:37:35
10@@ -76,7 +76,7 @@
11 0
12 };
13
14-char argbuf[MNTPATHLEN + 1];
15+char argbuf[PATH_MAX + 1];
16 char *auth_file = NULL;
17 static char *program_name;
18 int need_reinit = 0;
19@@ -97,6 +97,9 @@
20 /*
21 * MOUNT
22 * This is what the whole protocol is all about
23+ *
24+ * Note: librpc gets us MNTPATHLEN length strings, but realpath
25+ * needs a PATH_MAX length output buffer.
26 */
27 fhstatus *
28 mountproc_mnt_1_svc(dirpath *argp, struct svc_req *rqstp)
29@@ -105,7 +108,7 @@
30 struct stat stbuf;
31 nfs_client *cp;
32 nfs_mount *mp;
33- char nargbuf[MNTPATHLEN + 1];
34+ char nargbuf[PATH_MAX + 1];
35 int saved_errno = 0;
36 #ifdef WANT_LOG_MOUNTS
37 struct in_addr addr;
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/014-uninitialized.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/014-uninitialized.patch
deleted file mode 100644
index 370f440d2c..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/014-uninitialized.patch
+++ /dev/null
@@ -1,17 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/mountd.c
9+++ nfs-server/mountd.c
10@@ -278,6 +278,7 @@
11 || (mp = auth_path(cp, rqstp, dir)) == NULL
12 || mp->o.noaccess) {
13 #ifdef WANT_LOG_MOUNTS
14+ addr = svc_getcaller(rqstp->rq_xprt)->sin_addr;
15 Dprintf(L_WARNING, "Blocked attempt of %s to pathconf(%s)\n",
16 inet_ntoa(addr), dir);
17 #endif /* WANT_LOG_MOUNTS */
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/015-setattr.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/015-setattr.patch
deleted file mode 100644
index 3b86d43bc2..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/015-setattr.patch
+++ /dev/null
@@ -1,31 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Patch origin: nfs-server source RPM from openSUSE 10.3
7
8--- nfs-server/setattr.c.orig 2006-07-28 16:38:26.000000000 +0200
9+++ nfs-server/setattr.c 2006-07-28 16:42:28.000000000 +0200
10@@ -97,7 +97,20 @@
11 tvp[1].tv_sec = s->st_mtime;
12 tvp[1].tv_usec = 0;
13 }
14- if (efs_utimes(path, tvp) < 0)
15+ if (m_secs != IGNORE_TIME && attr->mtime.useconds == 1000000) {
16+ /*
17+ * from kernel/fs/nfsd/nfsxdr.c:
18+ * Passing the invalid value useconds=1000000 for mtime
19+ * is a Sun convention for "set both mtime and atime to
20+ * current server time". It's needed to make permissions
21+ * checks for the "touch" program across v2 mounts to
22+ * Solaris and Irix boxes work correctly. See description of
23+ * sattr in section 6.1 of "NFS Illustrated" by
24+ * Brent Callaghan, Addison-Wesley, ISBN 0-201-32750-5
25+ */
26+ if (utime(path, (struct utimbuf *)0) < 0)
27+ goto failure;
28+ } else if (efs_utimes(path, tvp) < 0)
29 goto failure;
30 }
31 }
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/016-makefile.in.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/016-makefile.in.patch
deleted file mode 100644
index 211aa0bf89..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/016-makefile.in.patch
+++ /dev/null
@@ -1,19 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Makefile fix for staging to work correctly.
7# Scott Garman <scott.a.garman@intel.com>
8
9--- nfs-server-2.2beta47/Makefile.in.orig 2010-08-03 20:55:05.000000000 -0700
10+++ nfs-server-2.2beta47/Makefile.in 2010-08-03 20:55:42.000000000 -0700
11@@ -69,7 +69,7 @@
12 RPC_WARNFLAGS = @RPC_WARNFLAGS@
13 TRANSPORTFLAGS = @RPCGEN_I@ -s udp -s tcp
14
15-prefix = $(install_prefix)/usr
16+prefix = @prefix@
17 exec_prefix = $(prefix)
18
19 bindir = $(exec_prefix)/sbin
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/017-wrs-dynamic-rpc.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/017-wrs-dynamic-rpc.patch
deleted file mode 100644
index 99cd6b1029..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/017-wrs-dynamic-rpc.patch
+++ /dev/null
@@ -1,263 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Add the ability to choose alternate RPC ports at runtime and disable
7# security so that it can run as a userland process
8# Patch origin: Wind River
9
10Index: nfs-server-2.2beta47/auth_init.c
11===================================================================
12--- nfs-server-2.2beta47.orig/auth_init.c
13+++ nfs-server-2.2beta47/auth_init.c
14@@ -409,6 +409,7 @@ auth_init(char *fname)
15 fname = EXPORTSFILE;
16 auth_file = fname; /* Save for re-initialization */
17
18+#ifdef ROOT_LEVEL_SECURITY
19 /* Check protection of exports file. */
20 switch(iCheckAccess(auth_file, EXPORTSOWNERUID, EXPORTSOWNERGID)) {
21 case FACCESSWRITABLE:
22@@ -424,6 +425,7 @@ auth_init(char *fname)
23 Dprintf(L_ERROR, "exiting because of security violation.\n");
24 exit(1);
25 }
26+#endif
27
28 if ((ef = fopen(fname, "r")) == NULL) {
29 Dprintf(L_ERROR, "Could not open exports file %s: %s\n",
30Index: nfs-server-2.2beta47/nfsd.c
31===================================================================
32--- nfs-server-2.2beta47.orig/nfsd.c
33+++ nfs-server-2.2beta47/nfsd.c
34@@ -46,6 +46,7 @@ static char pathbuf_1[NFS_MAXPATHLEN + N
35
36 extern char version[];
37 static char *program_name;
38+static int nfs_prog = NFS_PROGRAM;
39
40 /*
41 * Option table
42@@ -60,6 +61,7 @@ static struct option longopts[] = {
43 { "help", 0, 0, 'h' },
44 { "log-transfers", 0, 0, 'l' },
45 { "allow-non-root", 0, 0, 'n' },
46+ { "prog", required_argument, 0, 'g' },
47 { "port", required_argument, 0, 'P' },
48 { "promiscuous", 0, 0, 'p' },
49 { "re-export", 0, 0, 'r' },
50@@ -73,9 +75,10 @@ static struct option longopts[] = {
51 { "udp-only", 0, 0, OPT_NOTCP },
52 { "loopback-only", 0, 0, OPT_LOOPBACK },
53 { "hashed-inodes", 0, 0, 'I' },
54+ { "nfs-pid", required_argument, 0, 'N' },
55 { NULL, 0, 0, 0 }
56 };
57-static const char * shortopts = "a:d:Ff:hlnP:prR:tvz::";
58+static const char * shortopts = "a:d:Ff:g:hlnN:P:prR:tvz::";
59
60 /*
61 * Table of supported versions
62@@ -1003,6 +1006,8 @@ main(int argc, char **argv)
63 int failsafe_level = 0;
64 int c;
65 int i, ncopies = 1;
66+ char *nfs_pid_file = NULL;
67+
68
69 program_name = argv[0];
70 chdir("/");
71@@ -1026,9 +1031,15 @@ main(int argc, char **argv)
72 case 'f':
73 auth_file = optarg;
74 break;
75+ case 'g':
76+ nfs_prog = atoi(optarg);
77+ break;
78 case 'l':
79 log_transfers = 1;
80 break;
81+ case 'N':
82+ nfs_pid_file = strdup(optarg);
83+ break;
84 case 'n':
85 allow_non_root = 1;
86 break;
87@@ -1114,7 +1125,7 @@ main(int argc, char **argv)
88 log_open("nfsd", foreground);
89
90 /* Initialize RPC stuff */
91- rpc_init("nfsd", NFS_PROGRAM, nfsd_versions, nfs_dispatch,
92+ rpc_init("nfsd", nfs_prog, nfsd_versions, nfs_dispatch,
93 nfsport, NFS_MAXDATA);
94
95 if (_rpcpmstart) {
96@@ -1145,7 +1156,10 @@ main(int argc, char **argv)
97 /* Initialize the AUTH module. */
98 auth_init(auth_file);
99
100- setpidpath(_PATH_NFSD_PIDFILE);
101+ if (nfs_pid_file == 0)
102+ nfs_pid_file = _PATH_NFSD_PIDFILE;
103+ setpidpath(nfs_pid_file);
104+
105 if (failsafe_level == 0) {
106 /* Start multiple copies of the server */
107 writepid(getpid(), 1);
108@@ -1215,9 +1229,11 @@ usage(FILE *fp, int n)
109 fprintf(fp,
110 "Usage: %s [-Fhnpv] [-d kind] [-f exports-file] [-P port] [--version]\n"
111 " [--debug kind] [--exports-file=file] [--port port]\n"
112+" [--prog alternate_rpc_port_nubmer]\n"
113 " [--allow-non-root] [--promiscuous] [--version] [--foreground]\n"
114 " [--re-export] [--log-transfers] [--public-root path]\n"
115 " [--no-spoof-trace] [--no-cross-mounts] [--hashed-inodes] [--help]\n"
116+" [--nfs-pid file]\n"
117 , program_name);
118 exit(n);
119 }
120@@ -1234,7 +1250,7 @@ sigterm(int sig)
121 static void
122 terminate(void)
123 {
124- rpc_exit(NFS_PROGRAM, nfsd_versions);
125+ rpc_exit(nfs_prog, nfsd_versions);
126 efs_shutdown();
127 }
128
129Index: nfs-server-2.2beta47/mountd.c
130===================================================================
131--- nfs-server-2.2beta47.orig/mountd.c
132+++ nfs-server-2.2beta47/mountd.c
133@@ -42,6 +42,7 @@ int hashed_inodes; /* dummy */
134 static void usage(FILE *, int);
135 static void terminate(void);
136 static RETSIGTYPE sigterm(int sig);
137+int mount_prog = MOUNTPROG;
138
139 /*
140 * Option table for mountd
141@@ -55,6 +56,7 @@ static struct option longopts[] =
142 { "help", 0, 0, 'h' },
143 { "allow-non-root", 0, 0, 'n' },
144 { "port", required_argument, 0, 'P' },
145+ { "prog", required_argument, 0, 'g' },
146 { "promiscous", 0, 0, 'p' },
147 { "re-export", 0, 0, 'r' },
148 { "no-spoof-trace", 0, 0, 't' },
149@@ -63,9 +65,11 @@ static struct option longopts[] =
150 { "no-cross-mounts", 0, 0, 'x' },
151 { "no-tcp", 0, 0, OPT_NOTCP },
152 { "loopback-only", 0, 0, OPT_LOOPBACK },
153+ { "mount-pid", required_argument, 0, 'N' },
154+ { "rmtab", required_argument, 0, 'R' },
155 { NULL, 0, 0, 0 }
156 };
157-static const char * shortopts = "Fd:f:hnpP:rtvz::";
158+static const char * shortopts = "Fd:f:g:hnN:pP:rRtvz::";
159
160 /*
161 * Table of supported versions
162@@ -318,6 +322,7 @@ main(int argc, char **argv)
163 int failsafe_level = 0;
164 int port = 0;
165 int c;
166+ char *mount_pid_file = NULL;
167
168 program_name = argv[0];
169
170@@ -340,9 +345,15 @@ main(int argc, char **argv)
171 case 'f':
172 auth_file = optarg;
173 break;
174+ case 'g':
175+ mount_prog = port = atoi(optarg);
176+ break;
177 case 'n':
178 allow_non_root = 1;
179 break;
180+ case 'N':
181+ mount_pid_file = strdup(optarg);
182+ break;
183 case 'P':
184 port = atoi(optarg);
185 if (port <= 0 || port > 65535) {
186@@ -354,6 +365,9 @@ main(int argc, char **argv)
187 case 'p':
188 promiscuous = 1;
189 break;
190+ case 'R':
191+ _PATH_RMTAB = strdup(optarg);
192+ break;
193 case 'r':
194 re_export = 1;
195 break;
196@@ -401,7 +415,7 @@ main(int argc, char **argv)
197 log_open("mountd", foreground);
198
199 /* Create services and register with portmapper */
200- rpc_init("mountd", MOUNTPROG, mountd_versions, mount_dispatch, port, 0);
201+ rpc_init("mountd", mount_prog, mountd_versions, mount_dispatch, port, 0);
202
203 if (_rpcpmstart) {
204 /* Always foreground mode */
205@@ -422,7 +436,9 @@ main(int argc, char **argv)
206 auth_init(auth_file);
207
208 /* Write pidfile */
209- setpidpath(_PATH_MOUNTD_PIDFILE);
210+ if (mount_pid_file == 0)
211+ mount_pid_file = _PATH_MOUNTD_PIDFILE;
212+ setpidpath(mount_pid_file);
213 writepid(getpid(), 1);
214
215 /* Failsafe mode */
216@@ -453,7 +469,9 @@ usage(FILE *fp, int n)
217 program_name);
218 fprintf(fp, " [--debug kind] [--help] [--allow-non-root]\n");
219 fprintf(fp, " [--promiscuous] [--version] [--port portnum]\n");
220+ fprintf(fp, " [--prog alternate_rpc_port_nubmer]\n");
221 fprintf(fp, " [--exports-file=file] [--no-cross-mounts]\n");
222+ fprintf(fp, " [--mount-pid file] [--rmtab file]\n");
223 exit(n);
224 }
225
226@@ -467,7 +485,7 @@ sigterm(int sig)
227 static void
228 terminate(void)
229 {
230- rpc_exit(MOUNTPROG, mountd_versions);
231+ rpc_exit(mount_prog, mountd_versions);
232 }
233
234 RETSIGTYPE
235Index: nfs-server-2.2beta47/rmtab.c
236===================================================================
237--- nfs-server-2.2beta47.orig/rmtab.c
238+++ nfs-server-2.2beta47/rmtab.c
239@@ -14,6 +14,8 @@ static char * rmtab_gethost(struct svc_r
240 static int rmtab_insert(char *, char *);
241 static void rmtab_file(char);
242
243+char *_PATH_RMTAB = _PATH_RMTAB_VAL;
244+
245 /*
246 * global top to linklist
247 */
248Index: nfs-server-2.2beta47/rmtab.h
249===================================================================
250--- nfs-server-2.2beta47.orig/rmtab.h
251+++ nfs-server-2.2beta47/rmtab.h
252@@ -11,8 +11,9 @@
253 * Location of rmtab file. /etc/rmtab is the standard on most systems.
254 */
255 #include <paths.h>
256-#ifndef _PATH_RMTAB
257-#define _PATH_RMTAB "/etc/rmtab"
258+extern char *_PATH_RMTAB;
259+#ifndef _PATH_RMTAB_VAL
260+#define _PATH_RMTAB_VAL "/etc/rmtab"
261 #endif
262
263 extern void rmtab_add_client(dirpath, struct svc_req *);
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/018-remove-tcp-wrappers.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/018-remove-tcp-wrappers.patch
deleted file mode 100644
index 1b407e4533..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/018-remove-tcp-wrappers.patch
+++ /dev/null
@@ -1,25 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Remove the requirement to link with libwrap
7# Patch origin: Wind River
8
9Index: nfs-server-2.2beta47/haccess.c
10===================================================================
11--- nfs-server-2.2beta47.orig/haccess.c 1999-04-08 08:47:19.000000000 -0400
12+++ nfs-server-2.2beta47/haccess.c 2006-08-07 17:05:31.868221639 -0400
13@@ -79,8 +79,12 @@
14 clients[hash] = hp;
15
16 hp->clnt_addr = addr;
17+#ifdef USE_TCP_WRAPPERS
18 hp->status = hosts_ctl(rpcprog, "unknown",
19 inet_ntoa(addr), "root");
20+#else
21+ hp->status = 1;
22+#endif
23 nrhosts++;
24 }
25
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/019-pid-before-fork.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/019-pid-before-fork.patch
deleted file mode 100644
index 1b9c06a8e7..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/019-pid-before-fork.patch
+++ /dev/null
@@ -1,130 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Write a pid file before forking
7# Patch origin: Wind River
8
9Index: nfs-server-2.2beta47/daemon.c
10===================================================================
11--- nfs-server-2.2beta47.orig/daemon.c
12+++ nfs-server-2.2beta47/daemon.c
13@@ -15,6 +15,19 @@
14 static const char * pidfilename = 0;
15 static const char * get_signame(int signo);
16
17+void
18+writepid(pid_t pid, int clear)
19+{
20+ FILE *fp;
21+
22+ fp = fopen(pidfilename, clear? "w" : "a");
23+ if (fp == NULL)
24+ Dprintf(L_FATAL, "Unable to open %s: %m", pidfilename);
25+ fprintf(fp, "%d\n", pid);
26+ fclose(fp);
27+ return;
28+}
29+
30 /*
31 * Do the Crawley Thing
32 */
33@@ -33,8 +46,10 @@ daemonize(void)
34 Dprintf(L_FATAL, "unable to fork: %s", strerror(errno));
35
36 /* Parent process: exit */
37- if (c > 0)
38+ if (c > 0) {
39+ writepid(c, 1);
40 exit(0);
41+ }
42
43 /* Do the session stuff */
44 close(0);
45@@ -60,19 +75,6 @@ setpidpath(const char *filename)
46 }
47
48 void
49-writepid(pid_t pid, int clear)
50-{
51- FILE *fp;
52-
53- fp = fopen(pidfilename, clear? "w" : "a");
54- if (fp == NULL)
55- Dprintf(L_FATAL, "Unable to open %s: %m", pidfilename);
56- fprintf(fp, "%d\n", pid);
57- fclose(fp);
58- return;
59-}
60-
61-void
62 failsafe(int level, int ncopies)
63 {
64 int *servers, running, child, i;
65Index: nfs-server-2.2beta47/mountd.c
66===================================================================
67--- nfs-server-2.2beta47.orig/mountd.c
68+++ nfs-server-2.2beta47/mountd.c
69@@ -425,9 +425,6 @@ main(int argc, char **argv)
70 background_logging();
71 }
72
73- /* Become a daemon */
74- if (!foreground)
75- daemonize();
76
77 /* Initialize the FH module. */
78 fh_init();
79@@ -435,11 +432,15 @@ main(int argc, char **argv)
80 /* Initialize the AUTH module. */
81 auth_init(auth_file);
82
83- /* Write pidfile */
84 if (mount_pid_file == 0)
85 mount_pid_file = _PATH_MOUNTD_PIDFILE;
86 setpidpath(mount_pid_file);
87- writepid(getpid(), 1);
88+
89+ /* Become a daemon */
90+ if (!foreground)
91+ daemonize();
92+ else
93+ writepid(getpid(), 1);
94
95 /* Failsafe mode */
96 if (failsafe_level)
97Index: nfs-server-2.2beta47/nfsd.c
98===================================================================
99--- nfs-server-2.2beta47.orig/nfsd.c
100+++ nfs-server-2.2beta47/nfsd.c
101@@ -1147,11 +1147,6 @@ main(int argc, char **argv)
102 /* if (ncopies > 1)
103 read_only = 1; */
104
105- /*
106- * We first fork off a child and detach from tty
107- */
108- if (!foreground)
109- daemonize();
110
111 /* Initialize the AUTH module. */
112 auth_init(auth_file);
113@@ -1160,9 +1155,16 @@ main(int argc, char **argv)
114 nfs_pid_file = _PATH_NFSD_PIDFILE;
115 setpidpath(nfs_pid_file);
116
117+ /*
118+ * We first fork off a child and detach from tty
119+ */
120+ if (!foreground)
121+ daemonize();
122+ else
123+ writepid(getpid(), 1);
124+
125 if (failsafe_level == 0) {
126 /* Start multiple copies of the server */
127- writepid(getpid(), 1);
128 for (i = 1; i < ncopies; i++) {
129 pid_t pid;
130
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/020-undefined-chmod-fix.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/020-undefined-chmod-fix.patch
deleted file mode 100644
index fb51300895..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/020-undefined-chmod-fix.patch
+++ /dev/null
@@ -1,23 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Fix a problem with chmod attributes when using no_squash_all
7# Patch origin: Wind River
8
9---
10 setattr.c | 2 +-
11 1 file changed, 1 insertion(+), 1 deletion(-)
12
13--- a/setattr.c
14+++ b/setattr.c
15@@ -115,7 +115,7 @@ nfsstat setattr(char *path, sattr *attr,
16 }
17 }
18
19- if (flags & SATTR_CHMOD) {
20+ if (flags & SATTR_CHMOD && attr->mode != -1) {
21 unsigned int mode = attr->mode;
22
23 /* If setuid is not allowed, silently squash them */
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/021-nolibwrap.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/021-nolibwrap.patch
deleted file mode 100644
index 335d098fbc..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/021-nolibwrap.patch
+++ /dev/null
@@ -1,25 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Remove libwrap linkage
7# Patch origin: Wind River
8
9---
10 configure.in | 4 ++--
11 1 file changed, 2 insertions(+), 2 deletions(-)
12
13--- a/configure.in
14+++ b/configure.in
15@@ -86,8 +86,8 @@ AC_AUTHDES_GETUCRED
16 AC_BROKEN_SETFSUID
17 AC_MOUNTLIST
18 AC_FSUSAGE
19-AC_CHECK_LIB(wrap, main)
20-AC_LIBWRAP_BUG
21+dnl AC_CHECK_LIB(wrap, main)
22+dnl AC_LIBWRAP_BUG
23 AC_BSD_SIGNALS
24
25 dnl **************************************************************
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/022-add-close-on-exec-descriptors.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/022-add-close-on-exec-descriptors.patch
deleted file mode 100644
index c35bb7caf0..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/022-add-close-on-exec-descriptors.patch
+++ /dev/null
@@ -1,66 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Scott Garman <scott.a.garman@intel.com>
5
6# Force socket fds to close on exec when used in conjunction with pseudo
7# Patch origin: Wind River
8
9---
10 nfsd.c | 8 ++++++++
11 rpcmisc.c | 9 +++++++++
12 ugidd.c | 8 ++++++++
13 3 files changed, 25 insertions(+)
14
15--- a/nfsd.c
16+++ b/nfsd.c
17@@ -630,6 +630,14 @@ nfsd_nfsproc_create_2(createargs *argp,
18 if (S_ISSOCK(argp->attributes.mode)) {
19 if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
20 return(nfs_errno());
21+ /* if there is a pseudo exec mark the socket to be
22+ * closed automatically
23+ */
24+ {
25+ long f_flags;
26+ f_flags = fcntl(s, F_GETFD);
27+ f_flags = fcntl(s, F_SETFD, f_flags | FD_CLOEXEC);
28+ }
29 sa.sun_family = AF_UNIX;
30 strncpy(sa.sun_path, pathbuf, sizeof(sa.sun_path));
31 sa.sun_path[sizeof(sa.sun_path)-1] = '\0';
32--- a/rpcmisc.c
33+++ b/rpcmisc.c
34@@ -197,6 +197,15 @@ makesock(int port, int proto, int socksz
35 Dprintf(L_FATAL, "Could not make a %s socket: %s\n",
36 prot_name, strerror(errno));
37
38+ /* if there is a pseudo exec mark the socket to be
39+ * closed automatically
40+ */
41+ {
42+ long f_flags;
43+ f_flags = fcntl(s, F_GETFD);
44+ f_flags = fcntl(s, F_SETFD, f_flags | FD_CLOEXEC);
45+ }
46+ fcntl(s, FD_CLOEXEC, 1);
47 memset((char *) &sin, 0, sizeof(sin));
48 sin.sin_family = AF_INET;
49 sin.sin_addr.s_addr = INADDR_ANY;
50--- a/ugidd.c
51+++ b/ugidd.c
52@@ -195,6 +195,14 @@ authenticate_1_svc(argp, rqstp)
53 destaddr.sin_port = htons(*argp);
54 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
55 goto bad;
56+ /* if there is a pseudo exec mark the socket to be
57+ * closed automatically
58+ */
59+ {
60+ long f_flags;
61+ f_flags = fcntl(s, F_GETFD);
62+ f_flags = fcntl(s, F_SETFD, f_flags | FD_CLOEXEC);
63+ }
64 setsockopt(s, SOL_SOCKET, SO_LINGER, 0, 0);
65 bzero((char *) &sendaddr, sizeof sendaddr);
66 /* find a reserved port */
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/023-no-rpc-register.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/023-no-rpc-register.patch
deleted file mode 100644
index 50f23fcc6c..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server-2.1+2.2beta47/023-no-rpc-register.patch
+++ /dev/null
@@ -1,34 +0,0 @@
1Upstream-Status: Inappropriate [other]
2Upstream is not making further releases of this software.
3
4Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
5
6# Allow user mode NFS to work without rpcbind / portmap
7# Patch origin: Wind River
8
9---
10 rpcmisc.c | 6 ++++--
11 1 file changed, 4 insertions(+), 2 deletions(-)
12
13--- a/rpcmisc.c
14+++ b/rpcmisc.c
15@@ -91,7 +91,8 @@ not_inetd:
16 if (transp == NULL)
17 Dprintf(L_FATAL, "cannot create udp service.");
18 for (i = 0; (vers = verstbl[i]) != 0; i++) {
19- if (!svc_register(transp, prog, vers, dispatch, IPPROTO_UDP)) {
20+ if (!(svc_register(transp, prog, vers, dispatch, IPPROTO_UDP) ||
21+ svc_register(transp, prog, vers, dispatch, 0))) {
22 Dprintf(L_FATAL,
23 "unable to register (%s, %d, udp).",
24 name, vers);
25@@ -110,7 +111,8 @@ not_inetd:
26 transp->xp_ops->xp_recv = auth_rendevouser;
27 #endif
28 for (i = 0; (vers = verstbl[i]) != 0; i++) {
29- if (!svc_register(transp, prog, vers, dispatch, IPPROTO_TCP)) {
30+ if (!(svc_register(transp, prog, vers, dispatch, IPPROTO_TCP) ||
31+ svc_register(transp, prog, vers, dispatch, 0))) {
32 Dprintf(L_FATAL,
33 "unable to register (%s, %d, tcp).",
34 name, vers);
diff --git a/meta/recipes-devtools/unfs-server/unfs-server_2.1+2.2beta47.bb b/meta/recipes-devtools/unfs-server/unfs-server_2.1+2.2beta47.bb
deleted file mode 100644
index 226a6456d3..0000000000
--- a/meta/recipes-devtools/unfs-server/unfs-server_2.1+2.2beta47.bb
+++ /dev/null
@@ -1,78 +0,0 @@
1SUMMARY = "Userspace NFS server"
2SECTION = "console/network"
3LICENSE = "GPLv2+"
4LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b"
5
6RDEPENDS_${PN} = "pseudo"
7RDEPENDS_${PN}_class-native = "pseudo-native"
8RDEPENDS_${PN}_class-nativesdk = "nativesdk-pseudo"
9BASEPV = "2.2beta47"
10PR = "r1"
11
12SRC_URI = "ftp://linux.mathematik.tu-darmstadt.de/pub/linux/oldstuff/people/okir/nfs-server-${BASEPV}.tar.gz \
13 file://001-2.2b47-2.2b51.patch \
14 file://002-destdir.patch \
15 file://003-manpages.patch \
16 file://004-strsignal.patch \
17 file://005-sys-time.patch \
18 file://006-reiserfs.patch \
19 file://007-map.patch \
20 file://008-configure.patch \
21 file://009-multirw.patch \
22 file://010-realpath.patch \
23 file://011-fno-strict-aliasing.patch \
24 file://012-nostrip.patch \
25 file://013-mntpathlen.patch \
26 file://014-uninitialized.patch \
27 file://015-setattr.patch \
28 file://016-makefile.in.patch \
29 file://017-wrs-dynamic-rpc.patch \
30 file://018-remove-tcp-wrappers.patch \
31 file://019-pid-before-fork.patch \
32 file://020-undefined-chmod-fix.patch \
33 file://021-nolibwrap.patch \
34 file://022-add-close-on-exec-descriptors.patch \
35 file://023-no-rpc-register.patch \
36 "
37
38SRC_URI[md5sum] = "79a29fe9f79b2f3241d4915767b8c511"
39SRC_URI[sha256sum] = "7eeaf3cf0b9d96167a5ba03bf1046e39b4585de1339a55b285e673c06ba415cb"
40
41S = "${WORKDIR}/nfs-server-${BASEPV}/"
42
43inherit autotools
44
45BBCLASSEXTEND = "native nativesdk"
46
47CFLAGS = "-fPIE -fstack-protector-all"
48LDFLAGS = "-pie"
49
50EXTRA_OECONF = "--enable-ugid-dynamic \
51 --enable-ugid-nis \
52 --enable-host-access \
53 --with-exports-uid=0 \
54 --with-exports-gid=0 \
55 --enable-mount-logging \
56 --with-devtab=${DESTDIR}${base_prefix}/var/lib/nfs/devtab \
57 "
58
59do_configure_prepend () {
60 # Remove pregenerated xdr functions. They use long
61 # instead of u32, which produces incorrect code on
62 # 64-bit architectures:
63 rm -f *_xdr.c
64
65 if [ ! -f ${S}/acinclude.m4 ]; then
66 mv ${S}/aclocal.m4 ${S}/acinclude.m4
67 fi
68}
69
70# This recipe is intended for -native and -nativesdk builds only,
71# not target installs:
72python __anonymous () {
73 import re
74
75 pn = d.getVar("PN", True)
76 if not pn.endswith('-native') and not pn.startswith('nativesdk-'):
77 raise bb.parse.SkipPackage("unfs-server is intended for native/nativesdk builds only")
78}