unfs-server: new userspace nfs recipe

This is a simple userspace NFS server, derived from one which was
previously used in openSUSE 10.x. Wind River contributed many of the
patches.

This package is not intended for target installations, only -native
and -nativesdk use.

Enabling nativesdk for readline, sqlite3, and pseudo was required, as
well as a few new autoconf siteconfig entries.

Signed-off-by: Scott Garman <scott.a.garman@intel.com>
This commit is contained in:
Scott Garman 2010-08-12 21:02:58 -07:00 committed by Richard Purdie
parent 735210556d
commit b5b3825ce6
29 changed files with 4634 additions and 4 deletions

View File

@ -42,6 +42,6 @@ do_install () {
fi
}
BBCLASSEXTEND = "native"
BBCLASSEXTEND = "native nativesdk"

View File

@ -32,4 +32,4 @@ do_install_append () {
oe_libinstall -so -C shlib libreadline ${D}${libdir}
}
BBCLASSEXTEND = "native"
BBCLASSEXTEND = "native nativesdk"

View File

@ -30,4 +30,4 @@ FILES_libsqlite-dev = "${libdir}/*.a ${libdir}/*.la ${libdir}/*.so \
FILES_libsqlite-doc = "${docdir} ${mandir} ${infodir}"
AUTO_LIBNAME_PKGS = "libsqlite"
BBCLASSEXTEND = "native"
BBCLASSEXTEND = "native nativesdk"

View File

@ -18,6 +18,8 @@ RDEPENDS_${PN} = "\
pkgconfig-nativesdk \
qemu-nativesdk \
qemu-helper-nativesdk \
pseudo-nativesdk \
unfs-server-nativesdk \
opkg-nativesdk \
"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,68 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/Makefile.in 2002/11/07 16:56:07 1.1
+++ nfs-server/Makefile.in 2002/11/07 17:08:41
@@ -74,10 +74,10 @@
bindir = $(exec_prefix)/sbin
#vardir = $(install_prefix)/var/lib/nfs
-infodir = $(prefix)/info
-man5dir = $(prefix)/man/man5
+infodir = $(prefix)/share/info
+man5dir = $(prefix)/share/man/man5
man5ext = .5
-man8dir = $(prefix)/man/man8
+man8dir = $(prefix)/share/man/man8
man8ext = .8
# Prefix to be prepended to each installed RPC program, normally `rpc.'.
@@ -145,37 +145,37 @@
.PHONY: install installdirs
install: $(DAEMONS) $(CLIENTS) installdirs
@for prog in $(DAEMONS) $(CLIENTS); do \
- echo "installing $$prog in $(bindir)"; \
- $(INSTALL_PROGRAM) $$prog $(bindir)/$$prog; \
+ echo "installing $$prog in $(DESTDIR)$(bindir)"; \
+ $(INSTALL_PROGRAM) $$prog $(DESTDIR)$(bindir)/$$prog; \
done
@for manp in $(MANPAGES5); do \
- echo "installing $$manp$(man5ext) in $(man5dir)"; \
+ echo "installing $$manp$(man5ext) in $(DESTDIR)$(man5dir)"; \
$(INSTALL_DATA) $(srcdir)/$$manp.man \
- $(man5dir)/$$manp$(man5ext); \
+ $(DESTDIR)$(man5dir)/$$manp$(man5ext); \
done
@for manp in $(MANPAGES8p); do \
- echo "installing $$manp$(man8ext) in $(man8dir)"; \
+ echo "installing $$manp$(man8ext) in $(DESTDIR)$(man8dir)"; \
$(INSTALL_DATA) $(srcdir)/$$manp.man \
- $(man8dir)/$$manp$(man8ext); \
+ $(DESTDIR)$(man8dir)/$$manp$(man8ext); \
if [ 'x$(rpcprefix)' != 'x' ]; then \
rm -f $(man8dir)/$(rpcprefix)$$manp$(man8ext); \
ln -s $$manp$(man8ext) \
- $(man8dir)/$(rpcprefix)$$manp$(man8ext); \
+ $(DESTDIR)$(man8dir)/$(rpcprefix)$$manp$(man8ext); \
fi; \
done
@for manp in $(MANPAGES8); do \
- echo "installing $$manp$(man8ext) in $(man8dir)"; \
+ echo "installing $$manp$(man8ext) in $(DESTDIR)$(man8dir)"; \
$(INSTALL_DATA) $(srcdir)/$$manp.man \
- $(man8dir)/$$manp$(man8ext); \
+ $(DESTDIR)$(man8dir)/$$manp$(man8ext); \
done
@if [ -n "$(DEVTAB_FILE)" -a ! -f "$(DEVTAB_FILE)" ]; then \
echo "Initializing $(DEVTAB_FILE)"; \
- $(INSTALL) -m 755 -d `dirname $(DEVTAB_FILE)`; \
- echo "# Device mapping for unfsd" > "$(DEVTAB_FILE)"; \
+ $(INSTALL) -m 755 -d `dirname $(DESTDIR)$(DEVTAB_FILE)`; \
+ echo "# Device mapping for unfsd" > $(DESTDIR)"$(DEVTAB_FILE)"; \
fi
installdirs:
- ${srcdir}/mkinstalldirs $(bindir) $(man5dir) $(man8dir)
+ ${srcdir}/mkinstalldirs $(DESTDIR)$(bindir) $(DESTDIR)$(man5dir) $(DESTDIR)$(man8dir)
$(rpcprefix)mountd: $(MOUNTD_OBJS) libnfs.a
$(CC) $(LDFLAGS) -o $@ $(MOUNTD_OBJS) $(LIBS)

View File

@ -0,0 +1,28 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/exports.man 2002/11/07 17:15:59 1.1
+++ nfs-server/exports.man 2002/11/07 17:17:19
@@ -110,6 +110,14 @@
.TP
.IR link_absolute
Leave all symbolic link as they are. This is the default operation.
+.SS Anonymous Entries
+.PP
+Entries where hosts are not specified are known as anonymous entries. They
+have different default settings compared to normal entries. The differences
+include
+.IR all_squash ,
+.IR no_secure ", and"
+.IR ro .
.SS User ID Mapping
.PP
.I nfsd
@@ -231,7 +239,7 @@
# Mapping for client foobar:
# remote local
uid 0-99 - # squash these
-uid 100-500 1000 # map 100-500 to 1000-1500
+uid 100-500 1000 # map 100-500 to 1000-1400
gid 0-49 - # squash these
gid 50-100 700 # map 50-100 to 700-750
.fi

View File

@ -0,0 +1,48 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/failsafe.c 2002/11/07 17:12:46 1.1
+++ nfs-server/failsafe.c 2002/11/07 17:15:16
@@ -10,8 +10,12 @@
#include "logging.h"
#include "signals.h"
#include <sys/wait.h>
+#ifdef HAVE_STRSIGNAL
+#include <string.h>
+#else
static const char * get_signame(int signo);
+#endif
void
failsafe(int level, int ncopies)
@@ -111,9 +115,17 @@
pid, running? "Continue" : "Exit");
} else {
Dprintf(L_WARNING, "failsafe: "
+#ifdef HAVE_STRSIGNAL
+ "child %d terminated by: %s. "
+#else
"child %d terminated by %s. "
+#endif
"Restarting.",
+#ifdef HAVE_STRSIGNAL
+ pid, strsignal(signo));
+#else
pid, get_signame(signo));
+#endif
child = -1; /* Restart */
}
} else if (WIFEXITED(status)) {
@@ -159,6 +171,7 @@
/* NOP */
}
+#ifndef HAVE_STRSIGNAL
static const char *
get_signame(int signo)
{
@@ -199,3 +212,4 @@
sprintf(namebuf, "signal #%d", signo);
return namebuf;
}
+#endif

View File

@ -0,0 +1,29 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/system.h 2002/11/07 17:10:47 1.1
+++ nfs-server/system.h 2002/11/07 17:11:53
@@ -66,20 +66,16 @@
# include <grp.h> /* for setgroups */
#endif
-#ifdef TIME_WITH_SYS_TIME
+#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# include <time.h>
-#else /* not TIME_WITH_SYS_TIME */
-# ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else /* not HAVE_SYS_TIME_H */
-# include <time.h>
+#else /* not HAVE_SYS_TIME_H */
+# include <time.h>
struct timeval {
long tv_sec;
long tv_usec;
};
-# endif /* not HAVE_SYS_TIME_H */
-#endif /* not TIME_WITH_SYS_TIME */
+#endif /* not HAVE_SYS_TIME_H */
#ifdef HAVE_SYS_FILE_H
# include <sys/file.h>
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,78 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/auth.c
+++ nfs-server/auth.c 2002/11/08 12:49:13
@@ -595,7 +595,6 @@
cp->clnt_addr.s_addr = INADDR_ANY;
cp->flags = 0;
cp->m = NULL;
- cp->umap = NULL;
if (hname == NULL) {
if (anonymous_client != NULL) {
@@ -1200,10 +1199,9 @@
free (mp->path);
if (mp->o.clnt_nisdomain)
free(mp->o.clnt_nisdomain);
+ if (mp->umap)
+ ugid_free_map(mp->umap);
free (mp);
- }
- if (cp->umap != NULL) {
- ugid_free_map(cp->umap);
}
free (cp);
}
--- nfs-server/auth.h
+++ nfs-server/auth.h 2002/11/08 12:50:24
@@ -66,6 +66,11 @@
char * path;
nfs_options o;
dev_t mount_dev;
+ /*
+ * This is the uid/gid map.
+ * See ugid_map.c for details
+ */
+ struct ugid_map * umap;
/* Original NFS client */
struct nfs_client * origin;
} nfs_mount;
@@ -77,12 +82,6 @@
char * clnt_name;
unsigned short flags;
nfs_mount * m;
-
- /*
- * This is the uid/gid map.
- * See ugid_map.c for details
- */
- struct ugid_map * umap;
} nfs_client;
#define AUTH_CLNT_WILDCARD 0x0001
--- nfs-server/ugid_map.c
+++ nfs-server/ugid_map.c 2002/11/08 12:49:14
@@ -401,12 +401,11 @@
static ugid_map *
ugid_get_map(nfs_mount *mountp)
{
- nfs_client *clientp = mountp->client;
struct ugid_map *umap;
unsigned int how;
- if (clientp->umap == NULL) {
- clientp->umap = umap = (ugid_map *) xmalloc(sizeof(ugid_map));
+ if (mountp->umap == NULL) {
+ mountp->umap = umap = (ugid_map *) xmalloc(sizeof(ugid_map));
memset(umap, 0, sizeof(ugid_map));
for (how = 0; how < 4; how++) {
@@ -415,7 +414,7 @@
}
}
- return clientp->umap;
+ return mountp->umap;
}
static void

View File

@ -0,0 +1,13 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/configure.in 2002/11/08 14:24:55 1.1
+++ nfs-server/configure.in 2002/11/08 14:25:27
@@ -98,7 +98,7 @@
fi
if test "$enable_ugid_dynamic" = yes; then
AC_DEFINE(ENABLE_UGID_DAEMON)
- UGIDD_PROG=\${rpcprefix}.ugidd
+ UGIDD_PROG=\${rpcprefix}ugidd
UGIDD_MAN=ugidd
fi
if test "$enable_ugid_nis" = yes; then

View File

@ -0,0 +1,15 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/nfsd.c
+++ nfs-server/nfsd.c
@@ -1133,8 +1133,8 @@
}
}
- if (ncopies > 1)
- read_only = 1;
+ /* if (ncopies > 1)
+ read_only = 1; */
/*
* We first fork off a child and detach from tty

View File

@ -0,0 +1,30 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/configure.in
+++ nfs-server/configure.in
@@ -81,7 +81,7 @@
AC_CHECK_LIB(rpc, main)
AC_CHECK_LIB(crypt, main)
AC_CHECK_LIB(nys, main)
-AC_HAVE_FUNCS(getcwd seteuid setreuid getdtablesize setgroups lchown setsid setfsuid setfsgid innetgr quotactl authdes_getucred)
+AC_HAVE_FUNCS(getcwd seteuid setreuid getdtablesize setgroups lchown setsid setfsuid setfsgid innetgr quotactl authdes_getucred realpath)
AC_AUTHDES_GETUCRED
AC_BROKEN_SETFSUID
AC_MOUNTLIST
--- nfs-server/realpath.c
+++ nfs-server/realpath.c
@@ -53,6 +53,8 @@
#define MAX_READLINKS 32
+#ifndef HAVE_REALPATH
+
#ifdef __STDC__
char *realpath(const char *path, char resolved_path [])
#else
@@ -173,3 +175,5 @@
strcpy (resolved_path, got_path);
return resolved_path;
}
+
+#endif /* HAVE_REALPATH */

View File

@ -0,0 +1,13 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/Makefile.in
+++ nfs-server/Makefile.in
@@ -225,7 +225,7 @@
$(RPCGEN) -l -o $@ $?
nfs_prot_xdr.o: nfs_prot_xdr.c
- $(COMPILE) $(RPC_WARNFLAGS) -c nfs_prot_xdr.c
+ $(COMPILE) $(RPC_WARNFLAGS) -fno-strict-aliasing -c nfs_prot_xdr.c
mount_xdr.o: mount_xdr.c
$(COMPILE) $(RPC_WARNFLAGS) -c mount_xdr.c
mount_svc.o: mount_svc.c

View File

@ -0,0 +1,13 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/Makefile.in.xx 2006-01-12 12:43:09.000000000 +0100
+++ nfs-server/Makefile.in 2006-01-12 12:43:10.000000000 +0100
@@ -64,7 +64,7 @@
NFSD_DEFS =
CFLAGS = @CFLAGS@
-LDFLAGS = @LDFLAGS@ -s
+LDFLAGS = @LDFLAGS@
WARNFLAGS = @WARNFLAGS@
RPC_WARNFLAGS = @RPC_WARNFLAGS@
TRANSPORTFLAGS = @RPCGEN_I@ -s udp -s tcp

View File

@ -0,0 +1,32 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/mountd.c 2006/01/12 14:00:13 1.13
+++ nfs-server/mountd.c 2006/01/12 14:37:35
@@ -76,7 +76,7 @@
0
};
-char argbuf[MNTPATHLEN + 1];
+char argbuf[PATH_MAX + 1];
char *auth_file = NULL;
static char *program_name;
int need_reinit = 0;
@@ -97,6 +97,9 @@
/*
* MOUNT
* This is what the whole protocol is all about
+ *
+ * Note: librpc gets us MNTPATHLEN length strings, but realpath
+ * needs a PATH_MAX length output buffer.
*/
fhstatus *
mountproc_mnt_1_svc(dirpath *argp, struct svc_req *rqstp)
@@ -105,7 +108,7 @@
struct stat stbuf;
nfs_client *cp;
nfs_mount *mp;
- char nargbuf[MNTPATHLEN + 1];
+ char nargbuf[PATH_MAX + 1];
int saved_errno = 0;
#ifdef WANT_LOG_MOUNTS
struct in_addr addr;

View File

@ -0,0 +1,12 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/mountd.c
+++ nfs-server/mountd.c
@@ -278,6 +278,7 @@
|| (mp = auth_path(cp, rqstp, dir)) == NULL
|| mp->o.noaccess) {
#ifdef WANT_LOG_MOUNTS
+ addr = svc_getcaller(rqstp->rq_xprt)->sin_addr;
Dprintf(L_WARNING, "Blocked attempt of %s to pathconf(%s)\n",
inet_ntoa(addr), dir);
#endif /* WANT_LOG_MOUNTS */

View File

@ -0,0 +1,26 @@
# Patch origin: nfs-server source RPM from openSUSE 10.3
--- nfs-server/setattr.c.orig 2006-07-28 16:38:26.000000000 +0200
+++ nfs-server/setattr.c 2006-07-28 16:42:28.000000000 +0200
@@ -97,7 +97,20 @@
tvp[1].tv_sec = s->st_mtime;
tvp[1].tv_usec = 0;
}
- if (efs_utimes(path, tvp) < 0)
+ if (m_secs != IGNORE_TIME && attr->mtime.useconds == 1000000) {
+ /*
+ * from kernel/fs/nfsd/nfsxdr.c:
+ * Passing the invalid value useconds=1000000 for mtime
+ * is a Sun convention for "set both mtime and atime to
+ * current server time". It's needed to make permissions
+ * checks for the "touch" program across v2 mounts to
+ * Solaris and Irix boxes work correctly. See description of
+ * sattr in section 6.1 of "NFS Illustrated" by
+ * Brent Callaghan, Addison-Wesley, ISBN 0-201-32750-5
+ */
+ if (utime(path, (struct utimbuf *)0) < 0)
+ goto failure;
+ } else if (efs_utimes(path, tvp) < 0)
goto failure;
}
}

View File

@ -0,0 +1,14 @@
# Makefile fix for staging to work correctly.
# Scott Garman <scott.a.garman@intel.com>
--- nfs-server-2.2beta47/Makefile.in.orig 2010-08-03 20:55:05.000000000 -0700
+++ nfs-server-2.2beta47/Makefile.in 2010-08-03 20:55:42.000000000 -0700
@@ -69,7 +69,7 @@
RPC_WARNFLAGS = @RPC_WARNFLAGS@
TRANSPORTFLAGS = @RPCGEN_I@ -s udp -s tcp
-prefix = $(install_prefix)/usr
+prefix = @prefix@
exec_prefix = $(prefix)
bindir = $(exec_prefix)/sbin

View File

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

View File

@ -0,0 +1,20 @@
# Remove the requirement to link with libwrap
# Patch origin: Wind River
Index: nfs-server-2.2beta47/haccess.c
===================================================================
--- nfs-server-2.2beta47.orig/haccess.c 1999-04-08 08:47:19.000000000 -0400
+++ nfs-server-2.2beta47/haccess.c 2006-08-07 17:05:31.868221639 -0400
@@ -79,8 +79,12 @@
clients[hash] = hp;
hp->clnt_addr = addr;
+#ifdef USE_TCP_WRAPPERS
hp->status = hosts_ctl(rpcprog, "unknown",
inet_ntoa(addr), "root");
+#else
+ hp->status = 1;
+#endif
nrhosts++;
}

View File

@ -0,0 +1,125 @@
# Write a pid file before forking
# Patch origin: Wind River
Index: nfs-server-2.2beta47/daemon.c
===================================================================
--- nfs-server-2.2beta47.orig/daemon.c
+++ nfs-server-2.2beta47/daemon.c
@@ -15,6 +15,19 @@
static const char * pidfilename = 0;
static const char * get_signame(int signo);
+void
+writepid(pid_t pid, int clear)
+{
+ FILE *fp;
+
+ fp = fopen(pidfilename, clear? "w" : "a");
+ if (fp == NULL)
+ Dprintf(L_FATAL, "Unable to open %s: %m", pidfilename);
+ fprintf(fp, "%d\n", pid);
+ fclose(fp);
+ return;
+}
+
/*
* Do the Crawley Thing
*/
@@ -33,8 +46,10 @@ daemonize(void)
Dprintf(L_FATAL, "unable to fork: %s", strerror(errno));
/* Parent process: exit */
- if (c > 0)
+ if (c > 0) {
+ writepid(c, 1);
exit(0);
+ }
/* Do the session stuff */
close(0);
@@ -60,19 +75,6 @@ setpidpath(const char *filename)
}
void
-writepid(pid_t pid, int clear)
-{
- FILE *fp;
-
- fp = fopen(pidfilename, clear? "w" : "a");
- if (fp == NULL)
- Dprintf(L_FATAL, "Unable to open %s: %m", pidfilename);
- fprintf(fp, "%d\n", pid);
- fclose(fp);
- return;
-}
-
-void
failsafe(int level, int ncopies)
{
int *servers, running, child, i;
Index: nfs-server-2.2beta47/mountd.c
===================================================================
--- nfs-server-2.2beta47.orig/mountd.c
+++ nfs-server-2.2beta47/mountd.c
@@ -425,9 +425,6 @@ main(int argc, char **argv)
background_logging();
}
- /* Become a daemon */
- if (!foreground)
- daemonize();
/* Initialize the FH module. */
fh_init();
@@ -435,11 +432,15 @@ main(int argc, char **argv)
/* Initialize the AUTH module. */
auth_init(auth_file);
- /* Write pidfile */
if (mount_pid_file == 0)
mount_pid_file = _PATH_MOUNTD_PIDFILE;
setpidpath(mount_pid_file);
- writepid(getpid(), 1);
+
+ /* Become a daemon */
+ if (!foreground)
+ daemonize();
+ else
+ writepid(getpid(), 1);
/* Failsafe mode */
if (failsafe_level)
Index: nfs-server-2.2beta47/nfsd.c
===================================================================
--- nfs-server-2.2beta47.orig/nfsd.c
+++ nfs-server-2.2beta47/nfsd.c
@@ -1147,11 +1147,6 @@ main(int argc, char **argv)
/* if (ncopies > 1)
read_only = 1; */
- /*
- * We first fork off a child and detach from tty
- */
- if (!foreground)
- daemonize();
/* Initialize the AUTH module. */
auth_init(auth_file);
@@ -1160,9 +1155,16 @@ main(int argc, char **argv)
nfs_pid_file = _PATH_NFSD_PIDFILE;
setpidpath(nfs_pid_file);
+ /*
+ * We first fork off a child and detach from tty
+ */
+ if (!foreground)
+ daemonize();
+ else
+ writepid(getpid(), 1);
+
if (failsafe_level == 0) {
/* Start multiple copies of the server */
- writepid(getpid(), 1);
for (i = 1; i < ncopies; i++) {
pid_t pid;

View File

@ -0,0 +1,18 @@
# Fix a problem with chmod attributes when using no_squash_all
# Patch origin: Wind River
---
setattr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/setattr.c
+++ b/setattr.c
@@ -115,7 +115,7 @@ nfsstat setattr(char *path, sattr *attr,
}
}
- if (flags & SATTR_CHMOD) {
+ if (flags & SATTR_CHMOD && attr->mode != -1) {
unsigned int mode = attr->mode;
/* If setuid is not allowed, silently squash them */

View File

@ -0,0 +1,20 @@
# Remove libwrap linkage
# Patch origin: Wind River
---
configure.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/configure.in
+++ b/configure.in
@@ -86,8 +86,8 @@ AC_AUTHDES_GETUCRED
AC_BROKEN_SETFSUID
AC_MOUNTLIST
AC_FSUSAGE
-AC_CHECK_LIB(wrap, main)
-AC_LIBWRAP_BUG
+dnl AC_CHECK_LIB(wrap, main)
+dnl AC_LIBWRAP_BUG
AC_BSD_SIGNALS
dnl **************************************************************

View File

@ -0,0 +1,61 @@
# Force socket fds to close on exec when used in conjunction with pseudo
# Patch origin: Wind River
---
nfsd.c | 8 ++++++++
rpcmisc.c | 9 +++++++++
ugidd.c | 8 ++++++++
3 files changed, 25 insertions(+)
--- a/nfsd.c
+++ b/nfsd.c
@@ -630,6 +630,14 @@ nfsd_nfsproc_create_2(createargs *argp,
if (S_ISSOCK(argp->attributes.mode)) {
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
return(nfs_errno());
+ /* if there is a pseudo exec mark the socket to be
+ * closed automatically
+ */
+ {
+ long f_flags;
+ f_flags = fcntl(s, F_GETFD);
+ f_flags = fcntl(s, F_SETFD, f_flags | FD_CLOEXEC);
+ }
sa.sun_family = AF_UNIX;
strncpy(sa.sun_path, pathbuf, sizeof(sa.sun_path));
sa.sun_path[sizeof(sa.sun_path)-1] = '\0';
--- a/rpcmisc.c
+++ b/rpcmisc.c
@@ -197,6 +197,15 @@ makesock(int port, int proto, int socksz
Dprintf(L_FATAL, "Could not make a %s socket: %s\n",
prot_name, strerror(errno));
+ /* if there is a pseudo exec mark the socket to be
+ * closed automatically
+ */
+ {
+ long f_flags;
+ f_flags = fcntl(s, F_GETFD);
+ f_flags = fcntl(s, F_SETFD, f_flags | FD_CLOEXEC);
+ }
+ fcntl(s, FD_CLOEXEC, 1);
memset((char *) &sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
--- a/ugidd.c
+++ b/ugidd.c
@@ -195,6 +195,14 @@ authenticate_1_svc(argp, rqstp)
destaddr.sin_port = htons(*argp);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
goto bad;
+ /* if there is a pseudo exec mark the socket to be
+ * closed automatically
+ */
+ {
+ long f_flags;
+ f_flags = fcntl(s, F_GETFD);
+ f_flags = fcntl(s, F_SETFD, f_flags | FD_CLOEXEC);
+ }
setsockopt(s, SOL_SOCKET, SO_LINGER, 0, 0);
bzero((char *) &sendaddr, sizeof sendaddr);
/* find a reserved port */

View File

@ -0,0 +1,71 @@
DESCRIPTION = "Userspace NFS server"
SECTION = "console/network"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b"
PR = "r0"
SRC_URI = "ftp://linux.mathematik.tu-darmstadt.de/pub/linux/oldstuff/people/okir/nfs-server-${PV}.tar.gz \
file://001-2.2b47-2.2b51.patch \
file://002-destdir.patch \
file://003-manpages.patch \
file://004-strsignal.patch \
file://005-sys-time.patch \
file://006-reiserfs.patch \
file://007-map.patch \
file://008-configure.patch \
file://009-multirw.patch \
file://010-realpath.patch \
file://011-fno-strict-aliasing.patch \
file://012-nostrip.patch \
file://013-mntpathlen.patch \
file://014-uninitialized.patch \
file://015-setattr.patch \
file://016-makefile.in.patch \
file://017-wrs-dynamic-rpc.patch \
file://018-remove-tcp-wrappers.patch \
file://019-pid-before-fork.patch \
file://020-undefined-chmod-fix.patch \
file://021-nolibwrap.patch \
file://022-add-close-on-exec-descriptors.patch \
"
SRC_URI[md5sum] = "79a29fe9f79b2f3241d4915767b8c511"
SRC_URI[sha256sum] = "7eeaf3cf0b9d96167a5ba03bf1046e39b4585de1339a55b285e673c06ba415cb"
S = "${WORKDIR}/nfs-server-${PV}/"
inherit autotools
BBCLASSEXTEND = "native nativesdk"
CFLAGS = "-fPIE -fstack-protector-all"
LDFLAGS = "-pie"
EXTRA_OECONF = "--enable-ugid-dynamic \
--enable-ugid-nis \
--enable-host-access \
--with-exports-uid=0 \
--with-exports-gid=0 \
--enable-mount-logging \
--with-devtab=${DESTDIR}${base_prefix}/var/lib/nfs/devtab \
"
do_configure_prepend () {
# Remove pregenerated xdr functions. They use long
# instead of u32, which produces incorrect code on
# 64-bit architectures:
rm -f *_xdr.c
mv aclocal.m4 acinclude.m4
}
# This recipe is intended for -native and -nativesdk builds only,
# not target installs:
python __anonymous () {
import re
pn = bb.data.getVar("PN", d, 1)
if not pn.endswith('-native') and not pn.endswith('-nativesdk'):
raise bb.parse.SkipPackage("unfs-server is intended for native/nativesdk builds only")
}

View File

@ -17,7 +17,10 @@ ac_cv_sizeof_void_p=${ac_cv_sizeof_void_p=4}
ac_cv_sizeof_long_p=${ac_cv_sizeof_long_p=4}
ac_cv_sizeof_float=${ac_cv_sizeof_float=4}
ac_cv_sizeof_off_t=${ac_cv_sizeof_off_t=4}
ac_cv_sizeof_uid_t=${ac_cv_sizeof_uid_t=4}
ac_cv_sizeof_gid_t=${ac_cv_sizeof_gid_t=4}
ac_cv_sizeof_ino_t=${ac_cv_sizeof_ino_t=4}
ac_cv_sizeof_dev_t=${ac_cv_sizeof_dev_t=8}
ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void=yes}
ac_cv_func_getpwuid_r=${ac_cv_func_getpwuid_r=yes}
ac_cv_func_lstat_dereferences_slashed_symlink=${ac_cv_func_lstat_dereferences_slashed_symlink=yes}
@ -274,3 +277,8 @@ moz_cv_size_of_JS_BYTES_PER_DOUBLE=8
#ofono
ac_cv_lib_c_signalfd=${ac_cv_lib_c_signalfd=yes}
#unfs-server
nfsd_cv_broken_setfsuid=${nfsd_cv_broken_setfsuid=0}
nfsd_cv_func_statfs=${nfsd_cv_func_statfs=statfs2_bsize}
nfsd_cv_bsd_signals=${nfsd_cv_bsd_signals=yes}

View File

@ -14,15 +14,22 @@ ac_cv_linux_vers=${ac_cv_linux_vers=2}
ac_cv_need_trio=${ac_cv_need_trio=no}
ac_cv_sizeof_char=${ac_cv_sizeof_char=1}
ac_cv_sizeof_int=${ac_cv_sizeof_int=4}
ac_cv_sizeof_unsigned_int=${ac_cv_sizeof_unsigned_int=4}
ac_cv_sizeof___int64=${ac_cv_sizeof___int64=0}
ac_cv_sizeof_long=${ac_cv_sizeof_long=8}
ac_cv_sizeof_unsigned_long=${ac_cv_sizeof_unsigned_long=8}
ac_cv_sizeof_long_double=${ac_cv_sizeof_long_double=16}
ac_cv_sizeof_long_int=${ac_cv_sizeof_long_int=8}
ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long=8}
ac_cv_sizeof_off_t=${ac_cv_sizeof_off_t=8}
ac_cv_sizeof_short=${ac_cv_sizeof_short=2}
ac_cv_sizeof_unsigned_short=${ac_cv_sizeof_unsigned_short=2}
ac_cv_sizeof_short_int=${ac_cv_sizeof_short_int=2}
ac_cv_sizeof_size_t=${ac_cv_sizeof_size_t=8}
ac_cv_sizeof_uid_t=${ac_cv_sizeof_uid_t=4}
ac_cv_sizeof_gid_t=${ac_cv_sizeof_gid_t=4}
ac_cv_sizeof_ino_t=${ac_cv_sizeof_ino_t=8}
ac_cv_sizeof_dev_t=${ac_cv_sizeof_dev_t=8}
ac_cv_sizeof_void_p=${ac_cv_sizeof_void_p=8}
ac_cv_strerror_r_SUSv3=${ac_cv_strerror_r_SUSv3=no}
bash_cv_have_mbstate_t=${bash_cv_have_mbstate_t=yes}
@ -102,3 +109,8 @@ sudo_cv_uid_t=${sudo_cv_uid_t_len=10}
ac_cv_func_realloc_0_nonnull=${ac_cv_func_realloc_0_nonnull=yes}
lf_cv_sane_realloc=yes
as_cv_unaligned_access=${as_cv_unaligned_access=yes}
#unfs-server
nfsd_cv_broken_setfsuid=${nfsd_cv_broken_setfsuid=0}
nfsd_cv_func_statfs=${nfsd_cv_func_statfs=statfs2_bsize}
nfsd_cv_bsd_signals=${nfsd_cv_bsd_signals=yes}