capng_c 0.1.4 → 0.1.5
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.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/capng_c.gemspec +1 -1
- data/example/process_capability_without_root.rb +36 -0
- data/ext/capng/enum.c +3 -0
- data/lib/capng/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46ab5a21fef03d5b25db0124526add7f625acc865ae10da0f8614b6290b5aec0
|
4
|
+
data.tar.gz: cae7565475f00217336124b3c1d0bad6fd3772470e3c8e2605ebac09bac87829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90fab6a90550512222604afee7896c75b766559d39f3288cad6191fb5b1192f080efc4bec6deef2c00377da4f7e8d129ec928191d67fa9277aac505652064b59
|
7
|
+
data.tar.gz: eee3466a6e594b8b5d4fa1835c7650a6d7669cb20be1410c32c8e0b2d878d197263848ec2f1ea7923088428611a78400569f9be55ea16a4c0115ee3b6cd8547d
|
data/README.md
CHANGED
@@ -20,6 +20,10 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install capng_c
|
22
22
|
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
The usage examples are put in [example directory](example).
|
26
|
+
|
23
27
|
## Development
|
24
28
|
|
25
29
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/capng_c.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = %q{libcap-ng bindings for Ruby.}
|
12
12
|
spec.description = spec.summary
|
13
13
|
spec.homepage = "https://github.com/cosmo0920/cap-ng_c"
|
14
|
-
|
14
|
+
spec.license = "Apache-2.0"
|
15
15
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Copyright 2020- Hiroshi Hatake
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'capng'
|
16
|
+
|
17
|
+
capng = CapNG.new(:current_process)
|
18
|
+
unless capng.have_capability?(:effective, :dac_read_search)
|
19
|
+
puts "This example needs to setup :dac_read_search capability on running Ruby executable."
|
20
|
+
exit 2
|
21
|
+
end
|
22
|
+
|
23
|
+
print = CapNG::Print.new
|
24
|
+
puts "capability: #{print.caps_text(:buffer, :effective)}"
|
25
|
+
target_file = ARGV[0] || "/var/log/syslog"
|
26
|
+
|
27
|
+
path = "/var/log/syslog"
|
28
|
+
unless File.readable?(path)
|
29
|
+
puts "-----unreadable!!!!-----\ntarget: #{target_file}"
|
30
|
+
end
|
31
|
+
if capng.have_capability?(:effective, :dac_read_search)
|
32
|
+
contents = File.read(target_file)
|
33
|
+
if contents.length >= 0
|
34
|
+
puts "succeeded to read: #{target_file} w/o root user"
|
35
|
+
end
|
36
|
+
end
|
data/ext/capng/enum.c
CHANGED
@@ -55,5 +55,8 @@ void Init_capng_enum(VALUE rb_cCapNG)
|
|
55
55
|
rb_define_const(rb_mFlags, "NO_FLAG", LONG2NUM(CAPNG_NO_FLAG));
|
56
56
|
rb_define_const(rb_mFlags, "DROP_SUPP_GRP", LONG2NUM(CAPNG_DROP_SUPP_GRP));
|
57
57
|
rb_define_const(rb_mFlags, "CLEAR_BOUNDING", LONG2NUM(CAPNG_CLEAR_BOUNDING));
|
58
|
+
#if defined(CAPNG_INIT_SUPP_GRP)
|
59
|
+
// Ubuntu Trusty's libcap-ng-dev doesn't have CAPNG_INIT_SUPP_GRP constant.
|
58
60
|
rb_define_const(rb_mFlags, "INIT_SUPP_GRP", LONG2NUM(CAPNG_INIT_SUPP_GRP));
|
61
|
+
#endif
|
59
62
|
}
|
data/lib/capng/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capng_c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Hatake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- capng_c.gemspec
|
92
92
|
- example/file_capability.rb
|
93
93
|
- example/process_capability.rb
|
94
|
+
- example/process_capability_without_root.rb
|
94
95
|
- ext/capng/capability.c
|
95
96
|
- ext/capng/capng.c
|
96
97
|
- ext/capng/capng.h
|
@@ -102,7 +103,8 @@ files:
|
|
102
103
|
- lib/capng.rb
|
103
104
|
- lib/capng/version.rb
|
104
105
|
homepage: https://github.com/cosmo0920/cap-ng_c
|
105
|
-
licenses:
|
106
|
+
licenses:
|
107
|
+
- Apache-2.0
|
106
108
|
metadata:
|
107
109
|
allowed_push_host: https://rubygems.org
|
108
110
|
homepage_uri: https://github.com/cosmo0920/cap-ng_c
|