lib/chef/provider/user/dscl.rb
#
# Sets the group id for the user using dscl. Fails if a group doesn't
# exist on the system with given group id.
#
Sets the group id for the user using dscl. Fails if a group doesn't
exist on the system with given group id.
Sets the group id for the user using dscl . Fails if a group doesn ' t exist on the system with given group id .
def dscl_set_gid
          unless @new_resource.gid && @new_resource.gid.to_s.match(/^\d+$/)
            begin
              possible_gid = run_dscl("read /Groups/#{@new_resource.gid} PrimaryGroupID").split(" ").last
            rescue Chef::Exceptions::DsclCommandFailed => e
              raise Chef::Exceptions::GroupIDNotFound.new("Group not found for #{@new_resource.gid} when creating user #{@new_resource.username}")
            end
            @new_resource.gid(possible_gid) if possible_gid && possible_gid.match(/^\d+$/)
          end
          run_dscl("create /Users/#{@new_resource.username} PrimaryGroupID '#{@new_resource.gid}'")
        end
def dscl_set_gid unless @new_resource . gid && @new_resource . gid . to_s . match ( / ^ \d +$ / ) begin possible_gid = run_dscl ( "read /Groups/#{@new_resource.gid} PrimaryGroupID" ) . split ( " " ) . last rescue Chef :: Exceptions :: DsclCommandFailed => e raise Chef :: Exceptions :: GroupIDNotFound . new ( "Group not found for #{@new_resource.gid} when creating user #{@new_resource.username}" ) end @new_resource . gid ( possible_gid ) if possible_gid && possible_gid . match ( / ^ \d +$ / ) end run_dscl ( "create /Users/#{@new_resource.username} PrimaryGroupID '#{@new_resource.gid}'" ) end
Sets the group id for the user using dscl.
Sets the group id for the user using dscl .