class InstanceAgent::Plugins::CodeDeployPlugin::ChangeContextCommand
Public Class Methods
new(object, context)
click to toggle source
# File lib/instance_agent/plugins/codedeploy/install_instruction.rb, line 348 def initialize(object, context) @object = object @context = context end
Public Instance Methods
execute(cleanup_file)
click to toggle source
# File lib/instance_agent/plugins/codedeploy/install_instruction.rb, line 353 def execute(cleanup_file) if !@context.role.nil? raise "Attempt to set role on object, not supported" end args = "-t #{@context.type}" if (!@context.user.nil?) args = "-s #{@context.user} " + args end if (!@context.range.nil?) args = args + " -r #{@context.range.get_range}" end object = File.realpath(@object) if !system("semanage fcontext -a #{args} #{object}") raise "Unable to set context: semanage fcontext -a #{args} #{object}, exit code: #{$?}" end if !system("restorecon -v #{object}") raise "Unable to apply context: restorcecon -v #{object}, exit code: #{$?}" end cleanup_file.puts("semanage\0#{object}") end
to_h()
click to toggle source
# File lib/instance_agent/plugins/codedeploy/install_instruction.rb, line 375 def to_h {:type => :semanage, :context => {:user => @context.user, :role => @context.role, :type => @context.type, :range => @context.range.get_range}, :file => @object} end