diff options
Diffstat (limited to 'nfs_wizard')
-rw-r--r-- | nfs_wizard/nfs.wiz | 117 | ||||
-rw-r--r-- | nfs_wizard/scripts/NFSConf.pm | 36 |
2 files changed, 121 insertions, 32 deletions
diff --git a/nfs_wizard/nfs.wiz b/nfs_wizard/nfs.wiz index ffe7c8c6..4373259c 100644 --- a/nfs_wizard/nfs.wiz +++ b/nfs_wizard/nfs.wiz @@ -18,7 +18,18 @@ persistent="false" > </Variable> - + <Variable + name="wiz_nfs_level" + comment="The proxy access control level" + shellVariable="wiz_nfs_level" + defaultValue="2" + > + </Variable> + <Variable + name="wiz_netmask" + shellVariable="wiz_netmask" + > + </Variable> <Page helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-nfs.html" name="welcome" @@ -64,8 +75,7 @@ <Page helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-nfs.html" name="nfs connections" - func="do_it" - jumpPage="congratulations" + jumpPage="ask_level" executionLevel="NORMAL" nextFinish="false" canBack="true" @@ -110,43 +120,100 @@ <Freetext variableName="varwiz_nfs_dir" - alignement="Fill" helpText="Directory:" guiType="textfield" editable="true" - fontName="Default" - fontStyle="bold" - fontSize="14" - proportional="2" - ratio="30" - length="40" > </Freetext> + </Page> + <Page + name="ask_level" + helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-proxy.html" + func="chooser" + executionLevel="NORMAL" + nextFinish="false" + canBack="true" + canCancel="true" + > + + <Target + targetName="congratulations" + jumpIndex="1" + > + </Target> + + <Target + targetName="shownet" + jumpIndex="2" + > + </Target> <Info - name="info31" - alignement="Center" - guiType="label" - fontName="Default" - fontStyle="plain" - fontSize="11" + helpText="Access Control" > </Info> - <TDline - name="line" + + <Info + helpText="NFS can be restricted to a certain ip class" > - </TDline> + </Info> <Info - name="info33" - alignement="Center" - guiType="label" - fontName="Default" - fontStyle="plain" - fontSize="11" + helpText="Choose the level that suits your needs. If you don't know,the Local Network level is usually the most appropriate. Beware that the All level may be not secure." > </Info> + + + <Chooser + name="chooser1" + variableName="wiz_nfs_level" + helpFontName="Default" + > + + <Option + value="1" + description="All - No access restriction" + > + </Option> + + <Option + value="2" + description="Local Network - access for local network (recommended)" + > + </Option> + </Chooser> + </Page> + <Page + name="shownet" + func="do_it" + helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-proxy.html" + jumpPage="congratulations" + executionLevel="NORMAL" + nextFinish="false" + canBack="true" + canCancel="true" + > + + <Info + helpText="Grant access on local network" + > + </Info> + + + <Info + helpText="Access will be allowed for hosts on the network. Here is the information found about your current local network, you can modify it if needed." + > + </Info> + <Freetext + name="f_wiz_squid_mynetw" + fillfunc="network_mask" + variableName="wiz_netmask" + helpText="Authorised network:" + editable="true" + > + </Freetext> + </Page> <Page diff --git a/nfs_wizard/scripts/NFSConf.pm b/nfs_wizard/scripts/NFSConf.pm index 942380d9..673f571a 100644 --- a/nfs_wizard/scripts/NFSConf.pm +++ b/nfs_wizard/scripts/NFSConf.pm @@ -8,20 +8,42 @@ use strict; my $o = DrakconnectConf->new(); +sub network_mask { + my $wiz_ip_server = $o->get_from_known_dev("IP"); + my $mask = $o->get_from_known_dev("Mask"); + $mask = $mask ? $mask : "255.255.255.0"; + $wiz_ip_server = $wiz_ip_server ? $wiz_ip_server : "192.168.1.0"; + "$1.$2.$3.0/$mask" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; +} + +sub chooser { + if ($ENV{wiz_nfs_level} == 1) { + do_it(); + } + $ENV{wiz_nfs_level}; +} + sub do_it { + my $line; my $file = "/etc/exports"; - my $ip = "$1.$2.$3.0" if $o->get_from_known_dev("IP") =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $mask = $o->get_from_known_dev("Mask"); - my $line = "$ENV{wiz_nfs_dir} $ip/$mask(rw,no_root_squash)\n"; + chomp($ENV{wiz_nfs_dir}); + -f $file and cp_af($file, $file.".orig"); + if ($ENV{wiz_nfs_level} == 2) { + my $mask = $o->get_from_known_dev("Mask"); + $line = "$ENV{wiz_nfs_dir} $ENV{wiz_netmask}(rw,no_root_squash)\n"; + } + else { + $line = "$ENV{wiz_nfs_dir} *(rw,no_root_squash)\n"; + } + print "$line\n"; my $t; - foreach (cat_($file)) { - if (/^\s*(?!\#)\s*\$ENV{wiz_nfs_dir}.*/) { + if (/.*(?!\#).*$ENV{wiz_nfs_dir}\s.*/) { $t = $_; last; } } - if ($t) { substInFile { s|$t|\#$&$line|} $file } - else { append_to_file($file, $line) } + if ($t) {substInFile { s|.*(?!\#).*$ENV{wiz_nfs_dir}\s.*|\#$&|} $file } + append_to_file($file, $line); system("/usr/sbin/exportfs -a") } |