Skip to content

Commit

Permalink
Show port numbers for services too https://www.virtualmin.com/node/58814
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Sep 23, 2018
1 parent c06e9d9 commit b1a5650
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion firewalld/edit_serv.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ print &ui_table_row($text{'port_zone'},

# Service name
print &ui_table_row($text{'serv_name'},
&ui_select("serv", $serv, [ &list_firewalld_services() ]));
&ui_select("serv", $serv, [ &list_firewalld_services_with_ports() ]));

print &ui_table_end();
if ($in{'new'}) {
Expand Down
20 changes: 20 additions & 0 deletions firewalld/firewalld-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ sub list_firewalld_services
return split(/\s+/, $out);
}

# list_firewalld_services_with_ports()
# Returns an array of service names and descriptions
sub list_firewalld_services_with_ports
{
my @rv;
foreach my $s (&list_firewalld_services()) {
my @n = getservbyname($s, "tcp");
if (!@n) {
@n = getservbyname($s, "udp");
}
if (@n) {
push(@rv, [ $s, $s." (".$n[2]." ".uc($n[3]).")" ]);
}
else {
push(@rv, [ $s, $s ]);
}
}
return @rv;
}

# create_firewalld_port(&zone, port|range, proto)
# Adds a new allowed port to a zone. Returns undef on success or an error
# message on failure
Expand Down

0 comments on commit b1a5650

Please sign in to comment.