summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@opscode.com>2012-08-27 15:07:47 -0700
committerBryan McLellan <btm@loftninjas.org>2012-08-28 13:41:55 -0400
commitcb59812ec437a97b448f32af5740ea67428596b5 (patch)
treed16d9a630f98ca6f772480040dfcf5d4b0ab2eba
parenta404f926510f1f41424390a10b1d64c589315191 (diff)
downloadchef-cb59812ec437a97b448f32af5740ea67428596b5.tar.gz
CHEF-3391: make lookup_uid/lookup_gid safe on windows
-rw-r--r--chef/lib/chef/scan_access_control.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/chef/lib/chef/scan_access_control.rb b/chef/lib/chef/scan_access_control.rb
index 7a39b14a21..5b83a59695 100644
--- a/chef/lib/chef/scan_access_control.rb
+++ b/chef/lib/chef/scan_access_control.rb
@@ -76,7 +76,11 @@ class Chef
end
def lookup_uid
- Etc.getpwuid(stat.uid).name
+ unless (pwent = Etc.getpwuid(stat.uid)).nil?
+ pwent.name
+ else
+ stat.uid
+ end
rescue ArgumentError
stat.uid
end
@@ -99,7 +103,11 @@ class Chef
end
def lookup_gid
- Etc.getgrgid(stat.gid).name
+ unless (pwent = Etc.getgrgid(stat.gid)).nil?
+ pwent.name
+ else
+ stat.gid
+ end
rescue ArgumentError
stat.gid
end