kern/178103: Correct support of index files for WebNFS exports
Andrey Simonenko
simon at comsys.ntu-kpi.kiev.ua
Wed Apr 24 09:50:02 UTC 2013
>Number: 178103
>Category: kern
>Synopsis: Correct support of index files for WebNFS exports
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Apr 24 09:50:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator: Andrey Simonenko
>Release: FreeBSD 10-CURRENT amd64
>Organization:
>Environment:
>Description:
RFC 2055 describes index files for WebNFS exports. The exports(5) manual
page has description of the -index option, but this option does not work
because of mistakes in mountd and kernel part of the NFS server.
The following change:
1. corrects handling of the -index option in usr.sbin/mountd/mountd.c;
2. corrects fetching of the index file in sys/kern/vfs_export.c;
3. corrects locking if a directory does not have the index file in
sys/nfsserver/nfs_serv.c
This change is for the old NFS server, since new NFS server uses
another API for WebNFS settings and its logic of index files does not
correspond to RFC 2055.
>How-To-Repeat:
Export some file system with options "-public -index 123", then mount it
using NFSv2/3 client and public filehandle. Create a regular file "123"
in some directory and try to read that directory on a client. Do the same,
but create directory "123" with some content. In both cases the content
of a directory with the index file in NFS mounted file system should
be altered.
>Fix:
---------------------------------------------------------------------------
This is for mountd:
--- mountd.c.orig 2013-02-22 11:36:42.000000000 +0200
+++ mountd.c 2013-04-24 11:36:31.000000000 +0300
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD: src/usr.sbin/mountd/
#include <arpa/inet.h>
#include <ctype.h>
+#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <grp.h>
@@ -2232,7 +2233,14 @@ do_opt(char **cpp, char **endcpp, struct
*exflagsp |= (MNT_EXPUBLIC|MNT_EXRDONLY|MNT_EXPORTANON);
opt_flags |= OP_MAPALL;
} else if (cpoptarg && !strcmp(cpopt, "index")) {
+ if (strlen(cpoptarg) > MAXNAMLEN) {
+ syslog(LOG_ERR, "too long file name");
+ return (1);
+ }
ep->ex_indexfile = strdup(cpoptarg);
+ if (ep->ex_indexfile == NULL)
+ out_of_mem();
+ usedarg++;
} else if (!strcmp(cpopt, "quiet")) {
opt_flags |= OP_QUIET;
} else if (cpoptarg && !strcmp(cpopt, "sec")) {
---------------------------------------------------------------------------
This is for the kernel:
diff -ruNp sys.orig/kern/vfs_export.c sys/kern/vfs_export.c
--- sys.orig/kern/vfs_export.c 2013-02-22 11:36:29.000000000 +0200
+++ sys/kern/vfs_export.c 2013-04-12 14:36:18.000000000 +0300
@@ -387,7 +387,7 @@ vfs_setpublicfs(struct mount *mp, struct
* If an indexfile was specified, pull it in.
*/
if (argp->ex_indexfile != NULL) {
- if (nfs_pub.np_index != NULL)
+ if (nfs_pub.np_index == NULL)
nfs_pub.np_index = malloc(MAXNAMLEN + 1, M_TEMP,
M_WAITOK);
error = copyinstr(argp->ex_indexfile, nfs_pub.np_index,
diff -ruNp sys.orig/nfsserver/nfs_serv.c sys/nfsserver/nfs_serv.c
--- sys.orig/nfsserver/nfs_serv.c 2013-03-09 13:01:24.000000000 +0200
+++ sys/nfsserver/nfs_serv.c 2013-04-11 12:07:43.000000000 +0300
@@ -583,7 +583,8 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
vrele(nd.ni_startdir);
nd.ni_startdir = NULL;
ndp = &ind;
- }
+ } else
+ vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY);
error = 0;
}
/*
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list