Handle hostnames with upper-case letters
[webmin.git] / firewall / mandrake-linux-lib.pl
1 # redhat-linux-lib.pl
2 # Deal with redhat's /etc/sysconfig/iptables save file and startup script
3
4 # check_iptables()
5 # Returns an error message if something is wrong with iptables on this system
6 sub check_iptables
7 {
8 if (!-r "/etc/rc.d/init.d/iptables") {
9         return &text('redhat_escript', "<tt>/etc/rc.d/init.d/iptables</tt>");
10         }
11 if (!$config{'done_check_iptables'}) {
12         local $out = `/etc/rc.d/init.d/iptables status 2>&1`;
13         if ($out !~ /table:|INPUT|FORWARD|OUTPUT/) {
14                 return &text('redhat_eoutput',
15                              "<tt>/etc/init.d/iptables status</tt>");
16                 }
17         $config{'done_check_iptables'} = 1;
18         &save_module_config();
19         }
20 return undef;
21 }
22
23 $iptables_save_file = "/etc/sysconfig/iptables";
24
25 # apply_iptables()
26 # Applies the current iptables configuration from the save file
27 #sub apply_iptables
28 #{
29 #local $out = &backquote_logged("cd / ; /etc/rc.d/init.d/iptables restart 2>&1");
30 #$out =~ s/\033[^m]+m//g;
31 #return $? || $out =~ /FAILED/ ? "<pre>$out</pre>" : undef;
32 #}
33
34 # unapply_iptables()
35 # Writes the current iptables configuration to the save file
36 sub unapply_iptables
37 {
38 $out = &backquote_logged("cd / ; /etc/rc.d/init.d/iptables save 2>&1 </dev/null");
39 $out =~ s/\033[^m]+m//g;
40 return $? || $out =~ /FAILED/ ? "<pre>$out</pre>" : undef;
41 }
42
43 # started_at_boot()
44 sub started_at_boot
45 {
46 &foreign_require("init", "init-lib.pl");
47 return &init::action_status("iptables") == 2;
48 }
49
50 sub enable_at_boot
51 {
52 &foreign_require("init", "init-lib.pl");
53 &init::enable_at_boot("iptables");       # Assumes init script exists
54 }
55
56 sub disable_at_boot
57 {
58 &foreign_require("init", "init-lib.pl");
59 &init::disable_at_boot("iptables");
60 }
61
62 1;
63