Server IP : 195.201.23.43 / Your IP : 13.58.67.129 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/firewalld/ |
Upload File : |
#!/usr/bin/perl # Create a new zone, and add some allowed ports to it use strict; use warnings; no warnings 'redefine'; no warnings 'uninitialized'; require './firewalld-lib.pl'; our (%text, %in); &ReadParse(); &error_setup($text{'zone_err'}); # Validate inputs $in{'name'} =~ /^[a-z0-9\.\_\-]+$/i || &error($text{'zone_ename'}); my @zones = &list_firewalld_zones(); my ($clash) = grep { $_->{'name'} eq $in{'name'} } @zones; $clash && &error($text{'zone_eclash'}); # Add the zone my $err = &create_firewalld_zone($in{'name'}); &error($err) if ($err); # Find the Webmin port my @webminports; if (&foreign_installed("webmin")) { &foreign_require("webmin"); my @socks = &webmin::get_miniserv_sockets(); @webminports = &unique(map { $_->[1] } @webminports); } else { @webminports = ( $ENV{'SERVER_PORT'} || 10000 ); } # Work out which ports to allow my (@addports, @addservs); if ($in{'mode'} == 1) { # Copy from another zone my ($source) = grep { $_->{'name'} eq $in{'source'} } @zones; @addports = @{$source->{'ports'}}; @addservs = @{$source->{'services'}}; } elsif ($in{'mode'} >= 2) { # SSH, Webmin and Ident push(@addports, "ssh/tcp", "auth/tcp"); foreach my $webminport (@webminports) { push(@addports, $webminport."-".($webminport+10)."/tcp"); } if ($in{'mode'} >= 3) { # High ports push(@addports, "1024-65535/tcp"); } if ($in{'mode'} >= 4) { # Other virtual hosting ports push(@addports, "53/tcp", "53/udp"); # DNS push(@addports, "80/tcp", "443/tcp"); # HTTP push(@addports, "25/tcp", "587/tcp"); # SMTP push(@addports, "20/tcp", "21/tcp"); # FTP push(@addports, "110/tcp", "995/tcp"); # POP3 push(@addports, "143/tcp", "220/tcp", "993/tcp"); # IMAP push(@addports, "20000/tcp"); # Usermin } } # Add the ports and services my $zone = { 'name' => $in{'name'} }; foreach my $p (@addports) { my $err = &create_firewalld_port($zone, split(/\//, $p)); &error($err) if ($err); } foreach my $s (@addservs) { my $err = &create_firewalld_service($zone, $s); &error($err) if ($err); } &webmin_log("create", "zone", $in{'name'}); &redirect("index.cgi?zone=".&urlize($in{'name'}));Private