fix service port number lookup to use protocol
authorKjetil Torgrim Homme <kjetil.homme@redpill-linpro.com>
Wed, 1 Dec 2021 20:53:26 +0000 (21:53 +0100)
committerKjetil Torgrim Homme <kjetil.homme@redpill-linpro.com>
Mon, 3 Oct 2022 21:03:18 +0000 (23:03 +0200)
commit1f5f6523cdb1bc0b133237ce49403e42c6ab60cb
tree623caea59da0c47339ef949918acaec47011583d
parent71f3e491875e8a806529c488f3c37770c918aae9
fix service port number lookup to use protocol

The existing code passes `:proto`, which `string_to_port` casts to a
string, gets "proto", compares that to the possibilities "udp" or "tcp",
and when neither, falls back to using "tcp".

This patch passes the actual proto value to the function, in case there is
a UDP specific service in your /etc/services (uncommon, but it happens).
It looks like Puppet will evaluate the properties in declared order,
so I had to move `newproperty(:proto)` up so `@resource[:proto]` was
available in the code for `sport`, `dport` and `port`.
lib/puppet/type/firewall.rb