diff options
Diffstat (limited to 'lib/chef/provider/group/dscl.rb')
-rw-r--r-- | lib/chef/provider/group/dscl.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/provider/group/dscl.rb b/lib/chef/provider/group/dscl.rb index 71e42b36ba..fe152eda33 100644 --- a/lib/chef/provider/group/dscl.rb +++ b/lib/chef/provider/group/dscl.rb @@ -88,8 +88,12 @@ class Chef def gid_used?(gid) return false unless gid - groups_gids = safe_dscl("list", "/Groups", "gid") - !!( groups_gids =~ Regexp.new("#{Regexp.escape(gid.to_s)}\n") ) + search_gids = safe_dscl("search", "/Groups", "PrimaryGroupID", gid.to_s) + + # dscl -search should not return anything if the gid doesn't exist, + # but on the off-chance that it does, check whether the given gid is + # in the output. + !!(search_gids =~ /\b#{gid}\b/) end def set_gid |