mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
Merge pull request #2145 from webmin/dev/jail-backend-port
Dev/jail-backend-port
This commit is contained in:
@@ -30,15 +30,15 @@ print &ui_hidden("new", $in{'new'});
|
||||
print &ui_hidden("old", $in{'name'});
|
||||
print &ui_table_start($text{'jail_header'}, undef, 2);
|
||||
|
||||
# Jail name
|
||||
print &ui_table_row($text{'jail_name'},
|
||||
&ui_textbox("name", $jail->{'name'}, 30));
|
||||
|
||||
# Enabled or disabled?
|
||||
my $enabled = &find_value("enabled", $jail);
|
||||
print &ui_table_row($text{'jail_enabled'},
|
||||
&ui_yesno_radio("enabled", $enabled =~ /true|yes|1/i));
|
||||
|
||||
# Jail name
|
||||
print &ui_table_row($text{'jail_name'},
|
||||
&ui_textbox("name", $jail->{'name'}, 30));
|
||||
|
||||
# Filter to match
|
||||
my @filters = &list_filters();
|
||||
my $filter = &find_value("filter", $jail);
|
||||
@@ -49,6 +49,22 @@ print &ui_table_row($text{'jail_filter'},
|
||||
map { &filename_to_name($_->[0]->{'file'}) } @filters ],
|
||||
1, 0, $filter ? 1 : 0));
|
||||
|
||||
# Backend
|
||||
my $backend = &find_value("backend", $jail);
|
||||
print &ui_table_row($text{'jail_backend'},
|
||||
&ui_select("backend", $backend || "",
|
||||
[ [ "", "" ],
|
||||
[ "auto", $text{'jail_auto'} ],
|
||||
[ "systemd", $text{'jail_systemd'} ],
|
||||
[ "polling", $text{'jail_polling'} ],
|
||||
[ "gamin", $text{'jail_gamin'} ],
|
||||
[ "pyinotify", $text{'jail_pyinotify'} ] ]));
|
||||
|
||||
# Ports to monitor
|
||||
my $port = &find_value("port", $jail);
|
||||
print &ui_table_row($text{'jail_ports'},
|
||||
&ui_textbox("port", $port, 35));
|
||||
|
||||
# Actions to run
|
||||
my $actionlist = &find("action", $jail);
|
||||
my @actions = &list_actions();
|
||||
|
||||
@@ -87,6 +87,7 @@ jail_title1=Create Jail
|
||||
jail_title2=Edit Jail
|
||||
jail_header=Filter action jail details
|
||||
jail_name=Jail name
|
||||
jail_ports=Ports to block
|
||||
jail_egone=Jail no longer exists!
|
||||
jail_enabled=Currently enabled?
|
||||
jail_filter=Filter to search log for
|
||||
@@ -104,6 +105,8 @@ jail_ignoreip=IP addresses to never ban
|
||||
jail_err=Failed to save jail
|
||||
jail_eclash=A jail with the same name already exists
|
||||
jail_ename=Missing or invalid jail name
|
||||
jail_ebackend=Invalid backend name
|
||||
jail_eports=Invalid port name, number or range; use a single port name, number or a range in the form <tt>start:end</tt>; to specify multiple ports, separate them with commas
|
||||
jail_eaname=Invalid looking name parameter for action $1
|
||||
jail_eport=Invalid port number for action $1
|
||||
jail_eactions=No actions selected!
|
||||
|
||||
@@ -44,6 +44,14 @@ else {
|
||||
$clash && &error($text{'jail_eclash'});
|
||||
}
|
||||
|
||||
# Validate backend
|
||||
!$in{'backend'} || $in{'backend'} =~ /^(auto|systemd|polling|gamin|pyinotify)$/ ||
|
||||
&error($text{'jail_ebackend'});
|
||||
|
||||
# Validate ports (1234 or 1234:1245 or 1234:1245,1250,http or 1238,http,https)
|
||||
$in{'port'} =~ s/\s+//g if ($in{'port'});
|
||||
!$in{'port'} || $in{'port'} =~ /^(?!$)(?:[a-zA-Z]+|\d{1,5})(?:(?::\d{1,5})?)(?:,(?:[a-zA-Z]+|\d{1,5})(?:(?::\d{1,5})?)?)*$/gmi || &error($text{'jail_eports'});
|
||||
|
||||
# Parse and validate actions
|
||||
my @actions;
|
||||
for(my $i=0; defined($in{"action_$i"}); $i++) {
|
||||
@@ -116,6 +124,8 @@ else {
|
||||
# Save directives within the section
|
||||
&save_directive("enabled", $in{'enabled'} ? 'true' : 'false', $jail);
|
||||
&save_directive("filter", $in{'filter'} || undef, $jail);
|
||||
&save_directive("backend", $in{'backend'} || undef, $jail);
|
||||
&save_directive("port", $in{'port'} || undef, $jail);
|
||||
&save_directive("action", @actions ? join("\n", @actions)
|
||||
: undef, $jail);
|
||||
&save_directive("logpath", join("\n", @logpaths), $jail);
|
||||
|
||||
Reference in New Issue
Block a user