Sha256: ad60f454e9a43693fbc9620d008f36c05fc395d06981f94770d5de6603a9ede8

Contents?: true

Size: 1.46 KB

Versions: 20

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true
require_relative '../../../puppet/util/posix'

module Puppet
  # Manage file group ownership.
  Puppet::Type.type(:file).newproperty(:group) do
    desc <<-EOT
      Which group should own the file.  Argument can be either a group
      name or a group ID.

      On Windows, a user (such as "Administrator") can be set as a file's group
      and a group (such as "Administrators") can be set as a file's owner;
      however, a file's owner and group shouldn't be the same. (If the owner
      is also the group, files with modes like `"0640"` will cause log churn, as
      they will always appear out of sync.)
    EOT

    validate do |group|
      raise(Puppet::Error, "Invalid group name '#{group.inspect}'") unless group and group != ""
    end

    def insync?(current)
      # We don't want to validate/munge groups until we actually start to
      # evaluate this property, because they might be added during the catalog
      # apply.
      @should.map! do |val|
        gid = provider.name2gid(val)
        if gid
          gid
        elsif provider.resource.noop?
          return false
        else
          raise "Could not find group #{val}"
        end
      end

      @should.include?(current)
    end

    # We want to print names, not numbers
    def is_to_s(currentvalue)
      super(provider.gid2name(currentvalue) || currentvalue)
    end

    def should_to_s(newvalue)
      super(provider.gid2name(newvalue) || newvalue)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/type/file/group.rb
puppet-8.3.0-x86-mingw32 lib/puppet/type/file/group.rb
puppet-8.3.0-x64-mingw32 lib/puppet/type/file/group.rb
puppet-8.3.0-universal-darwin lib/puppet/type/file/group.rb
puppet-8.3.1 lib/puppet/type/file/group.rb
puppet-8.3.1-x86-mingw32 lib/puppet/type/file/group.rb
puppet-8.3.1-x64-mingw32 lib/puppet/type/file/group.rb
puppet-8.3.1-universal-darwin lib/puppet/type/file/group.rb
puppet-8.2.0 lib/puppet/type/file/group.rb
puppet-8.2.0-x86-mingw32 lib/puppet/type/file/group.rb
puppet-8.2.0-x64-mingw32 lib/puppet/type/file/group.rb
puppet-8.2.0-universal-darwin lib/puppet/type/file/group.rb
puppet-8.1.0 lib/puppet/type/file/group.rb
puppet-8.1.0-x86-mingw32 lib/puppet/type/file/group.rb
puppet-8.1.0-x64-mingw32 lib/puppet/type/file/group.rb
puppet-8.1.0-universal-darwin lib/puppet/type/file/group.rb
puppet-8.0.1 lib/puppet/type/file/group.rb
puppet-8.0.1-x86-mingw32 lib/puppet/type/file/group.rb
puppet-8.0.1-x64-mingw32 lib/puppet/type/file/group.rb
puppet-8.0.1-universal-darwin lib/puppet/type/file/group.rb