summaryrefslogtreecommitdiff
path: root/lib/chef/provider/group/dscl.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:09:07 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:09:07 -0700
commit7a1a6c8ef26c787e4b6dd1602f3d158b37e81720 (patch)
tree1e390cd535b38368d091cbb33e5d419408d5ce00 /lib/chef/provider/group/dscl.rb
parent77f8739a4741e2370e40ec39345a92a6ea393a1a (diff)
downloadchef-7a1a6c8ef26c787e4b6dd1602f3d158b37e81720.tar.gz
fix Layout/EmptyLineAfterGuardClause
i like this one, gives visual priority to returns or raises that are buried in the middle of things. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider/group/dscl.rb')
-rw-r--r--lib/chef/provider/group/dscl.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/chef/provider/group/dscl.rb b/lib/chef/provider/group/dscl.rb
index a5c4d27ddb..ce4a6adaf7 100644
--- a/lib/chef/provider/group/dscl.rb
+++ b/lib/chef/provider/group/dscl.rb
@@ -40,6 +40,7 @@ class Chef
return "" if ( args.first =~ /^delete/ ) && ( result[1].exitstatus != 0 )
raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") unless result[1].exitstatus == 0
raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") if result[2] =~ /No such key: /
+
result[2]
end
@@ -88,6 +89,7 @@ class Chef
def gid_used?(gid)
return false unless gid
+
search_gids = safe_dscl("search", "/Groups", "PrimaryGroupID", gid.to_s)
# dscl -search should not return anything if the gid doesn't exist,
@@ -99,6 +101,7 @@ class Chef
def set_gid
new_resource.gid(get_free_gid) if [nil, ""].include? new_resource.gid
raise(Chef::Exceptions::Group, "gid is already in use") if gid_used?(new_resource.gid)
+
safe_dscl("create", "/Groups/#{new_resource.group_name}", "PrimaryGroupID", new_resource.gid)
end