summaryrefslogtreecommitdiffstats
path: root/web_wizard/scripts/Webconf.pm
blob: be697513047bf20c3a0f7fa5513aa197732f36d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl

package Webconf;
require "/usr/share/wizards/common/scripts/Vareqval.pm";
require "/usr/share/wizards/common/scripts/DrakconnectConf.pm";
use MDK::Common;

use strict;

my $o = DrakconnectConf->new();

sub	check {
    $> and return 1;
    $o->is_dhcp() and return 2;
    0;
}

sub	do_it {
    my	$file = "/etc/httpd/conf/commonhttpd.conf";
    my	$that = "localhost";

    if ($ENV{wiz_web_external} eq "1") {
	$that = "all";
    }
    elsif ($ENV{wiz_web_internal} eq "1") {
	($that) = $o->get_from_known_dev("IP") =~ qr/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.)\d{1,3}$/;
	$that .= " 127.0.0.1";
    }
    cp_af($file, $file.".orig");
    substInFile {    
	if( m /^\s*<Directory \/home/s...m/^\s*<\/Directory>/s ) {
	    { s /^\s*Allow .*$/    Allow from $that\n/s;}
	    ;}
	if( m /^\s*<Directory \/var\/www/s...m/^\s*<\/Directory>/s ) {
	    { s /^\s*Allow .*$/    Allow from $that\n/s;}
	    ;}
    } $file;
    system("/etc/rc.d/init.d/httpd restart");
    10;
}

1;