forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_config.cgi
executable file
·111 lines (96 loc) · 3.54 KB
/
edit_config.cgi
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/local/bin/perl
# edit_config.cgi
# Show global configuration options
require './ipsec-lib.pl';
&ui_print_header(undef, $text{'config_title'}, "");
@conf = &get_config();
($config) = grep { $_->{'name'} eq 'config' } @conf;
print "<form action=save_config.cgi method=post>\n";
print "<table border width=100%>\n";
print "<tr $tb> <td><b>$text{'config_header'}</b></td> </tr>\n";
print "<tr $cb> <td><table width=100%>\n";
# Get list of interfaces
&foreign_require("net", "net-lib.pl");
@allifaces = &unique(sort { $a cmp $b }
(map { $_->{'fullname'} } &net::active_interfaces()),
(map { $_->{'fullname'} } &net::boot_interfaces()) );
# Show interfaces to listen on
$i = $config->{'values'}->{'interfaces'};
$imode = $i eq '%none' ? 1 :
$i eq '%defaultroute' ? 2 :
$i ? 3 : 0;
print "<tr> <td valign=top><b>$text{'config_ifaces'}</b></td> <td colspan=3>\n";
foreach $m (0 .. 3) {
printf "<input type=radio name=ifaces_mode value=%s %s> %s\n",
$m, $m == $imode ? "checked" : "", $text{'config_ifaces'.$m};
}
@iflist = $imode == 3 ? split(/\s+/, $i) : ();
print "<br><table border>\n";
print "<tr $tb> <td><b>$text{'config_riface'}</b></td> ",
"<td><b>$text{'config_iiface'}</b></td> </tr>\n";
$n = 0;
foreach $ifc (@iflist, "") {
local ($ii, $ri) = split(/=/, $ifc);
print "<tr $cb>\n";
$found = 0;
print "<td><select name=ri_$n>\n";
print "<option value=''> \n";
foreach $r (@allifaces) {
next if ($r =~ /^ipsec/ || $r =~ /:/);
printf "<option value=%s %s>%s (%s)\n",
$r, $ri eq $r ? "selected" : "", $r,
&net::iface_type($r);
$found++ if ($ri eq $r);
}
print "<option value=$ri selected>$ri\n" if (!$found && $ri);
print "</select></td>\n";
$found = 0;
print "<td><select name=ii_$n>\n";
foreach $k (0 .. 4) {
printf "<option value=ipsec%d %s>ipsec%d\n",
$k, $ii eq "ipsec$k" ? "selected" : "", $k;
$found++ if ($ii eq "ipsec$k");
}
print "<option value=$ii selected>$ii\n" if (!$found && $ii);
print "</select></td>\n";
print "</tr>\n";
$n++;
}
print "</table></td></tr>\n";
# syslog facility/level
&foreign_require("syslog", "syslog-lib.pl");
$s = $config->{'values'}->{'syslog'};
print "<tr> <td><b>$text{'config_syslog'}</b></td> <td colspan=3>\n";
printf "<input type=radio name=syslog_def value=1 %s> %s (<tt>%s</tt>)\n",
$s ? "" : "checked", $text{'default'}, "daemon.error";
printf "<input type=radio name=syslog_def value=0 %s> %s\n",
$s ? "checked" : "", $text{'config_fac'};
($fac, $pri) = split(/\./, $s);
$pri =~ s/warn$/warning/;
$pri =~ s/panic$/emerg/;
$pri =~ s/error$/err/;
print "<select name=fac>\n";
foreach $f (split(/\s+/, $syslog::config{'facilities'})) {
printf "<option %s>%s\n", $f eq $fac ? "selected" : "", $f;
}
print "</select> $text{'config_pri'}\n";
print "<select name=pri>\n";
foreach $p (&syslog::list_priorities()) {
printf "<option %s>%s\n", $p eq $pri ? "selected" : "", $p;
}
print "</select></td> </tr>\n";
# automatic forwarding enable
$f = $config->{'values'}->{'forwardcontrol'};
print "<tr> <td><b>$text{'config_fwd'}</b></td>\n";
print "<td>",&ui_radio("fwd", $f || "no",
[ [ "yes", $text{'yes'} ], [ "no", $text{'no'} ] ]),"</td>\n";
# nat traversal enable
$n = $config->{'values'}->{'nat_traversal'};
print "<td><b>$text{'config_nat'}</b></td>\n";
print "<td>",&ui_radio("nat", $n || "no",
[ [ "yes", $text{'yes'} ], [ "no", $text{'no'} ] ]),"</td> </tr>\n";
print "<td colspan=2></td>\n";
print "</tr>\n";
print "</table></td></tr></table>\n";
print "<input type=submit value='$text{'save'}'></form>\n";
&ui_print_footer("", $text{'index_return'});