3 # Allow editing of one export to a client
5 require './exports-lib.pl';
8 local $nfsv = nfs_max_version("localhost");
10 &ui_print_header(undef, $text{'create_title'}, "", "create_export");
11 $via_pfs = ($nfsv == 4) ? 1 : 0;
12 $exp->{"pfs"} = "/export";
15 &ui_print_header(undef, $text{'edit_title'}, "", "edit_export");
16 @exps = &list_exports();
17 $exp = $exps[$in{'idx'}];
18 %opts = %{$exp->{'options'}};
21 # WebNFS doesn't exist on Linux
22 local $linux = ($gconfig{'os_type'} =~ /linux/i) ? 1 : 0;
24 print "<script type=\"text/javascript\">\n";
25 print "function enable_sec(level) {\n";
26 print " if (level) {\n";
27 print " document.forms[0].sec[1].disabled=0;\n";
28 print " document.forms[0].sec[2].disabled=0;\n";
30 print " document.forms[0].sec[1].disabled=1;\n";
31 print " document.forms[0].sec[2].disabled=1;\n";
32 print " document.forms[0].sec[0].checked=1;\n";
34 print "function enable_pfs(enable) {\n";
35 print" set_pfs_dir();\n";
36 print "if (enable == 1) {\n";
37 print " document.forms[0].pfs.disabled=0;\n";
38 print " document.forms[0].pfs_button.disabled=0;\n";
39 print " document.forms[0].pfs_dir.disabled=0;\n";
41 print " document.forms[0].pfs.disabled=1;\n";
42 print " document.forms[0].pfs_button.disabled=1;\n";
43 print " document.forms[0].pfs_dir.disabled=1;\n";
46 print "function set_pfs_dir() {\n";
47 print " var pfs = document.forms[0].pfs.value;\n";
48 print " var dir = document.forms[0].dir.value;\n";
49 print " if (document.forms[0].via_pfs[0].checked == 0) {\n";
50 print " document.forms[0].pfs_dir.value = dir; }\n";
52 print " var reg = /\\/\$/;\n";
53 print " dir = dir.replace(reg, \"\");\n";
54 print " dir = dir.substring(dir.lastIndexOf(\"/\"));\n";
55 print " document.forms[0].pfs_dir.value = pfs + dir; }\n";
57 print "window.onload = function() {\n";
58 print " enable_pfs(document.forms[0].via_pfs[0].checked);\n";
59 print " if (document.forms[0].auth[0].checked == 1) {\n";
60 print " enable_sec(0); }\n";
62 print " enable_sec(1); }\n";
63 print " set_pfs_dir();\n";
67 print "<form action=save_export.cgi>\n";
68 print "<input type=hidden name=new value='$in{'new'}'>\n";
69 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
71 print "<table border width=100%>\n";
72 print "<tr $tb> <td><b>$text{'edit_details'}</b></td> </tr>\n";
73 print "<tr $cb> <td><table>\n";
75 # Show NFS pseudofilesystem (NFSv4)
77 print "<tr> <td>",&hlink("<b>$text{'edit_nfs_vers'}</b>","vers"),"</td>\n";
78 printf "<td colspan=3><input type=radio name=via_pfs value=1 %s onclick=enable_pfs(1)> 4\n",
79 $via_pfs ? "checked" : "";
80 printf "<input type=radio name=via_pfs value=0 %s onclick=enable_pfs(0)> 3 (or lower)</td> </tr>\n",
81 $via_pfs ? "" : "checked";
83 print "<tr> <td>",&hlink("<b>$text{'edit_pfs'}</b>","pfs"),"</td>\n";
84 printf "<td colspan=3><input name=pfs size=40 value=\"$exp->{'pfs'}\" onkeyup=set_pfs_dir()>";
85 print &file_chooser_button2("pfs", 1, "pfs_button", ($via_pfs == 0)),"</td> </tr>\n";
87 printf "<tr><td><input type=hidden name=via_pfs value=0></td></tr>\n";
90 # Show directory input
91 print "<tr> <td>",&hlink("<b>$text{'edit_dir'}</b>","dir"),"</td>\n";
92 print "<td colspan=3><input name=dir size=40 value=\"$exp->{'dir'}\" onkeyup=set_pfs_dir()>",
93 &file_chooser_button("dir", 1);
95 print "$text{'edit_in'} <input style=\"background: rgb(238, 238, 238)\" name=pfs_dir size=40 readonly></td> </tr>\n";
99 print "<tr> <td>",&hlink("<b>$text{'edit_active'}</b>","active"),"</td>\n";
100 printf "<td colspan=3><input type=radio name=active value=1 %s> $text{'yes'}\n",
101 $in{'new'} || $exp->{'active'} ? 'checked' : '';
102 printf "<input type=radio name=active value=0 %s> $text{'no'}</td> </tr>\n",
103 $in{'new'} || $exp->{'active'} ? '' : 'checked';
105 # Show input for export to
106 local $h = $exp->{'host'};
107 if ($h eq "=public") { $mode = 0; }
108 elsif ($h =~ /^gss\//) {$mode = 5; }
109 elsif ($h =~ /^\@(.*)/) { $mode = 1; $netgroup = $1; }
110 elsif ($h =~ /^(\S+)\/(\S+)$/) { $mode = 2; $network = $1; $netmask = $2; }
111 elsif ($h eq "") { $mode = 3; }
112 else { $mode = 4; $host = $h; }
113 # and authentication input
114 local $auth = "", $sec = "";
115 if ($h =~ /^gss\/krb5/) {
117 if ($h =~ /i$/) { $sec = "i"; }
118 if ($h =~ /p$/) { $sec = "p"; }
121 print "<tr><td rowspan=8 valign=top>",&hlink("<b>$text{'edit_to'}</b>","client");
123 print "<br>",&hlink("$text{'edit_auth'}","auth"),"</td>\n";
125 printf "<td rowspan=5><input type=radio name=auth value=0 %s onclick=enable_sec(0)> sys</td>\n",
126 ($auth eq "") ? "checked" : "";
128 printf "<td><input type=hidden name=auth value=0></td>\n";
130 printf "<tr><td><input type=radio name=mode value=3 %s> $text{'edit_all'} </td>\n",
131 $mode == 3 ? "checked" : "";
133 printf "<td colspan=2><input type=radio name=mode value=4 %s> $text{'edit_host'}\n",
134 $mode == 4 ? "checked" : "";
135 print "<input name=host size=35 value='$host'></td> </tr>\n";
137 printf "<tr><td><input type=radio name=mode value=0 %s %s> $text{'edit_webnfs'}</td>\n",
138 $mode == 0 ? "checked" : "", $linux ? "disabled" : "";
140 printf "<td colspan=2><input type=radio name=mode value=1 %s> $text{'edit_netgroup'}\n",
141 $mode == 1 ? "checked" : "";
142 print "<input name=netgroup size=25 value='$netgroup'></td> </tr>\n";
144 printf "<tr><td colspan=3><input type=radio name=mode value=2 %s> IPv4 $text{'edit_network'}\n",
145 $mode == 2 ? "checked" : "";
146 print "<input name=network size=15 value='$network'>\n";
147 print "$text{'edit_netmask'} <input name=netmask size=15 value='$netmask'></td> </tr>\n";
149 printf "<tr><td colspan=3><input type=radio name=mode value=6 %s disabled> IPv6 $text{'edit_address'}\n",
150 $mode == 6 ? "checked" : "";
151 print "<input name=address size=39 value='$address' disabled>\n";
152 print "$text{'edit_prefix'}<input name=prefix size=2 value='$prefix' disabled></td> </tr>\n";
155 printf "<tr><td colspan=3><input type=radio name=auth value=1 %s onclick=enable_sec(1)> krb5</td></tr>",
156 ($auth eq "krb5") ? "checked" : "";
157 printf "<tr><td colspan=3><input type=radio name=auth value=2 %s disabled> lipkey</td></tr>\n",
158 ($auth eq "lipkey") ? "checked" : "";
159 printf "<tr><td colspan=3><input type=radio name=auth value=3 %s disabled> spkm-3</td></tr>\n",
160 ($auth eq "spkm") ? "checked" : "";
162 # Show security level input
163 print "<tr> <td>", &hlink("<b>$text{'edit_sec'}</b>", "sec"), "</td>\n";
164 printf "<td nowrap colspan=3><input type=radio name=sec value=0 %s> $text{'config_none'}\n",
165 ($sec eq "") ? "checked" : "";
166 printf "<input type=radio name=sec value=1 %s> $text{'edit_integrity'}\n",
167 ($sec eq "i") ? "checked" : "";
168 printf "<input type=radio name=sec value=2 %s> $text{'edit_privacy'}</td></tr>\n",
169 ($sec eq "p") ? "checked" : "";
172 print "</table></td></tr></table><p>\n";
173 print "<table border width=100%>\n";
174 print "<tr $tb> <td><b>$text{'edit_security'}</b></td> </tr>\n";
175 print "<tr $cb> <td><table width=100%>\n";
177 # Show read-only input
178 print "<tr> <td>",&hlink("<b>$text{'edit_ro'}</b>","ro"),"</td>\n";
179 printf "<td><input type=radio name=ro value=1 %s> $text{'yes'}\n",
180 defined($opts{'rw'}) ? "" : "checked";
181 printf "<input type=radio name=ro value=0 %s> $text{'no'}</td>\n",
182 defined($opts{'rw'}) ? "checked" : "";
184 # Show input for secure port
185 print "<td>",&hlink("<b>$text{'edit_insecure'}</b>","insecure"),"</td>\n";
186 printf "<td><input type=radio name=insecure value=0 %s> $text{'yes'}\n",
187 defined($opts{'insecure'}) ? "" : "checked";
188 printf "<input type=radio name=insecure value=1 %s> $text{'no'}</td> </tr>\n",
189 defined($opts{'insecure'}) ? "checked" : "";
191 # Show subtree check input
192 print "<tr> <td>",&hlink("<b>$text{'edit_subtree_check'}</b>","subtree_check"),"</td>\n";
193 printf "<td><input type=radio name=no_subtree_check value=1 %s> $text{'yes'}\n",
194 defined($opts{'no_subtree_check'}) ? "checked" : "";
195 printf "<input type=radio name=no_subtree_check value=0 %s> $text{'no'}\n",
196 defined($opts{'no_subtree_check'}) ? "" : "checked";
199 # Show nohide check input
200 print "<td>",&hlink("<b>$text{'edit_hide'}</b>","hide"),"</td>\n";
201 printf "<td><input type=radio name=nohide value=0 %s> $text{'yes'}\n",
202 defined($opts{'nohide'}) ? "" : "checked";
203 printf "<input type=radio name=nohide value=1 %s> $text{'no'}</td> </tr>\n",
204 defined($opts{'nohide'}) ? "checked" : "";
207 my $sync = defined($opts{'sync'}) ? 1 : defined($opts{'async'}) ? 2 : 0;
208 print "<tr> <td>",&hlink("<b>$text{'edit_sync'}</b>","sync"),"</td>\n<td colspan=3>";
209 foreach $s (1, 2, 0) {
210 printf "<input type=radio name=sync value=%d %s> %s\n",
211 $s, $sync == $s ? "checked" : "", $text{'edit_sync'.$s};
213 print "</td> </tr>\n";
215 # Show root trust input
216 print "<tr> <td>",&hlink("<b>$text{'edit_squash'}</b>","squash"),"</td> <td colspan=3>\n";
217 printf "<input type=radio name=squash value=0 %s> $text{'edit_everyone'}\n",
218 defined($opts{'no_root_squash'}) ? "checked" : "";
219 printf "<input type=radio name=squash value=1 %s> $text{'edit_except'}\n",
220 !defined($opts{'no_root_squash'}) &&
221 !defined($opts{'all_squash'}) ? "checked" : "";
222 printf "<input type=radio name=squash value=2 %s> $text{'edit_nobody'}\n";
223 defined($opts{'all_squash'}) ? "checked" : "";
224 print "</td> </tr>\n";
226 # Show untrusted user input
227 print "<tr> <td>",&hlink("<b>$text{'edit_anonuid'}</b>","anonuid"),"</td> <td>\n";
228 printf "<input type=radio name=anonuid_def value=1 %s> $text{'edit_default'}\n",
229 defined($opts{'anonuid'}) ? "" : "checked";
230 printf "<input type=radio name=anonuid_def value=0 %s>\n",
231 defined($opts{'anonuid'}) ? "checked" : "";
232 printf "<input name=anonuid size=8 value=\"%s\">\n",
233 $opts{'anonuid'} ? getpwuid($opts{'anonuid'}) : "";
234 print &user_chooser_button("anonuid", 0),"</td>\n";
236 # Show untrusted group input
237 print "<td>",&hlink("<b>$text{'edit_anongid'}</b>","anongid"),"</td> <td>\n";
238 printf "<input type=radio name=anongid_def value=1 %s> $text{'edit_default'}\n",
239 defined($opts{'anongid'}) ? "" : "checked";
240 printf "<input type=radio name=anongid_def value=0 %s>\n",
241 defined($opts{'anongid'}) ? "checked" : "";
242 printf "<input name=anongid size=8 value=\"%s\">\n",
243 $opts{'anongid'} ? getgrgid($opts{'anongid'}) : "";
244 print &group_chooser_button("anongid", 0),"</td> </tr>\n";
246 print "<tr $tb> <td colspan=4><b>$text{'edit_v2opts'}</b></td> </tr>\n";
248 # Show input for relative symlinks
249 print "<tr> <td>",&hlink("<b>$text{'edit_relative'}</b>","link_relative"),"</td>\n";
250 printf "<td><input type=radio name=link_relative value=1 %s> $text{'yes'}\n",
251 defined($opts{'link_relative'}) ? "checked" : "";
252 printf "<input type=radio name=link_relative value=0 %s> $text{'no'}</td>\n",
253 defined($opts{'link_relative'}) ? "" : "checked";
255 # Show deny access input
256 print "<td>",&hlink("<b>$text{'edit_noaccess'}</b>","noaccess"),"</td>\n";
257 printf "<td><input type=radio name=noaccess value=1 %s> $text{'yes'}\n",
258 defined($opts{'noaccess'}) ? "checked" : "";
259 printf "<input type=radio name=noaccess value=0 %s> $text{'no'}</td> </tr>\n",
260 defined($opts{'noaccess'}) ? "" : "checked";
262 # Show untrusted UIDs input
263 print "<tr> <td>",&hlink("<b>$text{'edit_uids'}</b>","squash_uids"),"</td> <td>\n";
264 printf "<input type=radio name=squash_uids_def value=1 %s> $text{'edit_none'}\n",
265 $opts{'squash_uids'} ? "" : "checked";
266 printf "<input type=radio name=squash_uids_def value=0 %s>\n",
267 $opts{'squash_uids'} ? "checked" : "";
268 printf "<input name=squash_uids size=15 value=\"%s\"></td>\n",
269 $opts{'squash_uids'};
271 # Show untrusted GIDs input
272 print "<td>",&hlink("<b>$text{'edit_gids'}</b>","squash_gids"),"</td> <td>\n";
273 printf "<input type=radio name=squash_gids_def value=1 %s> $text{'edit_none'}\n",
274 $opts{'squash_gids'} ? "" : "checked";
275 printf "<input type=radio name=squash_gids_def value=0 %s>\n",
276 $opts{'squash_gids'} ? "checked" : "";
277 printf "<input name=squash_gids size=15 value=\"%s\"></td> </tr>\n",
278 $opts{'squash_gids'};
280 print "</table></td></tr></table>\n";
282 print "<table width=100%><tr>\n";
283 print "<td><input type=submit value=\"$text{'save'}\"></td>\n";
284 print "<td align=right><input type=submit name=delete ",
285 "value=\"$text{'delete'}\"></td>\n";
286 print "</tr></table>\n";
289 print "<input type=hidden name=new value=1>\n";
290 print "<input type=submit value=\"$text{'create'}\">\n";
293 &ui_print_footer("", $text{'index_return'});