Re: [PATCH] 474937 - don't duplicate --dport 22

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday, 11 בDecember 2008, David Cantrell wrote:
> Chris Lumens wrote:
> > We were writing --dport 22 to /etc/sysconfig/iptables twice beacuse ssh
> > was getting included both in the kickstart file and implicitly in
> > firewall.py.  Check for that duplication.
> Looks good.

Yes for this specific case, but IMO it may be better to solve
the general case of duplication (e.g: by the user itself).
Since I'm not a native pythonist, I'll show the idea in few
untested perl lines. However, i'll bet there are people here who
can not only translate it, but improve it as well:

 sub unique_list {
   my @list = sort @_;
   # One of zillions methods to get unique elements from (sorted) list...
   return grep { $nodup = ($last != $_); $last = $_; return $nodup } @list;
 }

 # It won't hurt mapping portnumbers to official service names if
 # available. Assume we have a hash (from /etc/services or hard-coded)
 %services = ...

 push(@servicelist, map { $services{$_} } @portlist); # Append the mapped
 @portlist = grep { !$services{$_} } @portlist };     # Save the non-mapped

 # OK, let's make it unique
 @servicelist = unique_list(@portlist);
 @portlist = unique_list(@portlist);

Any takers? (asbestos suite on ;-)

-- 
Oron Peled                             Voice/Fax: +972-4-8228492
oron@xxxxxxxxxxxx                  http://www.actcom.co.il/~oron
"write your own operating system.  It has worked every time for me"
           -- Linus Thorvalds

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux