fluentd 1.11.2 → 1.12.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/workflows/stale-actions.yml +22 -0
- data/.travis.yml +22 -2
- data/CHANGELOG.md +52 -0
- data/appveyor.yml +3 -0
- data/bin/fluent-cap-ctl +7 -0
- data/bin/fluent-ctl +7 -0
- data/fluentd.gemspec +7 -6
- data/lib/fluent/capability.rb +87 -0
- data/lib/fluent/command/cap_ctl.rb +174 -0
- data/lib/fluent/command/ctl.rb +177 -0
- data/lib/fluent/command/plugin_config_formatter.rb +2 -1
- data/lib/fluent/env.rb +4 -0
- data/lib/fluent/log.rb +33 -3
- data/lib/fluent/plugin.rb +5 -0
- data/lib/fluent/plugin/buffer.rb +27 -57
- data/lib/fluent/plugin/buffer/chunk.rb +2 -1
- data/lib/fluent/plugin/formatter.rb +24 -0
- data/lib/fluent/plugin/formatter_csv.rb +1 -1
- data/lib/fluent/plugin/formatter_hash.rb +3 -1
- data/lib/fluent/plugin/formatter_json.rb +3 -1
- data/lib/fluent/plugin/formatter_ltsv.rb +5 -3
- data/lib/fluent/plugin/formatter_out_file.rb +6 -4
- data/lib/fluent/plugin/formatter_single_value.rb +4 -2
- data/lib/fluent/plugin/formatter_tsv.rb +4 -2
- data/lib/fluent/plugin/in_exec.rb +4 -2
- data/lib/fluent/plugin/in_http.rb +23 -2
- data/lib/fluent/plugin/in_tail.rb +109 -41
- data/lib/fluent/plugin/in_tail/position_file.rb +39 -14
- data/lib/fluent/plugin/out_http.rb +20 -2
- data/lib/fluent/plugin/output.rb +15 -6
- data/lib/fluent/plugin/parser_json.rb +5 -2
- data/lib/fluent/plugin_helper/http_server/compat/server.rb +1 -1
- data/lib/fluent/plugin_helper/inject.rb +2 -1
- data/lib/fluent/plugin_helper/retry_state.rb +4 -0
- data/lib/fluent/supervisor.rb +150 -47
- data/lib/fluent/system_config.rb +2 -1
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +22 -4
- data/test/command/test_binlog_reader.rb +22 -6
- data/test/command/test_cap_ctl.rb +100 -0
- data/test/command/test_ctl.rb +57 -0
- data/test/command/test_plugin_config_formatter.rb +57 -2
- data/test/plugin/in_tail/test_position_file.rb +45 -25
- data/test/plugin/test_buffer.rb +4 -0
- data/test/plugin/test_filter_stdout.rb +6 -1
- data/test/plugin/test_formatter_hash.rb +6 -3
- data/test/plugin/test_formatter_json.rb +14 -4
- data/test/plugin/test_formatter_ltsv.rb +13 -5
- data/test/plugin/test_formatter_out_file.rb +35 -14
- data/test/plugin/test_formatter_single_value.rb +12 -6
- data/test/plugin/test_formatter_tsv.rb +12 -4
- data/test/plugin/test_in_exec.rb +18 -0
- data/test/plugin/test_in_http.rb +25 -0
- data/test/plugin/test_in_tail.rb +433 -30
- data/test/plugin/test_out_file.rb +23 -18
- data/test/plugin/test_output.rb +12 -0
- data/test/plugin_helper/test_compat_parameters.rb +7 -2
- data/test/plugin_helper/test_http_server_helper.rb +5 -0
- data/test/plugin_helper/test_inject.rb +13 -0
- data/test/test_capability.rb +74 -0
- data/test/test_formatter.rb +34 -10
- data/test/test_log.rb +44 -0
- data/test/test_output.rb +6 -1
- data/test/test_supervisor.rb +119 -1
- metadata +35 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7233372dc2b1c0ab6ae93682dc0a3ecd8ba2eb4956dfecc2456173cf30729090
|
4
|
+
data.tar.gz: e61aa30c17b3f27322a10fbc4b2e81a219eeeb0f061c4ccfd0b6c8c10777a607
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 737b0727cd390374168ed176a19a73b94d3010a7e93d5951a5580cfbca5bdd697c082afbde07ba1b266edd77be057ec7ccef6ea4383f626e7a11bcf4ad9d9c40
|
7
|
+
data.tar.gz: 94f055d9d2d88359a49caf597bc9076cee741d61e80d84aa3cd1cefe8b01e7ee78721502b5b0dd4e329cb0fceeec952b43b51efd666ee7c9742fc763d1c7cb11
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: "Mark or close stale issues and PRs"
|
2
|
+
on:
|
3
|
+
schedule:
|
4
|
+
- cron: "00 10 * * *"
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
stale:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- uses: actions/stale@v3
|
11
|
+
with:
|
12
|
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
13
|
+
days-before-stale: 90
|
14
|
+
days-before-close: 30
|
15
|
+
stale-issue-message: "This issue has been automatically marked as stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 30 days"
|
16
|
+
stale-pr-message: "This PR has been automatically marked as stale because it has been open 90 days with no activity. Remove stale label or comment or this PR will be closed in 30 days"
|
17
|
+
close-issue-message: "This issue was automatically closed because of stale in 30 days"
|
18
|
+
close-pr-message: "This PR was automatically closed because of stale in 30 days"
|
19
|
+
stale-pr-label: "stale"
|
20
|
+
stale-issue-label: "stale"
|
21
|
+
exempt-issue-labels: "bug,enhancement,feature request,pending,work_in_progress,v1,v2"
|
22
|
+
exempt-pr-labels: "bug,enhancement,feature request,pending,work_in_progress,v1,v2"
|
data/.travis.yml
CHANGED
@@ -9,44 +9,63 @@ matrix:
|
|
9
9
|
include:
|
10
10
|
- rvm: 2.4.9
|
11
11
|
os: linux
|
12
|
+
env: USE_CAPNG=false
|
12
13
|
- rvm: 2.4.9
|
13
14
|
os: linux-ppc64le
|
15
|
+
env: USE_CAPNG=false
|
14
16
|
- rvm: 2.5.7
|
15
17
|
os: linux
|
18
|
+
env: USE_CAPNG=false
|
16
19
|
- rvm: 2.5.7
|
17
20
|
os: linux
|
18
21
|
arch: s390x
|
19
22
|
dist: xenial
|
23
|
+
env: USE_CAPNG=false
|
20
24
|
- rvm: 2.6.5
|
21
25
|
os: linux
|
26
|
+
env: USE_CAPNG=false
|
27
|
+
- rvm: 2.6.6
|
28
|
+
os: linux
|
29
|
+
env: USE_CAPNG=true
|
22
30
|
- rvm: 2.7.0
|
23
31
|
os: linux
|
32
|
+
env: USE_CAPNG=false
|
24
33
|
- rvm: ruby-head
|
25
34
|
os: linux
|
35
|
+
env: USE_CAPNG=false
|
26
36
|
- rvm: ruby-head
|
27
37
|
os: linux-ppc64le
|
38
|
+
env: USE_CAPNG=false
|
28
39
|
- rvm: 2.4.6
|
29
40
|
os: osx
|
30
41
|
osx_image: xcode8.3 # OSX 10.12
|
42
|
+
env: USE_CAPNG=false
|
31
43
|
- rvm: ruby-head
|
32
44
|
os: osx
|
33
45
|
osx_image: xcode8.3 # OSX 10.12
|
46
|
+
env: USE_CAPNG=false
|
34
47
|
allow_failures:
|
35
48
|
- rvm: 2.4.6
|
36
49
|
os: osx
|
37
50
|
osx_image: xcode8.3
|
51
|
+
env: USE_CAPNG=false
|
38
52
|
- rvm: 2.5.7
|
39
53
|
os: linux
|
40
54
|
arch: s390x
|
41
55
|
dist: xenial
|
56
|
+
env: USE_CAPNG=false
|
42
57
|
- rvm: ruby-head
|
58
|
+
env: USE_CAPNG=false
|
43
59
|
|
44
60
|
branches:
|
45
61
|
only:
|
46
62
|
- master
|
47
63
|
|
48
|
-
before_install:
|
49
|
-
|
64
|
+
before_install: |
|
65
|
+
gem update --system=3.1.2
|
66
|
+
if [[ x"${USE_CAPNG}" == "xtrue" ]]; then
|
67
|
+
echo 'gem "capng_c"' >> Gemfile.local
|
68
|
+
fi
|
50
69
|
|
51
70
|
sudo: false
|
52
71
|
dist: trusty # for TLSv1.2 support
|
@@ -55,3 +74,4 @@ addons:
|
|
55
74
|
apt:
|
56
75
|
packages:
|
57
76
|
- libgmp3-dev
|
77
|
+
- libcap-ng-dev
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,57 @@
|
|
1
1
|
# v1.11
|
2
2
|
|
3
|
+
## Release v1.11.5 - 2020/11/06
|
4
|
+
|
5
|
+
### Enhancement
|
6
|
+
|
7
|
+
* formatter: Provide `newline` parameter to support `CRLF`
|
8
|
+
https://github.com/fluent/fluentd/pull/3152
|
9
|
+
* out_http: adding support for intermediate certificates
|
10
|
+
https://github.com/fluent/fluentd/pull/3146
|
11
|
+
* Update serverengine dependency to 2.2.2 or later
|
12
|
+
|
13
|
+
### Bug fix
|
14
|
+
|
15
|
+
* Fix a bug that windows service isn't stopped gracefuly
|
16
|
+
https://github.com/fluent/fluentd/pull/3156
|
17
|
+
|
18
|
+
## Release v1.11.4 - 2020/10/13
|
19
|
+
|
20
|
+
### Enhancement
|
21
|
+
|
22
|
+
* inject: Support `unixtime_millis` in `time_type` parameter
|
23
|
+
https://github.com/fluent/fluentd/pull/3145
|
24
|
+
|
25
|
+
### Bug fix
|
26
|
+
|
27
|
+
* out_http: Fix broken data with `json_array true`
|
28
|
+
https://github.com/fluent/fluentd/pull/3144
|
29
|
+
* output: Fix wrong logging issue for `${chunk_id}`
|
30
|
+
https://github.com/fluent/fluentd/pull/3134
|
31
|
+
|
32
|
+
## Release v1.11.3 - 2020/09/30
|
33
|
+
|
34
|
+
### Enhancement
|
35
|
+
|
36
|
+
* in_exec: Add `connect_mode` parameter to read stderr
|
37
|
+
https://github.com/fluent/fluentd/pull/3108
|
38
|
+
* parser_json: Improve the performance
|
39
|
+
https://github.com/fluent/fluentd/pull/3109
|
40
|
+
* log: Add `ignore_same_log_interval` parameter
|
41
|
+
https://github.com/fluent/fluentd/pull/3119
|
42
|
+
* Upgrade win32 gems
|
43
|
+
https://github.com/fluent/fluentd/pull/3100
|
44
|
+
* Refactoring code
|
45
|
+
https://github.com/fluent/fluentd/pull/3094
|
46
|
+
https://github.com/fluent/fluentd/pull/3118
|
47
|
+
|
48
|
+
### Bug fix
|
49
|
+
|
50
|
+
* buffer: Fix calculation of timekey stats
|
51
|
+
https://github.com/fluent/fluentd/pull/3018
|
52
|
+
* buffer: fix binmode usage for prevent gc
|
53
|
+
https://github.com/fluent/fluentd/pull/3138
|
54
|
+
|
3
55
|
## Release v1.11.2 - 2020/08/04
|
4
56
|
|
5
57
|
### Enhancement
|
data/appveyor.yml
CHANGED
@@ -7,6 +7,9 @@ install:
|
|
7
7
|
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
8
8
|
- ruby --version
|
9
9
|
- gem --version
|
10
|
+
# stay 0.14.0 for Windows CI until https://github.com/socketry/protocol-http2/issues/6 will be fixed
|
11
|
+
- ps: Write-Output "gem 'protocol-http2', ['<= 0.14.0']" | Out-File -FilePath Gemfile.local -Encoding default
|
12
|
+
- type Gemfile.local
|
10
13
|
- ridk.cmd exec bundle install
|
11
14
|
build: off
|
12
15
|
test_script:
|
data/bin/fluent-cap-ctl
ADDED
data/bin/fluent-ctl
ADDED
data/fluentd.gemspec
CHANGED
@@ -18,10 +18,11 @@ Gem::Specification.new do |gem|
|
|
18
18
|
|
19
19
|
gem.required_ruby_version = '>= 2.4'
|
20
20
|
|
21
|
+
gem.add_runtime_dependency("bundler")
|
21
22
|
gem.add_runtime_dependency("msgpack", [">= 1.3.1", "< 2.0.0"])
|
22
23
|
gem.add_runtime_dependency("yajl-ruby", ["~> 1.0"])
|
23
24
|
gem.add_runtime_dependency("cool.io", [">= 1.4.5", "< 2.0.0"])
|
24
|
-
gem.add_runtime_dependency("serverengine", [">= 2.
|
25
|
+
gem.add_runtime_dependency("serverengine", [">= 2.2.2", "< 3.0.0"])
|
25
26
|
gem.add_runtime_dependency("http_parser.rb", [">= 0.5.1", "< 0.7.0"])
|
26
27
|
gem.add_runtime_dependency("sigdump", ["~> 0.2.2"])
|
27
28
|
gem.add_runtime_dependency("tzinfo", [">= 1.0", "< 3.0"])
|
@@ -32,11 +33,11 @@ Gem::Specification.new do |gem|
|
|
32
33
|
fake_platform = ENV['GEM_BUILD_FAKE_PLATFORM'].to_s
|
33
34
|
gem.platform = fake_platform unless fake_platform.empty?
|
34
35
|
if /mswin|mingw/ =~ fake_platform || (/mswin|mingw/ =~ RUBY_PLATFORM && fake_platform.empty?)
|
35
|
-
gem.add_runtime_dependency("win32-service", ["~>
|
36
|
-
gem.add_runtime_dependency("win32-ipc", ["~> 0.
|
37
|
-
gem.add_runtime_dependency("win32-event", ["~> 0.6.
|
38
|
-
gem.add_runtime_dependency("windows-pr", ["~> 1.2.
|
39
|
-
gem.add_runtime_dependency("certstore_c", ["~> 0.1.
|
36
|
+
gem.add_runtime_dependency("win32-service", ["~> 2.1.5"])
|
37
|
+
gem.add_runtime_dependency("win32-ipc", ["~> 0.7.0"])
|
38
|
+
gem.add_runtime_dependency("win32-event", ["~> 0.6.3"])
|
39
|
+
gem.add_runtime_dependency("windows-pr", ["~> 1.2.6"])
|
40
|
+
gem.add_runtime_dependency("certstore_c", ["~> 0.1.7"])
|
40
41
|
end
|
41
42
|
|
42
43
|
gem.add_development_dependency("rake", ["~> 13.0"])
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#
|
2
|
+
# Fluent
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require "fluent/env"
|
18
|
+
|
19
|
+
if Fluent.linux?
|
20
|
+
begin
|
21
|
+
require 'capng'
|
22
|
+
rescue LoadError
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Fluent
|
27
|
+
if defined?(CapNG)
|
28
|
+
class Capability
|
29
|
+
def initialize(target = nil, pid = nil)
|
30
|
+
@capng = CapNG.new(target, pid)
|
31
|
+
end
|
32
|
+
|
33
|
+
def usable?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
def apply(select_set)
|
38
|
+
@capng.apply(select_set)
|
39
|
+
end
|
40
|
+
|
41
|
+
def clear(select_set)
|
42
|
+
@capng.clear(select_set)
|
43
|
+
end
|
44
|
+
|
45
|
+
def have_capability?(type, capability)
|
46
|
+
@capng.have_capability?(type, capability)
|
47
|
+
end
|
48
|
+
|
49
|
+
def update(action, type, capability_or_capability_array)
|
50
|
+
@capng.update(action, type, capability_or_capability_array)
|
51
|
+
end
|
52
|
+
|
53
|
+
def have_capabilities?(select_set)
|
54
|
+
@capng.have_capabilities?(select_set)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
else
|
58
|
+
class Capability
|
59
|
+
def initialize(target = nil, pid = nil)
|
60
|
+
end
|
61
|
+
|
62
|
+
def usable?
|
63
|
+
false
|
64
|
+
end
|
65
|
+
|
66
|
+
def apply(select_set)
|
67
|
+
false
|
68
|
+
end
|
69
|
+
|
70
|
+
def clear(select_set)
|
71
|
+
false
|
72
|
+
end
|
73
|
+
|
74
|
+
def have_capability?(type, capability)
|
75
|
+
false
|
76
|
+
end
|
77
|
+
|
78
|
+
def update(action, type, capability_or_capability_array)
|
79
|
+
false
|
80
|
+
end
|
81
|
+
|
82
|
+
def have_capabilities?(select_set)
|
83
|
+
false
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'optparse'
|
18
|
+
require 'fluent/log'
|
19
|
+
require 'fluent/env'
|
20
|
+
require 'fluent/capability'
|
21
|
+
|
22
|
+
module Fluent
|
23
|
+
class CapCtl
|
24
|
+
def prepare_option_parser
|
25
|
+
@op = OptionParser.new
|
26
|
+
|
27
|
+
@op.on('--clear', "Clear Fluentd Ruby capability") {|s|
|
28
|
+
@opts[:clear_capabilities] = true
|
29
|
+
}
|
30
|
+
|
31
|
+
@op.on('--add [CAPABILITITY1,CAPABILITY2, ...]', "Add capabilities into Fluentd Ruby") {|s|
|
32
|
+
@opts[:add_capabilities] = s
|
33
|
+
}
|
34
|
+
|
35
|
+
@op.on('--drop [CAPABILITITY1,CAPABILITY2, ...]', "Drop capabilities from Fluentd Ruby") {|s|
|
36
|
+
@opts[:drop_capabilities] = s
|
37
|
+
}
|
38
|
+
|
39
|
+
@op.on('--get', "Get capabilities for Fluentd Ruby") {|s|
|
40
|
+
@opts[:get_capabilities] = true
|
41
|
+
}
|
42
|
+
|
43
|
+
@op.on('-f', '--file FILE', "Specify target file to add Linux capabilities") {|s|
|
44
|
+
@opts[:target_file] = s
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def usage(msg)
|
49
|
+
puts @op.to_s
|
50
|
+
puts "error: #{msg}" if msg
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
54
|
+
def initialize(argv = ARGV)
|
55
|
+
@opts = {}
|
56
|
+
@argv = argv
|
57
|
+
|
58
|
+
if Fluent.linux?
|
59
|
+
begin
|
60
|
+
require 'capng'
|
61
|
+
|
62
|
+
@capng = CapNG.new
|
63
|
+
rescue LoadError
|
64
|
+
puts "Error: capng_c is not loaded. Please install it first."
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
else
|
68
|
+
puts "Error: This environment is not supported."
|
69
|
+
exit 2
|
70
|
+
end
|
71
|
+
|
72
|
+
prepare_option_parser
|
73
|
+
end
|
74
|
+
|
75
|
+
def call
|
76
|
+
parse_options!(@argv)
|
77
|
+
|
78
|
+
target_file = if !!@opts[:target_file]
|
79
|
+
@opts[:target_file]
|
80
|
+
else
|
81
|
+
File.readlink("/proc/self/exe")
|
82
|
+
end
|
83
|
+
|
84
|
+
if @opts[:clear_capabilities]
|
85
|
+
clear_capabilities(@opts, target_file)
|
86
|
+
elsif @opts[:add_capabilities]
|
87
|
+
add_capabilities(@opts, target_file)
|
88
|
+
elsif @opts[:drop_capabilities]
|
89
|
+
drop_capabilities(@opts, target_file)
|
90
|
+
end
|
91
|
+
if @opts[:get_capabilities]
|
92
|
+
get_capabilities(@opts, target_file)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def clear_capabilities(opts, target_file)
|
97
|
+
if !!opts[:clear_capabilities]
|
98
|
+
@capng.clear(:caps)
|
99
|
+
ret = @capng.apply_caps_file(target_file)
|
100
|
+
puts "Clear capabilities #{ret ? 'done' : 'fail'}."
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def add_capabilities(opts, target_file)
|
105
|
+
if add_caps = opts[:add_capabilities]
|
106
|
+
@capng.clear(:caps)
|
107
|
+
@capng.caps_file(target_file)
|
108
|
+
capabilities = add_caps.split(/\s*,\s*/)
|
109
|
+
check_capabilities(capabilities, get_valid_capabilities)
|
110
|
+
ret = @capng.update(:add,
|
111
|
+
CapNG::Type::EFFECTIVE | CapNG::Type::INHERITABLE | CapNG::Type::PERMITTED,
|
112
|
+
capabilities)
|
113
|
+
puts "Updating #{add_caps} #{ret ? 'done' : 'fail'}."
|
114
|
+
ret = @capng.apply_caps_file(target_file)
|
115
|
+
puts "Adding #{add_caps} #{ret ? 'done' : 'fail'}."
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def drop_capabilities(opts, target_file)
|
120
|
+
if drop_caps = opts[:drop_capabilities]
|
121
|
+
@capng.clear(:caps)
|
122
|
+
@capng.caps_file(target_file)
|
123
|
+
capabilities = drop_caps.split(/\s*,\s*/)
|
124
|
+
check_capabilities(capabilities, get_valid_capabilities)
|
125
|
+
ret = @capng.update(:drop,
|
126
|
+
CapNG::Type::EFFECTIVE | CapNG::Type::INHERITABLE | CapNG::Type::PERMITTED,
|
127
|
+
capabilities)
|
128
|
+
puts "Updating #{drop_caps} #{ret ? 'done' : 'fail'}."
|
129
|
+
@capng.apply_caps_file(target_file)
|
130
|
+
puts "Dropping #{drop_caps} #{ret ? 'done' : 'fail'}."
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def get_capabilities(opts, target_file)
|
135
|
+
if opts[:get_capabilities]
|
136
|
+
@capng.caps_file(target_file)
|
137
|
+
print = CapNG::Print.new
|
138
|
+
puts "Capabilities in '#{target_file}',"
|
139
|
+
puts "Effective: #{print.caps_text(:buffer, :effective)}"
|
140
|
+
puts "Inheritable: #{print.caps_text(:buffer, :inheritable)}"
|
141
|
+
puts "Permitted: #{print.caps_text(:buffer, :permitted)}"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def get_valid_capabilities
|
146
|
+
capabilities = []
|
147
|
+
cap = CapNG::Capability.new
|
148
|
+
cap.each do |_code, capability|
|
149
|
+
capabilities << capability
|
150
|
+
end
|
151
|
+
capabilities
|
152
|
+
end
|
153
|
+
|
154
|
+
def check_capabilities(capabilities, valid_capabilities)
|
155
|
+
capabilities.each do |capability|
|
156
|
+
unless valid_capabilities.include?(capability)
|
157
|
+
raise ArgumentError, "'#{capability}' is not valid capability. Valid Capabilities are: #{valid_capabilities.join(", ")}"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def parse_options!(argv)
|
163
|
+
begin
|
164
|
+
rest = @op.parse(argv)
|
165
|
+
|
166
|
+
if rest.length != 0
|
167
|
+
usage nil
|
168
|
+
end
|
169
|
+
rescue
|
170
|
+
usage $!.to_s
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|