[RFC,PATCH 4/4] Dynamic Pseudo Root
Steve Dickson
SteveD at redhat.com
Fri Dec 7 14:23:48 EST 2007
commit 17ed91b63336a554e2cfc39865e6982d58b1c92f
Author: Steve Dickson <steved at redhat.com>
Date: Tue Dec 4 06:38:22 2007 -0500
Fixed memory leak with memory returned by v4root_chkroot()
Make sure '/' gets correctly mapped in nfsd_export()
Signed-off-by: Steve Dickson <steved at redhat.com>
---
support/export/v4root.c | 20 +++++++++++++++-----
support/include/mounts.h | 1 -
utils/mountd/cache.c | 22 +++++++++++++++++-----
3 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/support/export/v4root.c b/support/export/v4root.c
index 77f8904..3187b8e 100644
--- a/support/export/v4root.c
+++ b/support/export/v4root.c
@@ -1,7 +1,7 @@
/*
* support/export/v4root.c
*
- * Routines that create and destroy v4 psuedo roots
+ * Routines that create and destroy v4 psuedo root
*
*/
@@ -130,7 +130,7 @@ v4root_mkroot()
void
v4root_create()
{
- nfs_export *exp, *nxt, *root;
+ nfs_export *exp, *nxt;
char path[BUFSIZ];
int i;
@@ -167,7 +167,6 @@ struct exportent *
v4root_chkroot(int fsidtype, unsigned int fsidnum, char *fhuuid)
{
struct exportent *psuedo_root = NULL;
- char u[16];
if (psuedo_export.export == NULL)
return NULL;
@@ -193,9 +192,20 @@ v4root_maproot(char *path)
return NULL;
if (strcmp(path, _PATH_PSEUDO_ROOT))
- mpath = path + strlen(_PATH_PSEUDO_ROOT);
+ mpath = strdup(path + strlen(_PATH_PSEUDO_ROOT));
else
- mpath = strlen(_PATH_PSEUDO_ROOT);
+ mpath = strdup(_PATH_PSEUDO_ROOT);
return mpath;
}
+struct exportent *
+v4root_isroot(char *path)
+{
+ if (psuedo_export.export == NULL)
+ return NULL;
+
+ if (strcmp(path, _PATH_PSEUDO_ROOT))
+ return NULL;
+
+ return psuedo_export.export;
+}
diff --git a/support/include/mounts.h b/support/include/mounts.h
index 4406150..0ad1a81 100644
--- a/support/include/mounts.h
+++ b/support/include/mounts.h
@@ -14,7 +14,6 @@
#endif
#include <sys/mount.h>
-//#include "misc.h"
struct mountargs {
const char *spec;
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index f367d2b..107d9d1 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -49,6 +49,9 @@ int cache_export_ent(char *domain, struct exportent *exp, char *p);
char *lbuf = NULL;
int lbuflen = 0;
extern int use_ipaddr;
+extern struct exportent *v4root_chkroot(int , unsigned int , char *);
+extern char *v4root_maproot(char *);
+extern struct exportent *v4root_isroot(char *);
void auth_unix_ip(FILE *f)
{
@@ -596,7 +599,7 @@ void nfsd_export(FILE *f)
char *cp;
int i;
- char *dom, *path, *mpath;
+ char *dom, *path, *mpath, *v4root=NULL;
nfs_export *exp, *found = NULL;
int found_type = 0;
struct in_addr addr;
@@ -620,11 +623,17 @@ void nfsd_export(FILE *f)
if (qword_get(&cp, path, strlen(lbuf)) <= 0)
goto out;
- if ((mpath = v4root_maproot(path)) == NULL)
- mpath = path;
-
auth_reload();
+ /* See if path need to be mapped to the to the pseudo root */
+ if ((v4root = v4root_maproot(path))){
+ /* If its the actual pseudo root, no need to search the table */
+ if ((found = (nfs_export *)v4root_isroot(path)))
+ goto found;
+ mpath = v4root;
+ } else
+ mpath = path;
+
/* now find flags for this export point in this domain */
for (i=0 ; i < MCL_MAXTYPES; i++) {
for (exp = exportlist[i]; exp; exp = exp->m_next) {
@@ -642,6 +651,7 @@ void nfsd_export(FILE *f)
continue;
} else if (strcmp(mpath, exp->m_export.e_path) != 0)
continue;
+
if (use_ipaddr) {
if (he == NULL) {
if (!inet_aton(dom, &addr))
@@ -678,8 +688,9 @@ void nfsd_export(FILE *f)
}
}
}
-
+found:
if (found) {
+ xlog(D_CALL, "nfsd_export: found: '%s'", path);
if (dump_to_cache(f, dom, path, &found->m_export) < 0) {
xlog(L_WARNING,
"Cannot export %s, possibly unsupported filesystem"
@@ -692,6 +703,7 @@ void nfsd_export(FILE *f)
out:
if (dom) free(dom);
if (path) free(path);
+ if (v4root) free(v4root);
if (he) free(he);
}
More information about the NFSv4
mailing list