aws-codedeploy-agent 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/CHANGES.md +3 -0
- data/Gemfile +13 -0
- data/LICENSE +177 -0
- data/NOTICE +2 -0
- data/README.md +16 -0
- data/aws-codedeploy-agent.gemspec +39 -0
- data/bin/codedeploy-agent +78 -0
- data/bin/codedeploy-install +15 -0
- data/bin/codedeploy-uninstall +13 -0
- data/certs/host-agent-deployment-signer-ca-chain.pem +76 -0
- data/conf/codedeployagent.yml +9 -0
- data/init.d/codedeploy-agent +61 -0
- data/lib/core_ext.rb +71 -0
- data/lib/instance_agent.rb +35 -0
- data/lib/instance_agent/agent/base.rb +34 -0
- data/lib/instance_agent/codedeploy_plugin/application_specification/ace_info.rb +133 -0
- data/lib/instance_agent/codedeploy_plugin/application_specification/acl_info.rb +163 -0
- data/lib/instance_agent/codedeploy_plugin/application_specification/application_specification.rb +142 -0
- data/lib/instance_agent/codedeploy_plugin/application_specification/context_info.rb +23 -0
- data/lib/instance_agent/codedeploy_plugin/application_specification/file_info.rb +23 -0
- data/lib/instance_agent/codedeploy_plugin/application_specification/linux_permission_info.rb +121 -0
- data/lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb +66 -0
- data/lib/instance_agent/codedeploy_plugin/application_specification/range_info.rb +134 -0
- data/lib/instance_agent/codedeploy_plugin/application_specification/script_info.rb +27 -0
- data/lib/instance_agent/codedeploy_plugin/codedeploy_control.rb +72 -0
- data/lib/instance_agent/codedeploy_plugin/command_executor.rb +357 -0
- data/lib/instance_agent/codedeploy_plugin/command_poller.rb +146 -0
- data/lib/instance_agent/codedeploy_plugin/deployment_specification.rb +150 -0
- data/lib/instance_agent/codedeploy_plugin/hook_executor.rb +206 -0
- data/lib/instance_agent/codedeploy_plugin/install_instruction.rb +374 -0
- data/lib/instance_agent/codedeploy_plugin/installer.rb +143 -0
- data/lib/instance_agent/codedeploy_plugin/request_helper.rb +28 -0
- data/lib/instance_agent/config.rb +43 -0
- data/lib/instance_agent/log.rb +3 -0
- data/lib/instance_agent/platform.rb +17 -0
- data/lib/instance_agent/platform/linux_util.rb +57 -0
- data/lib/instance_agent/runner/child.rb +57 -0
- data/lib/instance_agent/runner/master.rb +103 -0
- data/lib/instance_metadata.rb +47 -0
- data/test/certificate_helper.rb +120 -0
- data/test/helpers/instance_agent_helper.rb +25 -0
- data/test/instance_agent/agent/base_test.rb +49 -0
- data/test/instance_agent/codedeploy_plugin/application_specification_test.rb +1710 -0
- data/test/instance_agent/codedeploy_plugin/codedeploy_control_test.rb +51 -0
- data/test/instance_agent/codedeploy_plugin/command_executor_test.rb +513 -0
- data/test/instance_agent/codedeploy_plugin/command_poller_test.rb +459 -0
- data/test/instance_agent/codedeploy_plugin/deployment_specification_test.rb +335 -0
- data/test/instance_agent/codedeploy_plugin/hook_executor_test.rb +250 -0
- data/test/instance_agent/codedeploy_plugin/install_instruction_test.rb +566 -0
- data/test/instance_agent/codedeploy_plugin/installer_test.rb +519 -0
- data/test/instance_agent/codedeploy_plugin/request_helper_test.rb +37 -0
- data/test/instance_agent/config_test.rb +64 -0
- data/test/instance_agent/runner/child_test.rb +87 -0
- data/test/instance_metadata_test.rb +97 -0
- data/test/test_helper.rb +16 -0
- data/vendor/gems/.codedeploy-commands-1.0.0.created.rid +1 -0
- data/vendor/gems/codedeploy-commands/apis/CodeDeployCommand.api.json +372 -0
- data/vendor/gems/codedeploy-commands/codedeploy-commands-1.0.0.gemspec +28 -0
- data/vendor/gems/codedeploy-commands/lib/aws/codedeploy_commands.rb +18 -0
- data/vendor/gems/codedeploy-commands/lib/aws/plugins/certificate_authority.rb +12 -0
- data/vendor/gems/codedeploy-commands/lib/aws/plugins/deploy_control_endpoint.rb +22 -0
- data/vendor/gems/process_manager/README.md +1 -0
- data/vendor/gems/process_manager/lib/blank.rb +153 -0
- data/vendor/gems/process_manager/lib/core_ext.rb +73 -0
- data/vendor/gems/process_manager/lib/process_manager.rb +49 -0
- data/vendor/gems/process_manager/lib/process_manager/child.rb +119 -0
- data/vendor/gems/process_manager/lib/process_manager/config.rb +112 -0
- data/vendor/gems/process_manager/lib/process_manager/log.rb +107 -0
- data/vendor/gems/process_manager/lib/process_manager/master.rb +322 -0
- data/vendor/gems/process_manager/process_manager-0.0.13.gemspec +42 -0
- data/vendor/specifications/aws-sdk-core-2.0.5.gemspec +39 -0
- data/vendor/specifications/builder-3.2.2.gemspec +29 -0
- data/vendor/specifications/codedeploy-commands-1.0.0.gemspec +28 -0
- data/vendor/specifications/gli-2.5.6.gemspec +51 -0
- data/vendor/specifications/jamespath-0.5.1.gemspec +35 -0
- data/vendor/specifications/little-plugger-1.1.3.gemspec +32 -0
- data/vendor/specifications/logging-1.8.1.gemspec +44 -0
- data/vendor/specifications/multi_json-1.7.7.gemspec +30 -0
- data/vendor/specifications/multi_json-1.8.4.gemspec +30 -0
- data/vendor/specifications/multi_xml-0.5.5.gemspec +30 -0
- data/vendor/specifications/process_manager-0.0.13.gemspec +42 -0
- data/vendor/specifications/simple_pid-0.2.1.gemspec +28 -0
- metadata +377 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Init file for codedeploy-agent
|
|
4
|
+
#
|
|
5
|
+
# chkconfig: 2345 98 02
|
|
6
|
+
# description: codedeploy-agent processes the deployments created by AWS CodeDeploy and installs \
|
|
7
|
+
# the deployment artifacts on to this instance.
|
|
8
|
+
|
|
9
|
+
### BEGIN INIT INFO
|
|
10
|
+
# Provides: codedeploy-agent
|
|
11
|
+
# Required-Start: $all
|
|
12
|
+
# Required-Stop: $remote_fs
|
|
13
|
+
# Default-Start: 2 3 4 5
|
|
14
|
+
# Default-Stop: 0 1 6
|
|
15
|
+
# Short-Description: AWS CodeDeploy Host Agent
|
|
16
|
+
# Description: codedeploy-agent processes the deployments created by AWS CodeDeploy and installs
|
|
17
|
+
# the deployment artifacts on to this instance.
|
|
18
|
+
### END INIT INFO
|
|
19
|
+
|
|
20
|
+
RETVAL=0
|
|
21
|
+
|
|
22
|
+
BIN="codedeploy-agent"
|
|
23
|
+
|
|
24
|
+
start() {
|
|
25
|
+
echo -n $"Starting $BIN:"
|
|
26
|
+
nohup $BIN start >/dev/null </dev/null 2>&1 # Try to start the server
|
|
27
|
+
exit $?
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
stop() {
|
|
31
|
+
echo -n $"Stopping $BIN:"
|
|
32
|
+
nohup $BIN stop >/dev/null </dev/null 2>&1 # Try to stop the server
|
|
33
|
+
exit $?
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
status() {
|
|
37
|
+
$BIN status # Status of the server
|
|
38
|
+
exit $?
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
case "$1" in
|
|
42
|
+
start)
|
|
43
|
+
start
|
|
44
|
+
;;
|
|
45
|
+
stop)
|
|
46
|
+
stop
|
|
47
|
+
;;
|
|
48
|
+
restart)
|
|
49
|
+
stop
|
|
50
|
+
start
|
|
51
|
+
;;
|
|
52
|
+
force-reload)
|
|
53
|
+
stop
|
|
54
|
+
start
|
|
55
|
+
;;
|
|
56
|
+
status)
|
|
57
|
+
status
|
|
58
|
+
;;
|
|
59
|
+
*)
|
|
60
|
+
echo $"Usage: $0 {start|stop|status|restart}"
|
|
61
|
+
esac
|
data/lib/core_ext.rb
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
# some of this extentions are used during bootstrapping and don't
|
|
4
|
+
# have access to i.e. activesupport
|
|
5
|
+
#
|
|
6
|
+
# Methods from ruby 1.9 can be removed after migration
|
|
7
|
+
|
|
8
|
+
# 1.9 adds realpath to resolve symlinks; 1.8 doesn't
|
|
9
|
+
# have this method, so we add it so we get resolved symlinks
|
|
10
|
+
# and compatibility
|
|
11
|
+
unless File.respond_to?(:realpath)
|
|
12
|
+
class File #:nodoc:
|
|
13
|
+
def self.realpath path
|
|
14
|
+
return realpath(File.readlink(path)) if symlink?(path)
|
|
15
|
+
path
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Ruby 1.8.7 does not have a 'key' method on Hash
|
|
21
|
+
unless Hash.new.respond_to?(:key)
|
|
22
|
+
class Hash
|
|
23
|
+
def key(value)
|
|
24
|
+
matching = select{|k,v| v == value}
|
|
25
|
+
if matching && matching[0]
|
|
26
|
+
matching[0][0]
|
|
27
|
+
else
|
|
28
|
+
nil
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# taken from ActiveSupport - MIT licensed
|
|
35
|
+
unless Hash.new.respond_to?(:symbolize_keys!)
|
|
36
|
+
class Hash
|
|
37
|
+
def symbolize_keys!
|
|
38
|
+
keys.each do |key|
|
|
39
|
+
self[(key.to_sym rescue key) || key] = delete(key)
|
|
40
|
+
end
|
|
41
|
+
self
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def symbolize_keys
|
|
45
|
+
dup.symbolize_keys!
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# taken from ActiveSupport - MIT licensed
|
|
51
|
+
unless String.new.respond_to?(:demodulize)
|
|
52
|
+
class String
|
|
53
|
+
def demodulize
|
|
54
|
+
path = self.to_s
|
|
55
|
+
if i = path.rindex('::')
|
|
56
|
+
path[(i+2)..-1]
|
|
57
|
+
else
|
|
58
|
+
path
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# taken from ActiveSupport - MIT licensed
|
|
65
|
+
module Kernel
|
|
66
|
+
def singleton_class
|
|
67
|
+
class << self
|
|
68
|
+
self
|
|
69
|
+
end
|
|
70
|
+
end unless respond_to?(:singleton_class)
|
|
71
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require 'core_ext'
|
|
4
|
+
require 'process_manager'
|
|
5
|
+
|
|
6
|
+
unless defined?(InstanceAgent)
|
|
7
|
+
require 'instance_agent/config'
|
|
8
|
+
require 'instance_agent/log'
|
|
9
|
+
require 'instance_agent/platform'
|
|
10
|
+
require 'instance_agent/platform/linux_util'
|
|
11
|
+
require 'instance_agent/agent/base'
|
|
12
|
+
require 'instance_agent/codedeploy_plugin/command_poller'
|
|
13
|
+
require 'instance_agent/codedeploy_plugin/command_executor'
|
|
14
|
+
require 'instance_agent/codedeploy_plugin/deployment_specification'
|
|
15
|
+
require 'instance_agent/codedeploy_plugin/application_specification/application_specification'
|
|
16
|
+
require 'instance_agent/codedeploy_plugin/application_specification/file_info'
|
|
17
|
+
require 'instance_agent/codedeploy_plugin/application_specification/script_info'
|
|
18
|
+
require 'instance_agent/codedeploy_plugin/application_specification/linux_permission_info'
|
|
19
|
+
require 'instance_agent/codedeploy_plugin/application_specification/mode_info'
|
|
20
|
+
require 'instance_agent/codedeploy_plugin/application_specification/acl_info'
|
|
21
|
+
require 'instance_agent/codedeploy_plugin/application_specification/ace_info'
|
|
22
|
+
require 'instance_agent/codedeploy_plugin/application_specification/context_info'
|
|
23
|
+
require 'instance_agent/codedeploy_plugin/application_specification/range_info'
|
|
24
|
+
require 'instance_agent/codedeploy_plugin/install_instruction'
|
|
25
|
+
require 'instance_agent/runner/master'
|
|
26
|
+
require 'instance_agent/runner/child'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
module InstanceAgent
|
|
30
|
+
module Runner
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
module Agent
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module InstanceAgent
|
|
3
|
+
module Agent
|
|
4
|
+
class Base
|
|
5
|
+
|
|
6
|
+
def self.runner
|
|
7
|
+
self.new
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def description
|
|
11
|
+
self.class.to_s
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def log(severity, message)
|
|
15
|
+
raise ArgumentError, "Unknown severity #{severity.inspect}" unless InstanceAgent::Log::SEVERITIES.include?(severity.to_s)
|
|
16
|
+
InstanceAgent::Log.send(severity.to_sym, "#{description}: #{message}")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def run
|
|
20
|
+
perform
|
|
21
|
+
rescue Aws::Errors::MissingCredentialsError
|
|
22
|
+
log(:error, "Missing credentials - please check if this instance was started with an IAM instance profile")
|
|
23
|
+
sleep InstanceAgent::Config.config[:wait_after_error]
|
|
24
|
+
rescue SocketError, Errno::ENETDOWN, Aws::Errors::ServiceError => e
|
|
25
|
+
log(:error, "Cannot reach InstanceService: #{e.class} - #{e.message}")
|
|
26
|
+
sleep InstanceAgent::Config.config[:wait_after_error]
|
|
27
|
+
rescue Exception => e
|
|
28
|
+
log(:error, "Error during perform: #{e.class} - #{e.message} - #{e.backtrace.join("\n")}")
|
|
29
|
+
sleep InstanceAgent::Config.config[:wait_after_error]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
module InstanceAgent
|
|
2
|
+
module CodeDeployPlugin
|
|
3
|
+
module ApplicationSpecification
|
|
4
|
+
|
|
5
|
+
#Helper Class for storing an ace
|
|
6
|
+
class AceInfo
|
|
7
|
+
|
|
8
|
+
attr_reader :default, :type, :name, :read, :write, :execute
|
|
9
|
+
|
|
10
|
+
def initialize(ace, internal=false)
|
|
11
|
+
@default = false
|
|
12
|
+
@type = nil
|
|
13
|
+
@name = ""
|
|
14
|
+
parts = ace.split(":", -1).reverse
|
|
15
|
+
if (parts.length < 2) || (parts.length > 4)
|
|
16
|
+
raise AppSpecValidationException, "invalid acl entry #{ace}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
if (parts.length == 4)
|
|
20
|
+
if !(parts[3].eql?("d") || (parts[3].eql?("default")))
|
|
21
|
+
raise AppSpecValidationException, "invalid acl entry #{ace}"
|
|
22
|
+
end
|
|
23
|
+
@default = true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
if parts.length >= 3
|
|
27
|
+
if parts[2].eql?("d") || (parts[2].eql?("default"))
|
|
28
|
+
if @default
|
|
29
|
+
raise AppSpecValidationException, "invalid acl entry #{ace}"
|
|
30
|
+
end
|
|
31
|
+
@default = true
|
|
32
|
+
elsif parts[2].eql?("m") || parts[2].eql?("mask")
|
|
33
|
+
@type = "mask"
|
|
34
|
+
elsif parts[2].eql?("o") || parts[2].eql?("other")
|
|
35
|
+
@type = "other"
|
|
36
|
+
elsif parts[2].eql?("g") || parts[2].eql?("group")
|
|
37
|
+
@type = "group"
|
|
38
|
+
elsif parts[2].eql?("u") || parts[2].eql?("user")
|
|
39
|
+
@type = "user"
|
|
40
|
+
else
|
|
41
|
+
raise AppSpecValidationException, "invalid acl entry #{ace}"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if parts[1].eql?("m") || parts[1].eql?("mask")
|
|
46
|
+
if @type.nil?
|
|
47
|
+
@type = "mask"
|
|
48
|
+
else
|
|
49
|
+
@name = "mask"
|
|
50
|
+
end
|
|
51
|
+
elsif parts[1].eql?("o") || parts[1].eql?("other")
|
|
52
|
+
if @type.nil?
|
|
53
|
+
@type = "other"
|
|
54
|
+
else
|
|
55
|
+
@name = "other"
|
|
56
|
+
end
|
|
57
|
+
else
|
|
58
|
+
if @type.nil?
|
|
59
|
+
@type = "user"
|
|
60
|
+
end
|
|
61
|
+
@name = parts[1]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
if (@type.eql?("mask") || @type.eql?("other")) && !@name.empty?
|
|
65
|
+
raise AppSpecValidationException, "invalid acl entry #{ace}"
|
|
66
|
+
end
|
|
67
|
+
if (!internal && !@default && !@type.eql?("mask") && @name.empty?)
|
|
68
|
+
raise AppSpecValidationException, "use mode to set the base acl entry #{ace}"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
perm_chars = parts[0].chars.entries
|
|
72
|
+
if (perm_chars.length == 1) && (perm_chars[0].ord >= "0".ord) && (perm_chars[0].ord <= "7".ord)
|
|
73
|
+
perm_bits = to_bits(perm_chars[0].to_i, 3)
|
|
74
|
+
@read = (perm_bits[0] == 1)
|
|
75
|
+
@write = (perm_bits[1] == 1)
|
|
76
|
+
@execute = (perm_bits[2] == 1)
|
|
77
|
+
else
|
|
78
|
+
@read = false
|
|
79
|
+
@write = false
|
|
80
|
+
@execute = false
|
|
81
|
+
perm_chars.each do |perm|
|
|
82
|
+
case perm
|
|
83
|
+
when 'r'
|
|
84
|
+
@read = true
|
|
85
|
+
when 'w'
|
|
86
|
+
@write = true
|
|
87
|
+
when 'x'
|
|
88
|
+
@execute = true
|
|
89
|
+
when '-'
|
|
90
|
+
else
|
|
91
|
+
raise AppSpecValidationException, "unrecognized permission character #{perm} in #{ace}"
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
#format [default:][user|group|mask|other]:[name]:(r|-)(w|-)(x|-)
|
|
98
|
+
def get_ace
|
|
99
|
+
result = "";
|
|
100
|
+
if @default
|
|
101
|
+
result = "default:"
|
|
102
|
+
end
|
|
103
|
+
result = result + type + ":" + name + ":"
|
|
104
|
+
if (@read)
|
|
105
|
+
result = result + "r"
|
|
106
|
+
else
|
|
107
|
+
result = result + "-"
|
|
108
|
+
end
|
|
109
|
+
if (@write)
|
|
110
|
+
result = result + "w"
|
|
111
|
+
else
|
|
112
|
+
result = result + "-"
|
|
113
|
+
end
|
|
114
|
+
if (@execute)
|
|
115
|
+
result = result + "x"
|
|
116
|
+
else
|
|
117
|
+
result = result + "-"
|
|
118
|
+
end
|
|
119
|
+
result
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def to_bits(num, min_size)
|
|
123
|
+
bits = Array.new(min_size, 0)
|
|
124
|
+
num_bits = num.to_s(2).split("")
|
|
125
|
+
diff = [0, min_size - num_bits.length].max
|
|
126
|
+
num_bits.map.with_index {|n,i| bits[i+diff] = n.to_i}
|
|
127
|
+
bits
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
module InstanceAgent
|
|
2
|
+
module CodeDeployPlugin
|
|
3
|
+
module ApplicationSpecification
|
|
4
|
+
|
|
5
|
+
#Helper Class for storing an acl
|
|
6
|
+
class AclInfo
|
|
7
|
+
|
|
8
|
+
attr_reader :aces, :additional
|
|
9
|
+
|
|
10
|
+
def initialize(acl)
|
|
11
|
+
@aces = []
|
|
12
|
+
@additional = []
|
|
13
|
+
acl.each do |ace|
|
|
14
|
+
@aces << AceInfo.new(ace)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
#format [default:][user|group|mask|other]:[name]:(r|-)(w|-)(x|-) (or nil if none present)
|
|
19
|
+
def get_default_ace
|
|
20
|
+
@aces.each do |ace|
|
|
21
|
+
if ace.default
|
|
22
|
+
return ace.get_ace
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
@additional.each do |ace|
|
|
26
|
+
if ace.default
|
|
27
|
+
return ace.get_ace
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
#format array of aces with format: [default:][user|group|mask|other]:[name]:(r|-)(w|-)(x|-)
|
|
34
|
+
def get_acl
|
|
35
|
+
aces = []
|
|
36
|
+
@aces.each do |ace|
|
|
37
|
+
aces << ace.get_ace
|
|
38
|
+
end
|
|
39
|
+
@additional.each do |ace|
|
|
40
|
+
aces << ace.get_ace
|
|
41
|
+
end
|
|
42
|
+
aces
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def add_ace(ace)
|
|
46
|
+
additional << AceInfo.new(ace, true)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def clear_additional()
|
|
50
|
+
additional = []
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def has_base_named?
|
|
54
|
+
@aces.each do |ace|
|
|
55
|
+
if !ace.default && !ace.name.eql?("")
|
|
56
|
+
return true
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
@additional.each do |ace|
|
|
60
|
+
if !ace.default && !ace.name.eql?("")
|
|
61
|
+
return true
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
false
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def has_base_mask?
|
|
68
|
+
@aces.each do |ace|
|
|
69
|
+
if !ace.default && ace.type.eql?("mask")
|
|
70
|
+
return true
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
@additional.each do |ace|
|
|
74
|
+
if !ace.default && ace.type.eql?("mask")
|
|
75
|
+
return true
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
false
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def has_default?
|
|
82
|
+
!get_default_ace.nil?
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def has_default_user?
|
|
86
|
+
@aces.each do |ace|
|
|
87
|
+
if ace.default && ace.type.eql?("user") && ace.name.eql?("")
|
|
88
|
+
return true
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
@additional.each do |ace|
|
|
92
|
+
if ace.default && ace.type.eql?("user") && ace.name.eql?("")
|
|
93
|
+
return true
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
false
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def has_default_group?
|
|
100
|
+
!get_default_group_ace.nil?
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
#format [default:][user|group|mask|other]:[name]:(r|-)(w|-)(x|-) (or nil if not present)
|
|
104
|
+
def get_default_group_ace
|
|
105
|
+
@aces.each do |ace|
|
|
106
|
+
if ace.default && ace.type.eql?("group") && ace.name.eql?("")
|
|
107
|
+
return ace.get_ace
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
@additional.each do |ace|
|
|
111
|
+
if ace.default && ace.type.eql?("group") && ace.name.eql?("")
|
|
112
|
+
return ace.get_ace
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
nil
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def has_default_other?
|
|
119
|
+
@aces.each do |ace|
|
|
120
|
+
if ace.default && ace.type.eql?("other")
|
|
121
|
+
return true
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
@additional.each do |ace|
|
|
125
|
+
if ace.default && ace.type.eql?("other")
|
|
126
|
+
return true
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
false
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def has_default_named?
|
|
133
|
+
@aces.each do |ace|
|
|
134
|
+
if ace.default && !ace.name.eql?("")
|
|
135
|
+
return true
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
@additional.each do |ace|
|
|
139
|
+
if ace.default && !ace.name.eql?("")
|
|
140
|
+
return true
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
false
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def has_default_mask?
|
|
147
|
+
@aces.each do |ace|
|
|
148
|
+
if ace.default && ace.type.eql?("mask")
|
|
149
|
+
return true
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
@additional.each do |ace|
|
|
153
|
+
if ace.default && ace.type.eql?("mask")
|
|
154
|
+
return true
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
false
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|