Sha256: 5cbd99ea0570d2f972d77dab8c3ed807b1c24b7498f8eb0c9b5cf302371ecf92
Contents?: true
Size: 798 Bytes
Versions: 5
Compression:
Stored size: 798 Bytes
Contents
module GitWit::Actions::Dscl class GroupMembership < Base attr_reader :user, :group def initialize(base, user, group, config = {}) super base, :group_membership, "#{user} #{group}", config @user, @group = user, group end def exists? check = `dsmemberutil checkmembership -U '#{user}' -G '#{group}' 2>/dev/null` $?.success? && !!(check =~ /is a member/) end protected def create sudo_dscl "create /Users/#{user} PrimaryGroupID #{gid}" sudo_dscl "append /Groups/#{group} GroupMembership #{user}" end def destroy end def gid gid = dscl "read /Groups/#{group} gid".split("gid: ", 2).last raise Thor::Error, "Could not find gid for group #{group}" unless gid.present? gid.to_i end end end
Version data entries
5 entries across 5 versions & 1 rubygems