diff options
author | Antoine Ginies <aginies@mandriva.com> | 2005-05-26 01:20:06 +0000 |
---|---|---|
committer | Antoine Ginies <aginies@mandriva.com> | 2005-05-26 01:20:06 +0000 |
commit | 35fadbf1557b85ed92eac5fac3fc7ae5202793e2 (patch) | |
tree | eb57f507209b534a7e8a082cc90837ab04211bc3 | |
parent | 2ff0959ce8b473f547534218c6b4b53cef958951 (diff) | |
download | drakwizard-35fadbf1557b85ed92eac5fac3fc7ae5202793e2.tar drakwizard-35fadbf1557b85ed92eac5fac3fc7ae5202793e2.tar.gz drakwizard-35fadbf1557b85ed92eac5fac3fc7ae5202793e2.tar.bz2 drakwizard-35fadbf1557b85ed92eac5fac3fc7ae5202793e2.tar.xz drakwizard-35fadbf1557b85ed92eac5fac3fc7ae5202793e2.zip |
fix some Proftpd syntax
-rwxr-xr-x | ftp_wizard/Proftpd.pm | 102 |
1 files changed, 43 insertions, 59 deletions
diff --git a/ftp_wizard/Proftpd.pm b/ftp_wizard/Proftpd.pm index f08aba26..f696a7de 100755 --- a/ftp_wizard/Proftpd.pm +++ b/ftp_wizard/Proftpd.pm @@ -81,7 +81,12 @@ $o->{pages} = { { 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, + complete => sub { + if ($o->{var}{wiz_ftp_external} == 0 && $o->{var}{wiz_ftp_internal} == 0) { + $::in->ask_warn(N("Error"), N("Please choose whether to allow a connection to FTP server from internal or external hosts.")); + return 1; + } else { return 0 } + }, next => 'options' }, options => { @@ -99,29 +104,24 @@ $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, + complete => sub { + if (!any { /bash/ } cat_("/etc/shells")) { + $::in->ask_warn(N("Error"), N("I can't find bash in list of shells! It seems you have modified it by hand! Please correct.")); + return 1; + } else { return 0 } + }, next => 'summary', }, - warning_dhcp => { - name => N("Warning.") . "\n\n" . N("You are in DHCP, server may not work with your configuration."), - ignore => 1, - next => 'config' - }, - error_choose => { - name => N("Please choose whether to allow a connection to FTP server from internal or external hosts."), - next => 'config', - }, - error_shell => { - name => N("I can't find bash in list of shells! It seems you have modified it by hand! Please correct."), - no_back => 1, - end => 1, - next => 0, + warning_dhcp => { + name => N("Warning.") . "\n\n" . N("You are in DHCP, server may not work with your configuration."), + ignore => 1, + next => 'config' }, - must_be_root => { - name => N("Error.") . "\n\n" . N("Sorry, you must be root to do this..."), - ignore => 1, + must_be_root => { + name => N("Error.") . "\n\n" . N("Sorry, you must be root to do this..."), + ignore => 1, next => 'config' - }, + }, summary => { name => N("Configuring the FTP server") . "\n\n" . N("The wizard collected the following parameters needed to configure your FTP server") . "\n\n" . N("To accept those values, and configure your server, click the next button or use the back button to correct them"), pre => sub { @@ -166,47 +166,31 @@ 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")); } -sub check_dir { - -d $o->{var}{wiz_dir} and return 10; - 1 -} - sub get_dir { - my $file = "/etc/proftpd.conf"; - die "no FTP configuration file found! warning." if !-f $file; - local *NEW; - open(NEW, "< $file") or die "error while opening $file: $!"; - - local $_; - while (<NEW>) { # we need 3 elements to consider section as known - if (m/^\s*<drakwizard>/s...m!^\s*</drakwizard>!s) { - if (m/^\s*<Anonymous\s*(.*)>/s) { - return $1; - } - } + my $file = "/etc/proftpd.conf"; + die "no FTP configuration file found! warning." if !-f $file; + local *NEW; + open(NEW, "< $file") or die "error while opening $file: $!"; + local $_; + while (<NEW>) { # we need 3 elements to consider section as known + if (m/^\s*<drakwizard>/s...m!^\s*</drakwizard>!s) { + if (m/^\s*<Anonymous\s*(.*)>/s) { + return $1; + } } - "" + } + ""; } sub check { $> and return 'must_be_root'; $wiz->{net}->is_dhcp and return 'warning_dhcp'; - '' + ''; } sub print_anonymous { @@ -234,7 +218,7 @@ sub change_options { if (any { /^$var_in_conf/ } cat_($file)) { substInFile { s/$var_in_conf.*/$var_in_conf $status/ } $file; } else { - append_to_file($file, "$var_in_conf $status\n") + append_to_file($file, "$var_in_conf $status\n"); } } @@ -244,7 +228,7 @@ sub add_options { if (any { /^$var/ } cat_($file)) { substInFile { s/$var.*/$var $value/ } $file; } else { - append_to_file($file, "$var $value\n") + append_to_file($file, "$var $value\n"); } } @@ -270,7 +254,7 @@ sub do_it { if (!$bloc) { $bloc = " -#drakwizard_pxe_b +#drakwizard_proftpd <Global> <Limit LOGIN> Order allow,deny @@ -278,7 +262,7 @@ sub do_it { Deny from all </Limit> </Global> -#drakwizard_pxe_end +#drakwizard_proftpd "; append_to_file($file, $bloc); @@ -290,9 +274,9 @@ sub do_it { # 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}\n") + append_to_file($file, "ServerAdmin $o->{var}{wiz_server_admin}\n"); } } else { substInFile { s/ServerAdmin.*// } $file } @@ -305,9 +289,9 @@ sub do_it { my $data; if ($o->{var}{wiz_default_root} == 1) { - $data = "DefaultRoot ~" + $data = "DefaultRoot ~"; } else { - $data = "" + $data = ""; } if (any { /^DefaultRoot/ } cat_($file)) { substInFile { s/DefaultRoot.*/$data/ } $file; @@ -321,9 +305,9 @@ sub do_it { } if (services::is_service_running('proftpd')) { - services::restart('proftpd') + services::restart('proftpd'); } else { - services::start('proftpd') + services::start('proftpd'); } check_started('proftpd'); } |