- Updated to the latest pseudo root release (rel7).

- Added upstream 1.2.1-rc7 patch which fixes:
- Stop ignoring the -o v4 option (bz 529407)
- Allow network protocol roll backs when proto is set in the config file
    (bz 529864)
This commit is contained in:
Steve Dickson 2009-10-26 13:26:04 +00:00
parent cb3fa4ca36
commit 8152f820a8
6 changed files with 378 additions and 271 deletions

View File

@ -1,70 +0,0 @@
diff -up nfs-utils-1.2.0/utils/mount/configfile.c.orig nfs-utils-1.2.0/utils/mount/configfile.c
--- nfs-utils-1.2.0/utils/mount/configfile.c.orig 2009-09-30 13:57:48.647286000 -0400
+++ nfs-utils-1.2.0/utils/mount/configfile.c 2009-09-30 14:50:05.365468000 -0400
@@ -198,6 +198,15 @@ int inline check_vers(char *mopt, char *
}
return 0;
}
+int inline vers_is_set(char *mopt)
+{
+ int i;
+
+ for (i=0; versions[i]; i++)
+ if (strncasecmp(mopt, versions[i], strlen(versions[i])) == 0)
+ return 1;
+ return 0;
+}
/*
* Parse the given section of the configuration
* file to if there are any mount options set.
@@ -256,6 +265,8 @@ conf_parse_mntopts(char *section, char *
conf_free_list(list);
}
+int do_version_negation;
+
/*
* Concatenate options from the configuration file with the
* given options by building a link list of options from the
@@ -326,6 +337,8 @@ char *conf_get_mntopts(char *spec, char
strcat(config_opts, ",");
}
SLIST_FOREACH(entry, &head, entries) {
+ if (vers_is_set(entry->opt))
+ do_version_negation = 1;
strcat(config_opts, entry->opt);
strcat(config_opts, ",");
}
diff -up nfs-utils-1.2.0/utils/mount/stropts.c.orig nfs-utils-1.2.0/utils/mount/stropts.c
--- nfs-utils-1.2.0/utils/mount/stropts.c.orig 2009-09-30 13:57:48.613288000 -0400
+++ nfs-utils-1.2.0/utils/mount/stropts.c 2009-09-30 14:59:56.716461000 -0400
@@ -588,6 +588,7 @@ out_fail:
po_destroy(options);
return result;
}
+extern int do_version_negation;
/*
* This is a single pass through the fg/bg loop.
@@ -607,12 +608,20 @@ static int nfs_try_mount(struct nfsmount
if (errno != EPROTONOSUPPORT)
break;
}
- case 2:
case 3:
+ if (do_version_negation)
+ po_remove_all(mi->options, "nfsvers");
+ case 2:
result = nfs_try_mount_v3v2(mi);
break;
case 4:
result = nfs_try_mount_v4(mi);
+ if (do_version_negation && !result) {
+ if (errno == EPROTONOSUPPORT) {
+ po_remove_all(mi->options, "nfsvers");
+ result = nfs_try_mount_v3v2(mi);
+ }
+ }
break;
default:
errno = EIO;

View File

@ -1,37 +0,0 @@
diff -up nfs-utils-1.2.0/utils/mount/configfile.c.orig nfs-utils-1.2.0/utils/mount/configfile.c
--- nfs-utils-1.2.0/utils/mount/configfile.c.orig 2009-10-02 11:10:01.000000000 -0400
+++ nfs-utils-1.2.0/utils/mount/configfile.c 2009-10-02 11:14:30.000000000 -0400
@@ -185,6 +185,20 @@ void free_all(void)
free(entry);
}
}
+static char *versions[] = {"v2", "v3", "v4", "vers", "nfsvers", NULL};
+int inline check_vers(char *mopt, char *field)
+{
+ int i;
+
+ if (strncmp("mountvers", field, strlen("mountvers") != 0 &&
+ (strcasecmp(field, "nfsvers") == 0 ||
+ strcasecmp(field, "vers") == 0))) {
+ for (i=0; versions[i]; i++)
+ if (strcasestr(mopt, versions[i]) != NULL)
+ return 1;
+ }
+ return 0;
+}
/*
* Parse the given section of the configuration
* file to if there are any mount options set.
@@ -207,6 +221,12 @@ conf_parse_mntopts(char *section, char *
snprintf(buf, BUFSIZ, "%s=", node->field);
if (opts && strcasestr(opts, buf) != NULL)
continue;
+ /*
+ * Protocol verions can be set in a number of ways
+ */
+ if (opts && check_vers(opts, node->field))
+ continue;
+
if (lookup_entry(node->field) != NULL)
continue;
buf[0] = '\0';

View File

@ -1,31 +0,0 @@
diff -up nfs-utils-1.2.0/utils/mount/nfsmount.conf.orig nfs-utils-1.2.0/utils/mount/nfsmount.conf
--- nfs-utils-1.2.0/utils/mount/nfsmount.conf.orig 2009-09-30 11:32:14.148326000 -0400
+++ nfs-utils-1.2.0/utils/mount/nfsmount.conf 2009-09-30 11:35:24.714787000 -0400
@@ -24,12 +24,12 @@
# All reads and writes to the 'nfsserver.foo.com' server
# will be done with 32k (32768 bytes) block sizes.
#
-#[ NFSMount_Global_Options ]
+[ NFSMount_Global_Options ]
# This statically named section defines global mount
# options that can be applied on all NFS mount.
#
-# Protocol Version [2,3]
-# Nfsvers=3
+# Protocol Version [2,3,4]
+Nfsvers=3
# Network Transport [Udp,Tcp,Rdma]
# Proto=Tcp
#
diff -up nfs-utils-1.2.0/utils/mount/stropts.c.orig nfs-utils-1.2.0/utils/mount/stropts.c
--- nfs-utils-1.2.0/utils/mount/stropts.c.orig 2009-09-30 11:32:14.214327000 -0400
+++ nfs-utils-1.2.0/utils/mount/stropts.c 2009-09-30 11:34:35.841020000 -0400
@@ -601,7 +601,7 @@ static int nfs_try_mount(struct nfsmount
switch (mi->version) {
case 0:
- if (linux_version_code() > MAKE_VERSION(2, 6, 31)) {
+ if (linux_version_code() >= MAKE_VERSION(2, 6, 31)) {
errno = 0;
result = nfs_try_mount_v4(mi);
if (errno != EPROTONOSUPPORT)

View File

@ -1,7 +1,6 @@
diff --git a/support/export/xtab.c b/support/export/xtab.c diff -up nfs-utils-1.2.0/support/export/xtab.c.save nfs-utils-1.2.0/support/export/xtab.c
index 3b1dcce..2a43193 100644 --- nfs-utils-1.2.0/support/export/xtab.c.save 2009-10-20 08:46:50.000000000 -0400
--- a/support/export/xtab.c +++ nfs-utils-1.2.0/support/export/xtab.c 2009-10-20 08:47:26.000000000 -0400
+++ b/support/export/xtab.c
@@ -19,7 +19,9 @@ @@ -19,7 +19,9 @@
#include "exportfs.h" #include "exportfs.h"
#include "xio.h" #include "xio.h"
@ -12,7 +11,7 @@ index 3b1dcce..2a43193 100644
static void cond_rename(char *newfile, char *oldfile); static void cond_rename(char *newfile, char *oldfile);
static int static int
@@ -36,6 +38,8 @@ xtab_read(char *xtab, char *lockfn, int is_export) @@ -36,6 +38,8 @@ xtab_read(char *xtab, char *lockfn, int
if ((lockid = xflock(lockfn, "r")) < 0) if ((lockid = xflock(lockfn, "r")) < 0)
return 0; return 0;
setexportent(xtab, "r"); setexportent(xtab, "r");
@ -21,7 +20,7 @@ index 3b1dcce..2a43193 100644
while ((xp = getexportent(is_export==0, 0)) != NULL) { while ((xp = getexportent(is_export==0, 0)) != NULL) {
if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) && if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) &&
!(exp = export_create(xp, is_export!=1))) { !(exp = export_create(xp, is_export!=1))) {
@@ -48,6 +52,8 @@ xtab_read(char *xtab, char *lockfn, int is_export) @@ -48,6 +52,8 @@ xtab_read(char *xtab, char *lockfn, int
case 1: case 1:
exp->m_xtabent = 1; exp->m_xtabent = 1;
exp->m_mayexport = 1; exp->m_mayexport = 1;
@ -30,10 +29,9 @@ index 3b1dcce..2a43193 100644
break; break;
case 2: case 2:
exp->m_exported = -1;/* may be exported */ exp->m_exported = -1;/* may be exported */
diff --git a/support/include/exportfs.h b/support/include/exportfs.h diff -up nfs-utils-1.2.0/support/include/exportfs.h.save nfs-utils-1.2.0/support/include/exportfs.h
index a5cf482..1ad41e2 100644 --- nfs-utils-1.2.0/support/include/exportfs.h.save 2009-10-20 08:46:50.000000000 -0400
--- a/support/include/exportfs.h +++ nfs-utils-1.2.0/support/include/exportfs.h 2009-10-20 08:47:07.000000000 -0400
+++ b/support/include/exportfs.h
@@ -12,6 +12,17 @@ @@ -12,6 +12,17 @@
#include <netdb.h> #include <netdb.h>
#include "nfslib.h" #include "nfslib.h"
@ -52,10 +50,9 @@ index a5cf482..1ad41e2 100644
enum { enum {
MCL_FQDN = 0, MCL_FQDN = 0,
MCL_SUBNETWORK, MCL_SUBNETWORK,
diff --git a/support/include/nfs/export.h b/support/include/nfs/export.h diff -up nfs-utils-1.2.0/support/include/nfs/export.h.save nfs-utils-1.2.0/support/include/nfs/export.h
index f7a99ba..76953ac 100644 --- nfs-utils-1.2.0/support/include/nfs/export.h.save 2009-10-20 08:46:50.000000000 -0400
--- a/support/include/nfs/export.h +++ nfs-utils-1.2.0/support/include/nfs/export.h 2009-10-20 08:47:07.000000000 -0400
+++ b/support/include/nfs/export.h
@@ -24,6 +24,7 @@ @@ -24,6 +24,7 @@
#define NFSEXP_FSID 0x2000 #define NFSEXP_FSID 0x2000
#define NFSEXP_CROSSMOUNT 0x4000 #define NFSEXP_CROSSMOUNT 0x4000
@ -65,10 +62,9 @@ index f7a99ba..76953ac 100644
+#define NFSEXP_ALLFLAGS 0x1FFFF +#define NFSEXP_ALLFLAGS 0x1FFFF
#endif /* _NSF_EXPORT_H */ #endif /* _NSF_EXPORT_H */
diff --git a/support/include/nfslib.h b/support/include/nfslib.h diff -up nfs-utils-1.2.0/support/include/nfslib.h.save nfs-utils-1.2.0/support/include/nfslib.h
index 537a31e..e4777dd 100644 --- nfs-utils-1.2.0/support/include/nfslib.h.save 2009-10-20 08:46:50.000000000 -0400
--- a/support/include/nfslib.h +++ nfs-utils-1.2.0/support/include/nfslib.h 2009-10-20 08:47:07.000000000 -0400
+++ b/support/include/nfslib.h
@@ -88,6 +88,7 @@ struct exportent { @@ -88,6 +88,7 @@ struct exportent {
int e_fslocmethod; int e_fslocmethod;
char * e_fslocdata; char * e_fslocdata;
@ -77,11 +73,9 @@ index 537a31e..e4777dd 100644
struct sec_entry e_secinfo[SECFLAVOR_COUNT+1]; struct sec_entry e_secinfo[SECFLAVOR_COUNT+1];
}; };
diff --git a/support/include/v4root.h b/support/include/v4root.h diff -up /dev/null nfs-utils-1.2.0/support/include/v4root.h
new file mode 100644 --- /dev/null 2009-10-15 16:13:05.251004788 -0400
index 0000000..43b1d2e +++ nfs-utils-1.2.0/support/include/v4root.h 2009-10-20 08:47:16.000000000 -0400
--- /dev/null
+++ b/support/include/v4root.h
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
+/* +/*
+ * Copyright (C) 2009 Red Hat <nfs@redhat.com> + * Copyright (C) 2009 Red Hat <nfs@redhat.com>
@ -98,28 +92,14 @@ index 0000000..43b1d2e
+ +
+extern struct exportent *v4root_chkroot(int , unsigned int , char *); +extern struct exportent *v4root_chkroot(int , unsigned int , char *);
+extern struct exportent *v4root_export(char *, int); +extern struct exportent *v4root_export(char *, int);
+extern struct exportent *v4root_create(char *, nfs_export *, int); +extern struct exportent *v4root_lookup(char *, nfs_export *);
+extern void v4root_free(struct exportent *); +extern void v4root_free(struct exportent *);
+extern void v4root_unset(void), v4root_set(void); +extern void v4root_unset(void), v4root_set(void);
+ +
+#endif /* V4ROOT_H */ +#endif /* V4ROOT_H */
diff --git a/utils/mountd/Makefile.am b/utils/mountd/Makefile.am diff -up nfs-utils-1.2.0/utils/mountd/auth.c.save nfs-utils-1.2.0/utils/mountd/auth.c
index 1e76cf8..eba81fc 100644 --- nfs-utils-1.2.0/utils/mountd/auth.c.save 2009-10-20 08:46:50.000000000 -0400
--- a/utils/mountd/Makefile.am +++ nfs-utils-1.2.0/utils/mountd/auth.c 2009-10-20 08:47:26.000000000 -0400
+++ b/utils/mountd/Makefile.am
@@ -8,7 +8,7 @@ KPREFIX = @kprefix@
sbin_PROGRAMS = mountd
mountd_SOURCES = mountd.c mount_dispatch.c auth.c rmtab.c cache.c \
- svc_run.c fsloc.c mountd.h
+ svc_run.c fsloc.c v4root.c mountd.h
mountd_LDADD = ../../support/export/libexport.a \
../../support/nfs/libnfs.a \
../../support/misc/libmisc.a \
diff --git a/utils/mountd/auth.c b/utils/mountd/auth.c
index 575f207..041a745 100644
--- a/utils/mountd/auth.c
+++ b/utils/mountd/auth.c
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
#include "exportfs.h" #include "exportfs.h"
#include "mountd.h" #include "mountd.h"
@ -142,10 +122,9 @@ index 575f207..041a745 100644
++counter; ++counter;
return counter; return counter;
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c diff -up nfs-utils-1.2.0/utils/mountd/cache.c.save nfs-utils-1.2.0/utils/mountd/cache.c
index e4e2f22..d631570 100644 --- nfs-utils-1.2.0/utils/mountd/cache.c.save 2009-10-20 08:46:50.000000000 -0400
--- a/utils/mountd/cache.c +++ nfs-utils-1.2.0/utils/mountd/cache.c 2009-10-20 08:47:21.000000000 -0400
+++ b/utils/mountd/cache.c
@@ -32,23 +32,12 @@ @@ -32,23 +32,12 @@
#include "xmalloc.h" #include "xmalloc.h"
#include "fsloc.h" #include "fsloc.h"
@ -233,14 +212,14 @@ index e4e2f22..d631570 100644
+ else { + else {
+ /* See if the path is part of the psuedo root */ + /* See if the path is part of the psuedo root */
+ if (v4root_needed && !v4root) + if (v4root_needed && !v4root)
+ v4root = v4root_create(path, exp, TRUE); + v4root = v4root_lookup(path, exp);
continue; continue;
- } else if (strcmp(path, exp->m_export.e_path) != 0) - } else if (strcmp(path, exp->m_export.e_path) != 0)
+ } + }
+ } else if (strcmp(path, exp->m_export.e_path) != 0) { + } else if (strcmp(path, exp->m_export.e_path) != 0) {
+ /* See if the path is part of the psuedo root */ + /* See if the path is part of the psuedo root */
+ if (v4root_needed && !v4root) + if (v4root_needed && !v4root)
+ v4root = v4root_create(path, exp, TRUE); + v4root = v4root_lookup(path, exp);
continue; continue;
+ } + }
if (use_ipaddr) { if (use_ipaddr) {
@ -277,7 +256,7 @@ index e4e2f22..d631570 100644
if (dom) free(dom); if (dom) free(dom);
if (path) free(path); if (path) free(path);
if (he) free(he); if (he) free(he);
@@ -743,7 +776,9 @@ void cache_open(void) @@ -743,7 +776,9 @@ void cache_open(void)
if (!manage_gids && cachelist[i].cache_handle == auth_unix_gid) if (!manage_gids && cachelist[i].cache_handle == auth_unix_gid)
continue; continue;
sprintf(path, "/proc/net/rpc/%s/channel", cachelist[i].cache_name); sprintf(path, "/proc/net/rpc/%s/channel", cachelist[i].cache_name);
@ -288,12 +267,22 @@ index e4e2f22..d631570 100644
} }
} }
diff --git a/utils/mountd/v4root.c b/utils/mountd/v4root.c diff -up nfs-utils-1.2.0/utils/mountd/Makefile.am.save nfs-utils-1.2.0/utils/mountd/Makefile.am
new file mode 100644 --- nfs-utils-1.2.0/utils/mountd/Makefile.am.save 2009-10-20 08:46:50.000000000 -0400
index 0000000..8de2ab6 +++ nfs-utils-1.2.0/utils/mountd/Makefile.am 2009-10-20 08:47:16.000000000 -0400
--- /dev/null @@ -8,7 +8,7 @@ KPREFIX = @kprefix@
+++ b/utils/mountd/v4root.c sbin_PROGRAMS = mountd
@@ -0,0 +1,420 @@
mountd_SOURCES = mountd.c mount_dispatch.c auth.c rmtab.c cache.c \
- svc_run.c fsloc.c mountd.h
+ svc_run.c fsloc.c v4root.c mountd.h
mountd_LDADD = ../../support/export/libexport.a \
../../support/nfs/libnfs.a \
../../support/misc/libmisc.a \
diff -up /dev/null nfs-utils-1.2.0/utils/mountd/v4root.c
--- /dev/null 2009-10-15 16:13:05.251004788 -0400
+++ nfs-utils-1.2.0/utils/mountd/v4root.c 2009-10-20 08:47:33.000000000 -0400
@@ -0,0 +1,414 @@
+/* +/*
+ * Copyright (C) 2009 Red Hat <nfs@redhat.com> + * Copyright (C) 2009 Red Hat <nfs@redhat.com>
+ * + *
@ -334,21 +323,22 @@ index 0000000..8de2ab6
+ +
+extern int get_uuid(char *path, char *uuid, int uuidlen, char *u); +extern int get_uuid(char *path, char *uuid, int uuidlen, char *u);
+ +
+typedef struct _exports_t {
+ TAILQ_ENTRY(_exports_t) list;
+ char *path;
+ void *head;
+ char uuid_len;
+ char uuid[sizeof(uuid_t)];
+ struct exportent p_export;
+} exports_t;
+
+#define HASH_TABLE_SIZE 1021 +#define HASH_TABLE_SIZE 1021
+typedef struct _hash_head { +typedef struct _hash_head {
+ TAILQ_HEAD(export_list, _exports_t) h_head; + TAILQ_HEAD(export_list, _exports_t) h_head;
+} hash_head; +} hash_head;
+hash_head exports_tbl[HASH_TABLE_SIZE]; +hash_head exports_tbl[HASH_TABLE_SIZE];
+ +
+typedef struct _exports_t {
+ TAILQ_ENTRY(_exports_t) list;
+ char *path;
+ hash_head *head;
+ char uuid_len;
+ char uuid[sizeof(uuid_t)];
+ struct exportent p_export;
+} exports_t;
+
+
+ +
+static exports_t *hash_export_lookup(char *, unsigned int); +static exports_t *hash_export_lookup(char *, unsigned int);
+static void hash_export_add(struct _exports_t *, int); +static void hash_export_add(struct _exports_t *, int);
@ -372,6 +362,8 @@ index 0000000..8de2ab6
+void v4root_unset(void); +void v4root_unset(void);
+static int v4root_support(void); +static int v4root_support(void);
+ +
+static struct exportent *v4root_create(char *, nfs_export *);
+
+int v4root_needed; +int v4root_needed;
+ +
+static nfs_export pr_export = { +static nfs_export pr_export = {
@ -467,8 +459,8 @@ index 0000000..8de2ab6
+v4root_set() +v4root_set()
+{ +{
+ nfs_export *exp, *nxt; + nfs_export *exp, *nxt;
+ int i, slcnt; + int i;
+ char *e_path, *path, *ptr, *comp; + char *path, *ptr;
+ char *hostname; + char *hostname;
+ +
+ if (!v4root_needed) + if (!v4root_needed)
@ -482,42 +474,22 @@ index 0000000..8de2ab6
+ for (i = 0; i < MCL_MAXTYPES; i++) { + for (i = 0; i < MCL_MAXTYPES; i++) {
+ for (exp = exportlist[i].p_head; exp; exp = nxt) { + for (exp = exportlist[i].p_head; exp; exp = nxt) {
+ nxt = exp->m_next; + nxt = exp->m_next;
+ e_path = exp->m_export.e_path;
+ hostname = exp->m_export.e_hostname; + hostname = exp->m_export.e_hostname;
+ +
+ slcnt = slash_count(e_path); + path = strdup(exp->m_export.e_path);
+ if (slcnt == 1) + ptr = path + 1;
+ continue; + while ((ptr = strchr(ptr, '/')) != NULL) {
+ slcnt--; /* knock off the leanding '/' */ + *ptr = '\0';
+ + if (export_lookup(hostname, path, 0) == NULL)
+ path = strdup(e_path); + if (v4root_create(path, exp) == NULL) {
+ if (path == NULL) { + xlog(L_WARNING, "v4root_set: Unable to create"
+ xlog(L_WARNING, "v4root_set: No memory for pseudo export"); + "pseudo export for '%s'", path);
+ return;
+ }
+
+ /*
+ * Run through each component of the path to
+ * see if a pseudo export should be created.
+ */
+ comp = path+1;
+ do {
+ if ((ptr = strchr(comp, '/')) != NULL)
+ *ptr = '\0';
+
+ if (export_lookup(hostname, path, 0) == NULL)
+ if (v4root_create(path, exp, FALSE) == NULL) {
+ xlog(L_WARNING,
+ "v4root_set: Unable to create pseudo export"
+ "for '%s'", path);
+ break; + break;
+ } + }
+ *ptr = '/';
+ ptr++;
+ }
+ +
+ if (ptr) {
+ *ptr = '/';
+ comp = ptr+1;
+ }
+ } while (--slcnt > 0);
+ free(path); + free(path);
+ } + }
+ } + }
@ -541,53 +513,33 @@ index 0000000..8de2ab6
+struct exportent * +struct exportent *
+v4root_chkroot(int fsidtype, unsigned int fsidnum, char *fhuuid) +v4root_chkroot(int fsidtype, unsigned int fsidnum, char *fhuuid)
+{ +{
+ struct exportent *p_export = NULL;
+
+ if (pseudo_root == NULL) + if (pseudo_root == NULL)
+ return NULL; + return NULL;
+ +
+ switch(fsidtype) { + if (fsidtype != FSID_NUM)
+ case FSID_NUM: + return NULL;
+ if (fsidnum == _PSEUDO_ROOT_FSID) {
+ p_export = &pseudo_root->m_export;
+ strncpy(p_export->e_path, _PATH_PSEUDO_ROOT,
+ NFS_MAXPATHLEN);
+ }
+ break;
+ }
+ +
+ return p_export; + if (fsidnum != _PSEUDO_ROOT_FSID)
+ return NULL;
+
+ return &pseudo_root->m_export;
+} +}
+ +
+/* +/*
+ * Create a pseudo export, if one does not + * Create a pseudo export, if one does not
+ * already exist. + * already exist.
+ */ + */
+struct exportent * +static struct exportent *
+v4root_create(char *path, nfs_export *exp, int docheck) +v4root_create(char *path, nfs_export *exp)
+{ +{
+ static struct exportent *p_export = NULL; + static struct exportent *p_export = NULL;
+ exports_t *pexp; + exports_t *pexp;
+ char *epath = exp->m_export.e_path;
+ int elen, plen;
+ char uuid_len = sizeof(uuid_t); + char uuid_len = sizeof(uuid_t);
+ char uuid[sizeof(uuid_t)]; + char uuid[sizeof(uuid_t)];
+ +
+ if (pseudo_root == NULL) + if (pseudo_root == NULL)
+ return NULL; + return NULL;
+ +
+ if (docheck) {
+
+ /* Path needs to be a subset of e_path */
+ elen = strlen(epath);
+ plen = strlen(path);
+ if (plen >= elen)
+ return NULL;
+
+ if (memcmp(path, epath, plen) != 0)
+ return NULL;
+ }
+
+ /* Check to see if the export already exists */ + /* Check to see if the export already exists */
+ get_uuid(path, NULL, uuid_len, uuid); + get_uuid(path, NULL, uuid_len, uuid);
+ if ((p_export = v4root_export(uuid, uuid_len)) != NULL) + if ((p_export = v4root_export(uuid, uuid_len)) != NULL)
@ -621,6 +573,37 @@ index 0000000..8de2ab6
+} +}
+ +
+/* +/*
+ * See if the pseudo export exists
+ */
+struct exportent *
+v4root_lookup(char *path, nfs_export *exp)
+{
+ static struct exportent *p_export = NULL;
+ char *epath = exp->m_export.e_path;
+ int elen, plen;
+ char uuid_len = sizeof(uuid_t);
+ char uuid[sizeof(uuid_t)];
+
+ if (pseudo_root == NULL)
+ return NULL;
+
+ /* Path needs to be a subset of e_path */
+ elen = strlen(epath);
+ plen = strlen(path);
+ if (plen >= elen)
+ return NULL;
+
+ if (memcmp(path, epath, plen) != 0)
+ return NULL;
+
+ /* Now to see if the export exists */
+ get_uuid(path, NULL, uuid_len, uuid);
+ p_export = v4root_export(uuid, uuid_len);
+
+ return p_export;
+}
+
+/*
+ * Free a pseudo export + * Free a pseudo export
+ */ + */
+void +void

261
nfs-utils-1.2.1-rc7.patch Normal file
View File

@ -0,0 +1,261 @@
diff --git a/support/include/conffile.h b/support/include/conffile.h
index 672020a..fe23ec2 100644
--- a/support/include/conffile.h
+++ b/support/include/conffile.h
@@ -75,4 +75,11 @@ static inline void upper2lower(char *str)
while ((c = tolower(*str)))
*str++ = c;
}
+
+/*
+ * Default Mount options
+ */
+extern unsigned long config_default_vers;
+extern unsigned long config_default_proto;
+
#endif /* _CONFFILE_H_ */
diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index e347b0e..28b722c 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -20,13 +20,19 @@
#include <config.h>
#endif
#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <errno.h>
#include "xlog.h"
+#include "mount.h"
+#include "parse_opt.h"
+#include "network.h"
#include "conffile.h"
#define KBYTES(x) ((x) * (1024))
@@ -185,6 +191,63 @@ void free_all(void)
free(entry);
}
}
+static char *versions[] = {"v2", "v3", "v4", "vers", "nfsvers", NULL};
+int inline check_vers(char *mopt, char *field)
+{
+ int i;
+
+ if (strncmp("mountvers", field, strlen("mountvers")) != 0) {
+ for (i=0; versions[i]; i++)
+ if (strcasestr(mopt, versions[i]) != NULL)
+ return 1;
+ }
+ return 0;
+}
+
+unsigned long config_default_vers;
+unsigned long config_default_proto;
+/*
+ * Check to see if a default value is being set.
+ * If so, set the appropriate global value which will
+ * be used as the initial value in the server negation.
+ */
+int inline default_value(char *mopt)
+{
+ struct mount_options *options = NULL;
+ int dftlen = strlen("default");
+ char *field;
+
+ if (strncasecmp(mopt, "default", dftlen) != 0)
+ return 0;
+
+ field = mopt + dftlen;
+ if (strncasecmp(field, "proto", strlen("proto")) == 0) {
+ if ((options = po_split(field)) != NULL) {
+ if (!nfs_nfs_protocol(options, &config_default_proto)) {
+ xlog_warn("Unable to set default protocol : %s",
+ strerror(errno));
+ }
+ } else {
+ xlog_warn("Unable to alloc memory for default protocol");
+ }
+ } else if (strncasecmp(field, "vers", strlen("vers")) == 0) {
+ if ((options = po_split(field)) != NULL) {
+ if (!nfs_nfs_version(options, &config_default_vers)) {
+ xlog_warn("Unable to set default version: %s",
+ strerror(errno));
+
+ }
+ } else {
+ xlog_warn("Unable to alloc memory for default version");
+ }
+ } else
+ xlog_warn("Invalid default setting: '%s'", mopt);
+
+ if (options)
+ po_destroy(options);
+
+ return 1;
+}
/*
* Parse the given section of the configuration
* file to if there are any mount options set.
@@ -207,6 +270,12 @@ conf_parse_mntopts(char *section, char *arg, char *opts)
snprintf(buf, BUFSIZ, "%s=", node->field);
if (opts && strcasestr(opts, buf) != NULL)
continue;
+ /*
+ * Protocol verions can be set in a number of ways
+ */
+ if (opts && check_vers(opts, node->field))
+ continue;
+
if (lookup_entry(node->field) != NULL)
continue;
buf[0] = '\0';
@@ -302,15 +371,19 @@ char *conf_get_mntopts(char *spec, char *mount_point,
free_all();
return mount_opts;
}
+
if (mount_opts) {
strcpy(config_opts, mount_opts);
strcat(config_opts, ",");
}
SLIST_FOREACH(entry, &head, entries) {
+ if (default_value(entry->opt))
+ continue;
strcat(config_opts, entry->opt);
strcat(config_opts, ",");
}
- *(strrchr(config_opts, ',')) = '\0';
+ if ((ptr = strrchr(config_opts, ',')) != NULL)
+ *ptr = '\0';
free_all();
if (mount_opts)
diff --git a/utils/mount/network.c b/utils/mount/network.c
index bd621be..e651167 100644
--- a/utils/mount/network.c
+++ b/utils/mount/network.c
@@ -50,6 +50,7 @@
#include "nfsrpc.h"
#include "parse_opt.h"
#include "network.h"
+#include "conffile.h"
#define PMAP_TIMEOUT (10)
#define CONNECT_TIMEOUT (20)
@@ -609,10 +610,19 @@ static int nfs_probe_nfsport(const struct sockaddr *sap, const socklen_t salen,
if (pmap->pm_vers && pmap->pm_prot && pmap->pm_port)
return 1;
- if (nfs_mount_data_version >= 4)
+ if (nfs_mount_data_version >= 4) {
+ const unsigned int *probe_proto = probe_tcp_first;
+
+ /*
+ * If the default proto has been set and
+ * its not TCP, start with UDP
+ */
+ if (config_default_proto && config_default_proto != IPPROTO_TCP)
+ probe_proto = probe_udp_first;
+
return nfs_probe_port(sap, salen, pmap,
- probe_nfs3_first, probe_tcp_first);
- else
+ probe_nfs3_first, probe_proto);
+ } else
return nfs_probe_port(sap, salen, pmap,
probe_nfs2_only, probe_udp_only);
}
@@ -1261,7 +1271,7 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version)
* Returns TRUE if @protocol contains a valid value for this option,
* or FALSE if the option was specified with an invalid value.
*/
-static int
+int
nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol)
{
char *option;
diff --git a/utils/mount/network.h b/utils/mount/network.h
index 402e0a5..7eb89b0 100644
--- a/utils/mount/network.h
+++ b/utils/mount/network.h
@@ -57,6 +57,8 @@ int clnt_ping(struct sockaddr_in *, const unsigned long,
struct mount_options;
int nfs_nfs_version(struct mount_options *options, unsigned long *version);
+int nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol);
+
int nfs_options2pmap(struct mount_options *,
struct pmap *, struct pmap *);
diff --git a/utils/mount/nfsmount.conf b/utils/mount/nfsmount.conf
index f9fcfcb..9b8ff4a 100644
--- a/utils/mount/nfsmount.conf
+++ b/utils/mount/nfsmount.conf
@@ -24,14 +24,29 @@
# All reads and writes to the 'nfsserver.foo.com' server
# will be done with 32k (32768 bytes) block sizes.
#
-#[ NFSMount_Global_Options ]
+[ NFSMount_Global_Options ]
# This statically named section defines global mount
# options that can be applied on all NFS mount.
#
-# Protocol Version [2,3]
-# Nfsvers=3
-# Network Transport [Udp,Tcp,Rdma]
-# Proto=Tcp
+# Protocol Version [2,3,4]
+# This defines the default protocol version which will
+# be used to start the negotiation with the server.
+# Defaultvers=4
+#
+# Setting this option makes it mandatory the server supports the
+# given version. The mount will fail if the given version is
+# not support by the server.
+# Nfsvers=4
+#
+# Network Protocol [udp,tcp,rdma] (Note: values are case sensitive)
+# This defines the default network protocol which will
+# be used to start the negotiation with the server.
+# Defaultproto=tcp
+#
+# Setting this option makes it mandatory the server supports the
+# given network protocol. The mount will fail if the given network
+# protocol is not supported by the server.
+# Proto=tcp
#
# The number of times a request will be retired before
# generating a timeout
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 069bdc1..ceefdb0 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -45,6 +45,7 @@
#include "parse_opt.h"
#include "version.h"
#include "parse_dev.h"
+#include "conffile.h"
#ifndef NFS_PROGRAM
#define NFS_PROGRAM (100003)
@@ -283,6 +284,14 @@ static int nfs_validate_options(struct nfsmount_info *mi)
if (option && strcmp(option, "rdma") == 0)
mi->version = 3;
}
+ /*
+ * Use the default value set in the config file when
+ * the version has not been explicitly set.
+ */
+ if (mi->version == 0 && config_default_vers) {
+ if (config_default_vers < 4)
+ mi->version = config_default_vers;
+ }
if (!nfs_append_sloppy_option(mi->options))
return 0;

View File

@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser
Name: nfs-utils Name: nfs-utils
URL: http://sourceforge.net/projects/nfs URL: http://sourceforge.net/projects/nfs
Version: 1.2.0 Version: 1.2.0
Release: 16%{?dist} Release: 17%{?dist}
Epoch: 1 Epoch: 1
# group all 32bit related archs # group all 32bit related archs
@ -28,12 +28,9 @@ Patch102: nfs-utils-1.2.1-rc3.patch
Patch103: nfs-utils-1.2.1-rc4.patch Patch103: nfs-utils-1.2.1-rc4.patch
Patch104: nfs-utils-1.2.1-rc5.patch Patch104: nfs-utils-1.2.1-rc5.patch
Patch105: nfs-utils-1.2.1-rc6.patch Patch105: nfs-utils-1.2.1-rc6.patch
Patch106: nfs-utils-1.2.0-mount-vers4.patch Patch106: nfs-utils-1.2.1-rc7.patch
Patch200: nfs-utils-1.2.0-v4root-rel6.patch Patch200: nfs-utils-1.2.0-v4root-rel7.patch
Patch300: nfs-utils-1.2.0-mntconf-vers.patch
Patch301: nfs-utils-1.2.0-mntconf-negation.patch
Group: System Environment/Daemons Group: System Environment/Daemons
Provides: exportfs = %{epoch}:%{version}-%{release} Provides: exportfs = %{epoch}:%{version}-%{release}
@ -95,9 +92,6 @@ This package also contains the mount.nfs and umount.nfs program.
%patch200 -p1 %patch200 -p1
%patch300 -p1
%patch301 -p1
# Remove .orig files # Remove .orig files
find . -name "*.orig" | xargs rm -f find . -name "*.orig" | xargs rm -f
@ -268,6 +262,13 @@ fi
%attr(4755,root,root) /sbin/umount.nfs4 %attr(4755,root,root) /sbin/umount.nfs4
%changelog %changelog
* Mon Oct 26 09:23:45 EDT 2009
- Updated to the latest pseudo root release (rel7).
- Added upstream 1.2.1-rc7 patch which fixes:
- Stop ignoring the -o v4 option (bz 529407)
- Allow network protocol roll backs when proto is set
in the config file (bz 529864)
* Mon Oct 5 2009 Steve Dickson <steved@redhat.com> 1.2.0-16 * Mon Oct 5 2009 Steve Dickson <steved@redhat.com> 1.2.0-16
- Fixed a whole where '-o v4' was not overriding the - Fixed a whole where '-o v4' was not overriding the
version in the conf file. version in the conf file.