1
Index: nfs-utils-1.0.10/support/nfs/exports.c
2
===================================================================
3
--- nfs-utils-1.0.10.orig/support/nfs/exports.c
4
+++ nfs-utils-1.0.10/support/nfs/exports.c
5
@@ -39,12 +39,13 @@ int export_errno;
6
static char *efname = NULL;
7
static XFILE *efp = NULL;
9
+static int has_default_opts, has_default_subtree_opts;
10
static int *squids = NULL, nsquids = 0,
11
*sqgids = NULL, nsqgids = 0;
13
static int getexport(char *exp, int len);
14
static int getpath(char *path, int len);
15
-static int parseopts(char *cp, struct exportent *ep, int warn);
16
+static int parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr);
17
static int parsesquash(char *list, int **idp, int *lenp, char **ep);
18
static int parsenum(char **cpp);
19
static int parsemaptype(char *type);
20
@@ -68,7 +69,7 @@ setexportent(char *fname, char *type)
22
getexportent(int fromkernel, int fromexports)
24
- static struct exportent ee;
25
+ static struct exportent ee, def_ee;
26
char exp[512], *hostname;
27
char rpath[MAXPATHLEN+1];
29
@@ -78,31 +79,36 @@ getexportent(int fromkernel, int fromexp
33
- ee.e_flags = EXPORT_DEFAULT_FLAGS;
34
- /* some kernels assume the default is sync rather than
35
- * async. More recent kernels always report one or other,
36
- * but this test makes sure we assume same as kernel
40
- ee.e_flags &= ~NFSEXP_ASYNC;
41
- ee.e_flags &= ~NFSEXP_GATHERED_WRITES;
43
- ee.e_maptype = CLE_MAP_IDENT;
44
- ee.e_anonuid = 65534;
45
- ee.e_anongid = 65534;
48
- ee.e_mountpoint = NULL;
52
if (first || (ok = getexport(exp, sizeof(exp))) == 0) {
53
- ok = getpath(ee.e_path, sizeof(ee.e_path));
54
+ has_default_opts = 0;
55
+ has_default_subtree_opts = 0;
57
+ def_ee.e_flags = EXPORT_DEFAULT_FLAGS;
58
+ /* some kernels assume the default is sync rather than
59
+ * async. More recent kernels always report one or other,
60
+ * but this test makes sure we assume same as kernel
64
+ def_ee.e_flags &= ~NFSEXP_ASYNC;
65
+ def_ee.e_flags &= ~NFSEXP_GATHERED_WRITES;
67
+ def_ee.e_maptype = CLE_MAP_IDENT;
68
+ def_ee.e_anonuid = 65534;
69
+ def_ee.e_anongid = 65534;
70
+ def_ee.e_squids = NULL;
71
+ def_ee.e_sqgids = NULL;
72
+ def_ee.e_mountpoint = NULL;
73
+ def_ee.e_nsquids = 0;
74
+ def_ee.e_nsqgids = 0;
76
+ ok = getpath(def_ee.e_path, sizeof(def_ee.e_path));
79
- strncpy (ee.m_path, ee.e_path, sizeof (ee.m_path) - 1);
80
- ee.m_path [sizeof (ee.m_path) - 1] = '\0';
82
+ strncpy (def_ee.m_path, def_ee.e_path, sizeof (def_ee.m_path) - 1);
83
+ def_ee.m_path [sizeof (def_ee.m_path) - 1] = '\0';
84
ok = getexport(exp, sizeof(exp));
87
@@ -111,6 +117,23 @@ getexportent(int fromkernel, int fromexp
92
+ /* Check for default options */
93
+ if (exp[0] == '-') {
94
+ if (parseopts(exp + 1, &def_ee, 0, &has_default_subtree_opts) < 0)
97
+ has_default_opts = 1;
99
+ ok = getexport(exp, sizeof(exp));
101
+ xlog(L_ERROR, "expected client(options...)");
102
+ export_errno = EINVAL;
109
/* Check for default client */
111
@@ -130,7 +153,8 @@ getexportent(int fromkernel, int fromexp
115
- xlog(L_WARNING, "No options for %s %s: suggest %s(sync) to avoid warning", ee.e_path, exp, exp);
116
+ if (!has_default_opts)
117
+ xlog(L_WARNING, "No options for %s %s: suggest %s(sync) to avoid warning", ee.e_path, exp, exp);
119
if (strlen(hostname) >= sizeof(ee.e_hostname)) {
120
syntaxerr("client name too long");
121
@@ -140,7 +164,7 @@ getexportent(int fromkernel, int fromexp
122
strncpy(ee.e_hostname, hostname, sizeof (ee.e_hostname) - 1);
123
ee.e_hostname[sizeof (ee.e_hostname) - 1] = '\0';
125
- if (parseopts(opt, &ee, fromexports) < 0)
126
+ if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0)
129
/* resolve symlinks */
130
@@ -293,7 +317,7 @@ mkexportent(char *hname, char *path, cha
131
ee.e_path[sizeof (ee.e_path) - 1] = '\0';
132
strncpy (ee.m_path, ee.e_path, sizeof (ee.m_path) - 1);
133
ee.m_path [sizeof (ee.m_path) - 1] = '\0';
134
- if (parseopts(options, &ee, 0) < 0)
135
+ if (parseopts(options, &ee, 0, NULL) < 0)
139
@@ -301,7 +325,7 @@ mkexportent(char *hname, char *path, cha
141
updateexportent(struct exportent *eep, char *options)
143
- if (parseopts(options, eep, 0) < 0)
144
+ if (parseopts(options, eep, 0, NULL) < 0)
148
@@ -310,7 +334,7 @@ updateexportent(struct exportent *eep, c
149
* Parse option string pointed to by cp and set mount options accordingly.
152
-parseopts(char *cp, struct exportent *ep, int warn)
153
+parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr)
155
int had_subtree_opt = 0;
156
char *flname = efname?efname:"command line";
157
@@ -461,6 +485,8 @@ out:
160
ep->e_hostname, ep->e_path);
161
+ if (had_subtree_opt_ptr)
162
+ *had_subtree_opt_ptr = had_subtree_opt;
166
Index: nfs-utils-1.0.10/utils/exportfs/exports.man
167
===================================================================
168
--- nfs-utils-1.0.10.orig/utils/exportfs/exports.man
169
+++ nfs-utils-1.0.10/utils/exportfs/exports.man
170
@@ -22,6 +22,11 @@ client may be immediately followed by a
171
list of export options for that client. No whitespace is permitted
172
between a client and its option list.
174
+Also, each line may have one or more specifications for default options
175
+after the path name, in the form of a dash ("\-") followed by an option
176
+list. The option list is used for all subsequent exports on that line
179
Blank lines are ignored. A pound sign ("#") introduces a comment to the
180
end of the line. Entries may be continued across newlines using a
181
backslash. If an export name contains spaces it should be quoted using
182
@@ -502,6 +507,7 @@ is supposedly that of user joe).
183
/usr *.local.domain(ro) @trusted(rw)
184
/home/joe pc001(rw,all_squash,anonuid=150,anongid=100)
185
/pub (ro,insecure,all_squash)
186
+/srv/www \-sync,rw server @trusted @external(ro)
187
'''/pub/private (noaccess)
190
@@ -515,6 +521,9 @@ under the nobody account. The
192
option in this entry also allows clients with NFS implementations that
193
don't use a reserved port for NFS.
194
+The sixth line exports a directory read-write to the machine 'server'
195
+as well as the `@trusted' netgroup, and read-only to netgroup `@external',
196
+all three mounts with the `sync' option enabled.
197
''' The last line denies all NFS clients
198
'''access to the private directory.