Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dont set ACLs if there are no ACLs to change #108

Merged
merged 2 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/puppet/provider/posix_acl/posixacl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def permission=(_value)
end
end
end
set_perm(perm_to_set, @resource.value(:path))
# It's possible we don't have any perms to set if we only removed some
set_perm(perm_to_set, @resource.value(:path)) unless perm_to_set_check.empty?
end
end
end
101 changes: 101 additions & 0 deletions spec/acceptance/updating_posix_acl_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'updating posix_acls' do
context 'on a simple acl with an additional user' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
include posix_acl::requirements
user { ['blub', 'blub2']:
ensure => 'present',
}
file { '/opt/test3':
ensure => directory,
owner => root,
group => root,
mode => '2770',
}
-> posix_acl { '/opt/test3':
action => exact,
permission => [
'user::rwx',
'group::rwx',
'mask::rwx',
'other::---',
'user:blub:r-x',
],
provider => posixacl,
recursive => false,
require => User['blub'],
}
PUPPET
end
end
end

context 'on adding ACLs without overwriting existing ACLs' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
include posix_acl::requirements
user { ['blub', 'blub2']:
ensure => 'present',
}
file { '/opt/test3':
ensure => directory,
owner => root,
group => root,
mode => '2770',
}
-> posix_acl { '/opt/test3':
action => set,
permission => [
'user::rwx',
'group::rwx',
'mask::rwx',
'other::---',
'user:blub2:r-x',
],
provider => posixacl,
recursive => false,
require => User['blub2'],
}
PUPPET
end
end
end

context 'on adding ACLs with overwriting existing ACLs' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
include posix_acl::requirements
user { ['blub', 'blub2']:
ensure => 'present',
}
file { '/opt/test3':
ensure => directory,
owner => root,
group => root,
mode => '2770',
}
-> posix_acl { '/opt/test3':
action => exact,
permission => [
'user::rwx',
'group::rwx',
'mask::rwx',
'other::---',
'user:blub2:r-x',
],
provider => posixacl,
recursive => false,
require => User['blub2'],
}
PUPPET
end
end
end
end