summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2004-01-27 10:35:03 +0000
committerAntoine Ginies <aginies@mandriva.com>2004-01-27 10:35:03 +0000
commitfe729fed41e88c82b1d58e21dc42ecb9dadea131 (patch)
tree21d07ff466e48e3b4b2fcd9cf371f4b787f45ee2
parent78e6f3518570c99f93b6976502359eb27ed14d2e (diff)
downloaddrakwizard-fe729fed41e88c82b1d58e21dc42ecb9dadea131.tar
drakwizard-fe729fed41e88c82b1d58e21dc42ecb9dadea131.tar.gz
drakwizard-fe729fed41e88c82b1d58e21dc42ecb9dadea131.tar.bz2
drakwizard-fe729fed41e88c82b1d58e21dc42ecb9dadea131.tar.xz
drakwizard-fe729fed41e88c82b1d58e21dc42ecb9dadea131.zip
- correct some typo
- add test of bash in /etc/shells - rewrite fonction to allow/deny from internet/intranet - force selection of intranet or internet to continue wizard
-rwxr-xr-xftp_wizard/Proftpd.pm114
1 files changed, 44 insertions, 70 deletions
diff --git a/ftp_wizard/Proftpd.pm b/ftp_wizard/Proftpd.pm
index d7870129..6c970323 100755
--- a/ftp_wizard/Proftpd.pm
+++ b/ftp_wizard/Proftpd.pm
@@ -33,7 +33,8 @@ my $wiz = MDK::Wizard::Wizcommon->new;
my $o = {
name => N("FTP wizard"),
var => {
- wiz_ftp_external => '',
+ wiz_ftp_external => '0',
+ wiz_ftp_internal => '1',
# wiz_ftp_anon => '',
# wiz_ftp_home => '',
wiz_root_login => '',
@@ -76,18 +77,15 @@ $o->{pages} = {
},
config => {
name => N("FTP Server") . "\n\n" . N("Your server can act as an FTP Server toward your internal network (intranet) and as an FTP Server for the Internet.") . "\n\n" . N("Select the kind of FTP service you want to activate:"),
- pre => sub {
- $o->{var}{wiz_ftp_internal} ||= 1;
- $o->{var}{wiz_ftp_external} ||= 0;
- },
data => [
{ label => N("Enable the FTP Server for the Intranet"), type => 'bool', val => \$o->{var}{wiz_ftp_internal} },
{ label => N("Enable the FTP Server for the Internet"), type => 'bool', val => \$o->{var}{wiz_ftp_external} },
],
+ post => \&check_opt,
next => 'options'
},
options => {
- name => N("Ftp Proftpd server options") . "\n\n" . N("Permit root login: allow root to log on ftp server.") . "\n" . N("Admin Email: email address of FTP maintainer.") . "\n" . N("Chroot Home user: Block user in their home directory.") . "\n\n" . N("allow FTP resume: allow resume upload or download on ftp server.") . "\n" . N("Allow FXP: allow file transfert via other ftp."),
+ name => N("Ftp Proftpd server options") . "\n\n" . N("Permit root login: allow root to log on ftp server.") . "\n" . N("Admin Email: email address of FTP administrator.") . "\n" . N("Chroot Home user: the users will only see their home directory.") . "\n\n" . N("Allow FTP resume: allow resume upload or download on ftp server.") . "\n" . N("Allow FXP: allow file transfert via other ftp."),
pre => sub {
$o->{var}{wiz_root_login} ||= 0;
$o->{var}{wiz_default_root} ||= 1;
@@ -101,6 +99,7 @@ $o->{pages} = {
{ label => N("Allow FTP resume:"), type => 'bool', val => \$o->{var}{wiz_ftp_resume} },
{ label => N("Allow FXP:"), type => 'bool', val => \$o->{var}{wiz_ftp_fxp} },
],
+ post => \&check_shell,
next => 'summary',
},
warning_dhcp => {
@@ -108,6 +107,16 @@ $o->{pages} = {
ignore => 1,
next => 'config'
},
+ error_choose => {
+ name => N("Please choose allow connection to FTP server from internal or external."),
+ next => 'config',
+ },
+ error_shell => {
+ name => N("I can't find bash in list of shells. Please correct."),
+ no_back => 1,
+ end => 1,
+ next => 0,
+ },
must_be_root => {
name => N("Error.") . "\n\n" . N("Sorry, you must be root to do this..."),
ignore => 1,
@@ -151,6 +160,16 @@ sub new {
}, $class;
}
+sub check_opt {
+ if ($o->{var}{wiz_ftp_external} == 0 && $o->{var}{wiz_ftp_internal} == 0) {
+ return 'error_choose'
+ }
+}
+
+sub check_shell {
+ if (!any { /bash/ } cat_("/etc/shells")) { return 'error_shell' }
+}
+
sub true {
my ($val) = @_;
return member($val, qw(1 '1' "1" true 'true' "true"));
@@ -231,8 +250,6 @@ sub do_it {
my $file = "/etc/proftpd.conf";
die "no ftp configuration file found ! warning." if !-f $file;
MDK::Common::cp_af($file, $file . ".orig");
- local *NEW;
- open(NEW, "< $file") or die "error while opening $file: $!";
my $allow = "all";
if ($wiz_ftp_internal && !$wiz_ftp_external) {
($allow) = $wiz->{net}->itf_get("IPADDR") =~ qr/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.)\d{1,3}$/;
@@ -241,81 +258,38 @@ sub do_it {
elsif (!$wiz_ftp_external) {
$allow = "none";
}
- $file = "/etc/proftpd.conf";
- open(NEW, "< $file");
- my $exist = 0;
- local $_;
- while (<NEW>) { # we need 3 elements to consider section as known
- if (m/^\s*<Global>/s...m!^\s*</Global>!s) {
- if (m/^\s*<Limit LOGIN>/s...m!^\s*</Limit>!s) {
- if (/^\s*(?!#)\s*Order /) {
- $exist++;
- }
- if (/^\s*(?!#)\s*Allow /) {
- $exist++;
- }
- if (/^\s*(?!#)\s*Deny /) {
- $exist++;
- }
- }
- }
- }
- close(NEW);
- if ($exist < 3) { # Odd parameters are commented if exists to then add a known section
- substInFile {
- if (m/^\s*<Global>/s...m!^\s*</Global>!s) {
- if (m/^\s*<Limit LOGIN>/s...m!^\s*</Limit>!s) {
- s/^\s*(?!#)\s*Order .*$/#$&\n/s;
- s/^\s*(?!#)\s*Allow .*$/#$&\n/s;
- s/^\s*(?!#)\s*Deny .*$/#$&\n/s;
- }
- }
- } $file;
- open(NEW, ">> $file");
- print NEW '
-#<drakwizard>
+
+ my $conf = cat_($file) . "#EndOfFile";
+ my ($bloc) = $conf =~ /.*?(#drakwizard_pxe_b.*?#drakwizard_pxe_end)\n.*#EndOfFile/s;
+
+ # print "$begin\n";
+ # print "$end\n";
+
+ if (!$bloc) {
+ $bloc = "
+#drakwizard_pxe_b
<Global>
<Limit LOGIN>
Order allow,deny
- Allow from '.$allow.'
+ Allow from $allow
Deny from all
</Limit>
</Global>
-#</drakwizard>
-';
- close NEW;
- }
- else { # the known section (3 parameters) is replaced with our needs
- substInFile {
- if (m/^\s*<Global>/s...m!^\s*</Global>!s) {
- if (m/^\s*<Limit LOGIN>/s...m!^\s*</Limit>!s) {
- if (/^\s*(?!#)\s*Order /i) {
- if (!/\s*Order\s*allow,\s*deny\s*$/) {
- s//#$&\n Order allow,deny\n/;
- }
- }
- if (/^\s*(?!#)\s*Allow /i) {
- if (!/\s*Allow\s*from\s*$allow\s*$/) {
- s//#$&\n Allow from $allow/;
- }
- }
- if (/^\s*(?!#)\s*Deny /i) {
- if (!/\s*Deny\s*from\s*all\s*$/) {
- s//#$&\n Deny from all\n/;
- }
- }
- }
- }
- } $file;
+#drakwizard_pxe_end
+
+";
+ append_to_file($file, $bloc);
+ } else {
+ substInFile { s/Allow from.*/Allow from $allow/ }
}
# options
# wiz_root_login wiz_server_admin wiz_default_root wiz_ftp_resume wiz_ftp_fxp
if ($o->{var}{wiz_server_admin}) {
if (any { /^ServerAdmin/ } cat_($file)) {
- substInFile { s/ServerAdmin.*/ServerAdmin $o->{var}{wiz_server_admin}/ } $file
+ substInFile { s/ServerAdmin.*/ServerAdmin $o->{var}{wiz_server_admin}/ } $file
} else {
- append_to_file($file, "ServerAdmin $o->{var}{wiz_server_admin}")
+ append_to_file($file, "ServerAdmin $o->{var}{wiz_server_admin}\n")
}
} else { substInFile { s/ServerAdmin.*// } $file }