Skip to content

Commit 86620cf

Browse files
bodepdjonnytdevops
authored andcommitted
Lookup username from uuid
When using the uid feature of the firewall module, it did not work with string based usernames as documented. The uid propery always synchronized with a message of <number> does not match <username>. This code overrides the uid getter method to perform a check of both the data from the property hash as well as using that data (assuming it is a uid) to resolve the username. While this patch is pretty simple, I have only tested it on Ubuntu 14.04. I am not sure if it could be problematic with other versions. I have not yet written tests b/c I wanted to submit my proposed fix for discussion while I get those written.
1 parent b2eae73 commit 86620cf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/puppet/type/firewall.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,11 @@ def should_to_s(value)
730730
only, as iptables does not accept multiple uid in a single
731731
statement.
732732
EOS
733+
def insync?(is)
734+
require 'etc'
735+
return is.to_s == @should.first.to_s || Etc.getpwuid(Integer(is)).name == @should.first.to_s
736+
end
737+
733738
end
734739

735740
newproperty(:gid, :required_features => :owner) do

0 commit comments

Comments
 (0)