From 11a02e3046e3b05081865cf639585ef2d08537aa Mon Sep 17 00:00:00 2001 From: Antoine Ginies Date: Tue, 5 Jul 2005 04:05:45 +0000 Subject: fix user_mod --- web_wizard/Apache.pm | 60 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 19 deletions(-) (limited to 'web_wizard') diff --git a/web_wizard/Apache.pm b/web_wizard/Apache.pm index e43af1d6..876c7bb1 100755 --- a/web_wizard/Apache.pm +++ b/web_wizard/Apache.pm @@ -31,7 +31,7 @@ use MDK::Wizard::Varspaceval; my $wiz = new MDK::Wizard::Wizcommon; -my $file; +my $file = "/etc/httpd/conf/httpd.conf"; my $root; my $config; @@ -44,7 +44,7 @@ my $o = { user_dir => '', shared_dir => '' }, - needed_rpm => [ 'apache-mpm-prefork' ], + needed_rpm => [ 'apache-mpm-prefork', 'apache-mod_userdir' ], defaultimage => "/usr/share/wizards/web_wizard/images/apache.png", init => sub { if (-f $file) { @@ -97,7 +97,12 @@ $o->{pages} = { }, user_dir => { name => N("Type the name of the directory users should create in their homes (without ~/) to get it available via http://www.yourserver.com/~user"), - pre => sub { $o->{var}{user_dir} ||= 'public_html' }, + pre => sub { + $o->{var}{user_dir} = get_user_dir(); + if ($o->{var}{user_dir} =~ /disabled/) { + $o->{var}{user_dir} = 'public_html'; + } + }, data => [ { label => N("user http sub-directory: ~/"), help => N("Type the name of the directory users should create in their homes (without ~/) to get it available via http://www.yourserver.com/~user"), val => \$o->{var}{user_dir} }, ], @@ -170,11 +175,11 @@ sub chg_docroot { substInFile { s|^\s*|{var}{shared_dir}>|; - } "/etc/httpd/conf/commonhttpd.conf" if $old; + } $file if $old; substInFile { s|^\s*|{var}{shared_dir}>|; - } "/etc/httpd/conf/httpd.conf"; + } $file; } sub is_user_mod { @@ -192,25 +197,44 @@ sub is_last_user_mod { } sub get_user_dir { - my %conf = MDK::Wizard::Varspaceval->get("/etc/httpd/conf/httpd.conf"); + my %conf = MDK::Wizard::Varspaceval->get($file); $conf{UserDir}; } sub chg_user_dir { - my $root = get_user_dir(); + # disable by default user_mod + if (! any { // } cat_($file)) { + append_to_file($file, < + UserDir disabled + + + + AllowOverride FileInfo AuthConfig Limit + Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec + + Order allow,deny + Allow from all + + + Order deny,allow + Deny from all + + +EOF + } + + $root = get_user_dir(); if ($o->{var}{user_mod}) { substInFile { - s|(/home/\*/)$root(/?)|$1$o->{var}{user_dir}$2|g; - } "/etc/httpd/conf/httpd.conf"; + s|(\s*)UserDir.*|$1UserDir $o->{var}{user_dir}|g; + s|{var}{user_dir}>|g; + } $file; + } else { substInFile { - s|(\s*)UserDir\s*$root(/?)|$1UserDir $o->{var}{user_dir}$2|g; - s|(/home/\*/)$root(/?)|$1$o->{var}{user_dir}$2|g; - } "/etc/httpd/conf/httpd.conf"; - } - else { - substInFile { - s|(\s*)UserDir\s*$root(/?)|$1UserDir disabled$2|g; - } "/etc/httpd/conf/httpd.conf"; + s|(\s*)UserDir\s*$root|$1UserDir disabled|g; + } $file; } } @@ -219,9 +243,7 @@ sub do_it { my $in = 'interactive'->vnew('su', 'Apache'); my $w = $in->wait_message(N("Apache server"), N("Configuring your system as Apache server ...")); - my $file = "/etc/httpd/conf/httpd.conf"; my $that = "localhost"; - if ($o->{var}{web_external} eq "1") { $that = "all"; } -- cgit v1.2.1