Skip to content

Commit

Permalink
Lookup username from uuid
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bodepd authored and jonnytdevops committed Jan 21, 2015
1 parent b2eae73 commit 86620cf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/puppet/type/firewall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,11 @@ def should_to_s(value)
only, as iptables does not accept multiple uid in a single
statement.
EOS
def insync?(is)
require 'etc'
return is.to_s == @should.first.to_s || Etc.getpwuid(Integer(is)).name == @should.first.to_s
end

end

newproperty(:gid, :required_features => :owner) do
Expand Down

0 comments on commit 86620cf

Please sign in to comment.