diff options
Diffstat (limited to 'ftp_wizard')
-rw-r--r-- | ftp_wizard/ftp.wiz | 76 | ||||
-rw-r--r-- | ftp_wizard/scripts/ProFtpconf.pm | 49 |
2 files changed, 115 insertions, 10 deletions
diff --git a/ftp_wizard/ftp.wiz b/ftp_wizard/ftp.wiz index 12e6b9f9..63ad0024 100644 --- a/ftp_wizard/ftp.wiz +++ b/ftp_wizard/ftp.wiz @@ -9,6 +9,7 @@ defaultImage="__WIZ_HOME__/ftp_wizard/images/FTP" perlModule="__WIZ_HOME__/ftp_wizard/scripts/ProFtpconf.pm" rpm="proftpd" + summaryFunc="do_it" > <Variable @@ -33,6 +34,11 @@ shellVariable="wiz_ftp_external" > </Variable> + <Variable + name="shared_dir" + shellVariable="wiz_dir" + > + </Variable> <Page helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-ftp.html" name="welcome" @@ -159,6 +165,67 @@ </Page> <Page + name="ask_dir" + func="check_dir" + executionLevel="NORMAL" + nextFinish="false" + canBack="true" + canCancel="true" + > + + <Target + targetName="error_in_dir" + jumpIndex="1" + > + </Target> + + <Target + targetName="confirmation" + jumpIndex="10" + > + </Target> + + <Info + helpText="Shared dir:" + > + </Info> + + + <Info + helpText="Type the path of the directory you want being shared." + > + </Info> + + <Freetext + name="freetext_dir" + variableName="shared_dir" + helpText="Shared dir:" + editable="true" + fillfunc="get_dir" + > + </Freetext> + </Page> + + + <Page + helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html" + name="error_in_dir" + jumpPage="ask_dir" + nextButtonText="Fix it" + executionLevel="NORMAL" + nextFinish="false" + canBack="true" + canCancel="true" + > + + <Info + helpText="The path you entered does not exist." + > + </Info> + </Page> + + + <Page helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-ftp.html" name="confirmation" func="do_it" @@ -182,9 +249,7 @@ needed to configure your FTP Server" > </Info> - <Freetext - name="freetext1" variableName="wiz_ftp_internal" helpText="Intranet FTP Server:" editable="false" @@ -192,13 +257,18 @@ needed to configure your FTP Server" </Freetext> <Freetext - name="freetext2" variableName="wiz_ftp_external" helpText="Internet FTP Server:" editable="false" > </Freetext> + <Freetext + variableName="shared_dir" + helpText="Public directory:" + editable="false" + > + </Freetext> <Info helpText="To accept these values, and configure your server, click the Next button or use the Back button to correct them." diff --git a/ftp_wizard/scripts/ProFtpconf.pm b/ftp_wizard/scripts/ProFtpconf.pm index a53a1023..85ecfd4d 100644 --- a/ftp_wizard/scripts/ProFtpconf.pm +++ b/ftp_wizard/scripts/ProFtpconf.pm @@ -15,6 +15,22 @@ sub true { 0; } +sub check_dir { + -d ($ENV{wiz_dir}) and return 10; + 1; +} + +sub get_dir { + 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 $o = DrakconnectConf->new(); sub check { @@ -23,6 +39,23 @@ sub check { 0; } +sub print_anonymous() { + print ' +#<drakwizard> +<Anonymous '.$_[0].'> + User ftp + Group ftp + UserAlias anonymous ftp + MaxClients 10 + <Limit WRITE> + DenyAll + </Limit> +</Anonymous> +#</drakwizard> +'; +EOF +} + sub do_it { my $wiz_ftp_internal = $ENV{wiz_ftp_external} ? 1 : true $ENV{wiz_ftp_internal}; my $wiz_ftp_external = true $ENV{wiz_ftp_external}; @@ -41,23 +74,23 @@ sub do_it { my $file = "/etc/proftpd.conf"; open (NEW, "< $file"); my $exist = 0; - while (<NEW>) { + 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 += 1; + $exist++; } if (/^\s*(?!\#)\s*Allow .*$/) { - $exist += 1; + $exist++; } if (/^\s*(?!\#)\s*Deny .*$/) { - $exist += 1; + $exist++; } } } } close (NEW); - if ($exist < 3) { + 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 ) { @@ -69,16 +102,18 @@ sub do_it { } $file; open (NEW, ">> $file"); print NEW ' +#<drakwizard> <Global> <Limit LOGIN> Order allow,deny Allow from '.$allow.' Deny from all </Limit> -</Global>'; +</Global> +#</drakwizard>'; close NEW; } - else { + 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 ) { |