]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Lookup username from uuid
authorDan Bode <bodepd@gmail.com>
Thu, 8 Jan 2015 17:06:10 +0000 (18:06 +0100)
committerJonathan Tripathy <jonathan.tripathy@puppetlabs.com>
Wed, 21 Jan 2015 07:40:32 +0000 (23:40 -0800)
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.

lib/puppet/type/firewall.rb

index e7cb04b712ded898011298b2f2f3a93e16ca62b3..88d1aaf533ce0bdf12a952910f96d9c790781855 100644 (file)
@@ -730,6 +730,11 @@ Puppet::Type.newtype(:firewall) do
       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