~ken-vandine/ubuntu/natty/nfs-utils/1.2.2-4ubuntu1

« back to all changes in this revision

Viewing changes to debian/patches/07-exports-default-options.patch

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2007-01-05 13:38:07 UTC
  • mfrom: (1.2.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20070105133807-0nvljb85umz1gfwu
Tags: 1:1.0.11~git-20060105-2
08-dont-build-getkversion.patch: We missed tools/Makefile.in on last
refresh, so it ended up in the .diff.gz. Fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;
 
8
 static int     first;
 
9
+static int     has_default_opts, has_default_subtree_opts;
 
10
 static int     *squids = NULL, nsquids = 0,
 
11
                *sqgids = NULL, nsqgids = 0;
 
12
 
 
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)
 
21
 struct exportent *
 
22
 getexportent(int fromkernel, int fromexports)
 
23
 {
 
24
-       static struct exportent ee;
 
25
+       static struct exportent ee, def_ee;
 
26
        char            exp[512], *hostname;
 
27
        char            rpath[MAXPATHLEN+1];
 
28
        char            *opt, *sp;
 
29
@@ -78,31 +79,36 @@ getexportent(int fromkernel, int fromexp
 
30
                return NULL;
 
31
 
 
32
        freesquash();
 
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
 
37
-        * Ditto for wgather
 
38
-        */
 
39
-       if (fromkernel) {
 
40
-               ee.e_flags &= ~NFSEXP_ASYNC;
 
41
-               ee.e_flags &= ~NFSEXP_GATHERED_WRITES;
 
42
-       }
 
43
-       ee.e_maptype = CLE_MAP_IDENT;
 
44
-       ee.e_anonuid = 65534;
 
45
-       ee.e_anongid = 65534;
 
46
-       ee.e_squids = NULL;
 
47
-       ee.e_sqgids = NULL;
 
48
-       ee.e_mountpoint = NULL;
 
49
-       ee.e_nsquids = 0;
 
50
-       ee.e_nsqgids = 0;
 
51
 
 
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;
 
56
+       
 
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
 
61
+                * Ditto for wgather
 
62
+                */
 
63
+               if (fromkernel) {
 
64
+                       def_ee.e_flags &= ~NFSEXP_ASYNC;
 
65
+                       def_ee.e_flags &= ~NFSEXP_GATHERED_WRITES;
 
66
+               }
 
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;
 
75
+
 
76
+               ok = getpath(def_ee.e_path, sizeof(def_ee.e_path));
 
77
                if (ok <= 0)
 
78
                        return NULL;
 
79
-               strncpy (ee.m_path, ee.e_path, sizeof (ee.m_path) - 1);
 
80
-               ee.m_path [sizeof (ee.m_path) - 1] = '\0';
 
81
+
 
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));
 
85
        }
 
86
        if (ok < 0) {
 
87
@@ -111,6 +117,23 @@ getexportent(int fromkernel, int fromexp
 
88
                return NULL;
 
89
        }
 
90
        first = 0;
 
91
+               
 
92
+       /* Check for default options */
 
93
+       if (exp[0] == '-') {
 
94
+               if (parseopts(exp + 1, &def_ee, 0, &has_default_subtree_opts) < 0)
 
95
+                       return NULL;
 
96
+               
 
97
+               has_default_opts = 1;
 
98
+
 
99
+               ok = getexport(exp, sizeof(exp));
 
100
+               if (ok < 0) {
 
101
+                       xlog(L_ERROR, "expected client(options...)");
 
102
+                       export_errno = EINVAL;
 
103
+                       return NULL;
 
104
+               }
 
105
+       }
 
106
+
 
107
+       ee = def_ee;
 
108
 
 
109
        /* Check for default client */
 
110
        if (ok == 0)
 
111
@@ -130,7 +153,8 @@ getexportent(int fromkernel, int fromexp
 
112
                }
 
113
                *sp = '\0';
 
114
        } else {
 
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);
 
118
        }
 
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';
 
124
 
 
125
-       if (parseopts(opt, &ee, fromexports) < 0)
 
126
+       if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0)
 
127
                return NULL;
 
128
 
 
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)
 
136
                return NULL;
 
137
        return &ee;
 
138
 }
 
139
@@ -301,7 +325,7 @@ mkexportent(char *hname, char *path, cha
 
140
 int
 
141
 updateexportent(struct exportent *eep, char *options)
 
142
 {
 
143
-       if (parseopts(options, eep, 0) < 0)
 
144
+       if (parseopts(options, eep, 0, NULL) < 0)
 
145
                return 0;
 
146
        return 1;
 
147
 }
 
148
@@ -310,7 +334,7 @@ updateexportent(struct exportent *eep, c
 
149
  * Parse option string pointed to by cp and set mount options accordingly.
 
150
  */
 
151
 static int
 
152
-parseopts(char *cp, struct exportent *ep, int warn)
 
153
+parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr)
 
154
 {
 
155
        int     had_subtree_opt = 0;
 
156
        char    *flname = efname?efname:"command line";
 
157
@@ -461,6 +485,8 @@ out:
 
158
 
 
159
                                flname, flline,
 
160
                                ep->e_hostname, ep->e_path);
 
161
+       if (had_subtree_opt_ptr)
 
162
+               *had_subtree_opt_ptr = had_subtree_opt;
 
163
 
 
164
        return 1;
 
165
 }
 
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.
 
173
 .PP
 
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
 
177
+only.
 
178
+.PP
 
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)
 
188
 .fi
 
189
 .PP
 
190
@@ -515,6 +521,9 @@ under the nobody account. The
 
191
 .I insecure 
 
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.
 
199
 '''.SH CAVEATS