Class: InstanceAgent::Plugins::CodeDeployPlugin::ChangeAclCommand
- Inherits:
-
Object
- Object
- InstanceAgent::Plugins::CodeDeployPlugin::ChangeAclCommand
- Defined in:
- lib/instance_agent/plugins/codedeploy/install_instruction.rb
Instance Method Summary collapse
- #clear_full_acl ⇒ Object
- #execute(cleanup_file) ⇒ Object
- #get_full_acl ⇒ Object
-
#initialize(object, acl) ⇒ ChangeAclCommand
constructor
A new instance of ChangeAclCommand.
- #to_h ⇒ Object
Constructor Details
#initialize(object, acl) ⇒ ChangeAclCommand
Returns a new instance of ChangeAclCommand.
276 277 278 279 |
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 276 def initialize(object, acl) @object = object @acl = acl end |
Instance Method Details
#clear_full_acl ⇒ Object
293 294 295 |
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 293 def clear_full_acl @acl.clear_additional end |
#execute(cleanup_file) ⇒ Object
281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 281 def execute(cleanup_file) begin get_full_acl acl = @acl.get_acl.join(",") if !system("setfacl --set #{acl} #{@object}") raise "Unable to set acl correctly: setfacl --set #{acl} #{@object}, exit code: #{$?}" end ensure clear_full_acl end end |
#get_full_acl ⇒ Object
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 297 def get_full_acl() perm = "%o" % File.stat(@object).mode perm = perm[-3,3] @acl.add_ace(":#{perm[0]}") @acl.add_ace("g::#{perm[1]}") @acl.add_ace("o::#{perm[2]}") if @acl.has_base_named? && !@acl.has_base_mask? @acl.add_ace("m::#{perm[1]}") end if @acl.has_default? if !@acl.has_default_user? @acl.add_ace("d::#{perm[0]}") end if !@acl.has_default_group? @acl.add_ace("d:g::#{perm[1]}") end if !@acl.has_default_other? @acl.add_ace("d:o:#{perm[2]}") end if @acl.has_default_named? && !@acl.has_default_mask? @acl.add_ace(@acl.get_default_group_ace.sub("group:","mask")) end end end |
#to_h ⇒ Object
322 323 324 |
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 322 def to_h {:type => :setfacl, :acl => @acl.get_acl, :file => @object} end |