Skip to content

Commit

Permalink
(PUP-7126) Add pre_resource_eval in POSIX file provider
Browse files Browse the repository at this point in the history
This commit adds pre_reosurce_eval to the POSIX file provider. This function is
a class function that when called & when SELinux is supported, will setup and
create a SELinux handle. More information about this function can be found in
this PR: #9376.
  • Loading branch information
AriaXLi committed Jun 3, 2024
1 parent fd32e68 commit 4dcd489
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/puppet/provider/file/posix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,21 @@
require 'etc'
require_relative '../../../puppet/util/selinux'

def self.post_resource_eval
Selinux.matchpathcon_fini if Puppet::Util::SELinux.selinux_support?
class << self
# @return [non-NULL handle value] A handle for selinux
attr_reader :selinux_handle

def pre_resource_eval
@selinux_handle = if Puppet::Util::SELinux.selinux_support?
Selinux.selabel_open(0, nil, 0)
else
nil
end
end

def self.post_resource_eval
Selinux.matchpathcon_fini if Puppet::Util::SELinux.selinux_support?
end
end

def uid2name(id)
Expand Down

0 comments on commit 4dcd489

Please sign in to comment.