Browse Source

Ticket 47433 - With SeLinux, setup-ds.pl and setup-ds-admin.pl fail to detect already ranged labelled ports

Bug Description:
	With SeLinux ports may be labelled per range. In the output of 'semanage port -l' a range is displayed
	with <portMin>-<portMax> rather than with an individual <portNum>.
	When parsing the output, DSCreate.pm(updateSelinuxPolicy) expects a list of individual ports so it fails
	to detect that a given port is in the range of ports.

Fix Description:
	When parsing the output of 'semanage port -l', if a range exists it checks that the provided port is
	in the range or not.

https://fedorahosted.org/389/ticket/47433

Reviewed by: Rich Megginson (thanks Rich)

Platforms tested: Fedora 17

Flag Day: no

Doc impact: no
Thierry bordaz (tbordaz) 12 years ago
parent
commit
2d6d9ac5e7
1 changed files with 13 additions and 3 deletions
  1. 13 3
      ldap/admin/src/scripts/DSCreate.pm.in

+ 13 - 3
ldap/admin/src/scripts/DSCreate.pm.in

@@ -1007,9 +1007,19 @@ sub updateSelinuxPolicy {
             $portline =~ s/ldap_port_t\s+tcp\s+//g;
             my @labeledports = split(/,\s+/, $portline);
             foreach my $labeledport (@labeledports) {
-                if ($inf->{slapd}->{ServerPort} == $labeledport) {
-                    $need_label = 0;
-                    last;
+                if (index($labeledport, "-") == -1) {
+                        # this is not a range of ports
+                        if ($inf->{slapd}->{ServerPort} == $labeledport) {
+                                $need_label = 0;
+                                last;
+                        }
+                } else {
+                        # this is a range of ports like '<portMin>-<portMax>'
+                        my @range = split(/-/, $labeledport);
+                        if ((@range[0] <= $inf->{slapd}->{ServerPort}) && ($inf->{slapd}->{ServerPort} <= @range[1])) {
+                                $need_label = 0;
+                                last;
+                        }
                 }
             }