2 # Functions for HPUX exports files
5 # Return a list of all the directories currently being exported
8 local (@rv, $pos, $lnum, $h, $o, $line);
9 return @list_exports_cache if (@list_exports_cache);
10 open(EXP, $config{'exports_file'});
12 while($line = <EXP>) {
15 while($line =~ /\\$/) {
16 # continuation character!
22 if ($line =~ /^(#*)\s*(\/\S*)\s+-(.*)$/) {
26 # 'host' includes the hole option string!
27 # for describe_host needed, only
29 parse_options($3, $exp{'options'});
30 $exp{'line'} = $slnum;
31 $exp{'eline'} = $lnum;
33 $exp{'index'} = scalar(@rv);
39 @list_exports_cache = @rv;
40 return @list_exports_cache;
44 # make_exports_line([&export]+)
47 local ($options, $line);
48 $options = join_options($_[0]->{'options'});
49 $line = ($_[0]->{'active'} ? "" : "#").$_[0]->{'dir'};
50 $line .= ($options ? " -".$options : "");
56 # Given a host option string return a human-readable version
59 local ($desc, %options);
60 &parse_options($_[0], \%options);
61 if (defined($options{"ro"}) && $options{"access"} ne "") {
62 $desc = $text{'index_sel_ro'};
64 elsif (defined($options{"ro"}) && !defined($options{"access"})) {
65 $desc = $text{'index_all_ro'};
67 elsif ($options{"rw"} ne "") {
68 $desc = $text{'index_ro_rw'};
70 elsif (!defined($options{"ro"}) && $options{"access"} ne "") {
71 $desc = $text{'index_sel_rw'};
73 elsif (!defined($options{"ro"}) && !defined($options{"rw"}) && !defined($options{"access"})) {
74 $desc = $text{'index_all_rw'};
76 if ($options{"root"} ne "") {
78 $desc .= $text{'index_sel_root'};
83 # more_detail_fields()
84 sub more_detail_fields
86 print " <td><b>", &hlink($text{'edit_async'}, "async"), "</b></td>\n";
87 printf "<td nowrap><input type=radio name=async value=1 %s> %s\n",
88 defined($opts{"async"}) ? "checked" : "", $text{'yes'};
89 printf "<input type=radio name=nfs_bg value=0 %s> %s</td> </tr>\n",
90 defined($opts{"async"}) ? "" : "checked", $text{'no'};
97 print " <td><b>", &hlink($text{'edit_user_access'}, "user_access"), "</b></td>\n";
98 print " <td><b>", &hlink($text{'edit_root_access'}, "root_access"), "</b></td>\n";
99 print " <td><b>", &hlink($text{'edit_anon_access'}, "anon"), "</b></td>\n";
102 $fn = "<font size=-1>"; $efn = "</font>";
104 printf " <td><input type=radio name=user value=1 %s> $text{'edit_sel_ro'}<br>\n",
105 defined($opts{"ro"}) && $opts{"access"} ne "" ? "checked" : "";
106 printf "<input type=radio name=user value=2 %s> $text{'edit_all_ro'}<br>\n",
107 defined($opts{"ro"}) && !defined($opts{"access"}) ? "checked" : "";
108 printf "<input type=radio name=user value=3 %s> $text{'edit_ro_rw'}<br>\n",
109 $opts{"rw"} ne "" ? "checked" : "";
110 printf "<input type=radio name=user value=4 %s> $text{'edit_sel_rw'}<br>\n",
111 !defined($opts{"ro"}) && $opts{"access"} ne "" ? "checked" : "";
112 printf "<input type=radio name=user value=5 %s> $text{'edit_all_rw'}<br>\n",
113 !defined($opts{"ro"}) && !defined($opts{"rw"}) && !defined($opts{"access"}) ? "checked" : "";
115 printf " <td><input type=radio name=root value=1 %s> $text{'edit_none'}<br>\n",
116 defined($opts{"root"}) ? "" : "checked";
120 printf "<input type=radio name=root value=2 %s> $text{'edit_sel_hosts'}<br>\n",
121 $opts{"root"} ne "" ? "checked" : "";
124 if ($in{'new'}) { $opts{"anon"} = getpwnam("nobody"); }
125 printf "<input type=radio name=anon value=1 %s> $text{'edit_anon_noaccess'}<br>\n",
126 $opts{"anon"} == -1 ? "checked" : "";
127 if (defined($opts{"anon"}) && $opts{"anon"} != -1) {
128 $anonuser = getpwuid($opts{'anon'}) ?
129 getpwuid($opts{'anon'}) : $opts{'anon'};
131 printf "<input type=radio name=anon value=2 %s>\n",
132 $opts{"anon"} != -1 ? "checked" : "";
133 print "<input name=anonnam size=8 value=\"$anonuser\"> ",
134 &user_chooser_button("anonnam", 0),"\n";
143 print " <td>$fn<textarea name=ualist rows=6 cols=40 >";
144 if ($opts{"rw"} ne "") {
145 $list = join("\n", split(/:/, $opts{"rw"}));
147 if ($opts{"access"} ne "") {
148 $list = join("\n", split(/:/, $opts{"access"}));
151 print "</textarea>$efn</td>\n";
152 printf " <td>$fn<textarea name=rtlist rows=6 cols=40 >%s</textarea>$efn</td>\n",
153 join("\n", split(/:/, $opts{"root"}));
160 if ($in{user} == 1 || $in{user} == 3 || $in{user} == 4) {
161 &check_hosts($text{'edit_user_access'}, $in{ualist});
162 @ualist = split(/\s+/, $in{ualist});
164 if ($in{root} == 2) {
165 &check_hosts($text{'edit_root_access'}, $in{rtlist});
166 @rtlist = split(/\s+/, $in{rtlist});
169 # Remove from the root list any hosts which not in the user list as well
170 if (($in{user} == 1 || $in{user} == 3 || $in{user} == 4) && $in{root} == 2) {
172 foreach $rth (@tmplist) {
173 if (($idx = &indexof($rth, @ualist)) == -1) {
174 splice(@rtlist, &indexof($rth, @rtlist), 1);
185 # Fill in the options associative array
190 delete($opts{"access"});
191 if ($in{user} == 1) { $opts{"ro"} = ""; $opts{"access"} = join(':', @ualist); }
192 elsif ($in{user} == 2) { $opts{"ro"} = ""; }
193 elsif ($in{user} == 3) { $opts{"rw"} = join(':', @ualist); }
194 elsif ($in{user} == 4) { $opts{"access"} = join(':', @ualist); }
195 elsif ($in{user} == 5) { ; }
197 if ($in{root} == 1) { delete($opts{"root"}); }
198 elsif ($in{root} == 2) { $opts{"root"} = join(':', @rtlist); }
200 if ($in{async} == 1) { $opts{"async"} = ""; }
201 else { delete($opts{"async"}); }
203 if ($in{'anon'} == 1) { $opts{"anon"} = -1; }
204 elsif ($in{'anonnam'} =~ /^[0-9\-]+$/)
205 { $opts{"anon"} = $in{"anonnam"}; }
206 elsif (getpwnam($in{"anonnam"}))
207 { $opts{"anon"} = getpwnam($in{"anonnam"}); }
208 else { $opts{"anon"} = -1; }