capng_c 0.1.2 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,25 +11,41 @@
11
11
  /* See the License for the specific language governing permissions and */
12
12
  /* limitations under the License. */
13
13
 
14
+ /* clang-format off */
15
+ /*
16
+ * Document-class: CapNG::State
17
+ *
18
+ * Handle CapNG state.
19
+ *
20
+ * @example
21
+ * require 'capng'
22
+ *
23
+ * @state = CapNG::State.new
24
+ * @state.save
25
+ * # Some capability operations
26
+ * @state.restore
27
+ */
28
+ /* clang-format on */
29
+
14
30
  #include <capng.h>
15
31
 
16
- struct CapNGState {
17
- void *state;
32
+ struct CapNGState
33
+ {
34
+ void* state;
18
35
  };
19
36
 
20
- static void capng_state_free(void* capng);
21
-
22
- static const rb_data_type_t rb_capng_state_type = {
23
- "capng/state",
24
- {
25
- 0,
26
- capng_state_free,
27
- 0,
28
- },
29
- NULL,
30
- NULL,
31
- RUBY_TYPED_FREE_IMMEDIATELY
32
- };
37
+ static void
38
+ capng_state_free(void* capng);
39
+
40
+ static const rb_data_type_t rb_capng_state_type = { "capng/state",
41
+ {
42
+ 0,
43
+ capng_state_free,
44
+ 0,
45
+ },
46
+ NULL,
47
+ NULL,
48
+ RUBY_TYPED_FREE_IMMEDIATELY };
33
49
 
34
50
  static void
35
51
  capng_state_free(void* ptr)
@@ -42,11 +58,17 @@ rb_capng_state_alloc(VALUE klass)
42
58
  {
43
59
  VALUE obj;
44
60
  struct CapNGState* capng_state;
45
- obj = TypedData_Make_Struct(
46
- klass, struct CapNGState, &rb_capng_state_type, capng_state);
61
+ obj =
62
+ TypedData_Make_Struct(klass, struct CapNGState, &rb_capng_state_type, capng_state);
47
63
  return obj;
48
64
  }
49
65
 
66
+ /*
67
+ * Initalize State class.
68
+ *
69
+ * @return [nil]
70
+ *
71
+ */
50
72
  static VALUE
51
73
  rb_capng_state_initialize(VALUE self)
52
74
  {
@@ -58,12 +80,17 @@ rb_capng_state_initialize(VALUE self)
58
80
  return Qnil;
59
81
  }
60
82
 
61
-
83
+ /*
84
+ * Save current capability state.
85
+ *
86
+ * @return [nil]
87
+ *
88
+ */
62
89
  static VALUE
63
90
  rb_capng_state_save(VALUE self)
64
91
  {
65
92
  struct CapNGState* capng_state;
66
- void *state = NULL;
93
+ void* state = NULL;
67
94
 
68
95
  TypedData_Get_Struct(self, struct CapNGState, &rb_capng_state_type, capng_state);
69
96
 
@@ -73,11 +100,18 @@ rb_capng_state_save(VALUE self)
73
100
  return Qnil;
74
101
  }
75
102
 
103
+ /*
104
+ * Restore saved capability state.
105
+ *
106
+ * @return [nil]
107
+ *
108
+ */
109
+
76
110
  static VALUE
77
111
  rb_capng_state_restore(VALUE self)
78
112
  {
79
113
  struct CapNGState* capng_state;
80
- void *state = NULL;
114
+ void* state = NULL;
81
115
 
82
116
  TypedData_Get_Struct(self, struct CapNGState, &rb_capng_state_type, capng_state);
83
117
 
@@ -90,7 +124,7 @@ rb_capng_state_restore(VALUE self)
90
124
  void
91
125
  Init_capng_state(VALUE rb_cCapNG)
92
126
  {
93
- rb_cState = rb_define_class_under(rb_cCapNG, "State", rb_cObject);
127
+ VALUE rb_cState = rb_define_class_under(rb_cCapNG, "State", rb_cObject);
94
128
 
95
129
  rb_define_alloc_func(rb_cState, rb_capng_state_alloc);
96
130
 
@@ -14,7 +14,7 @@
14
14
  #include <capng.h>
15
15
 
16
16
  capng_select_t
17
- select_name_to_select_type(char *select_name)
17
+ select_name_to_select_type(char* select_name)
18
18
  {
19
19
  if (strcmp(select_name, "caps") == 0) {
20
20
  return CAPNG_SELECT_CAPS;
@@ -22,11 +22,11 @@ select_name_to_select_type(char *select_name)
22
22
  return CAPNG_SELECT_BOUNDS;
23
23
  } else if (strcmp(select_name, "both") == 0) {
24
24
  return CAPNG_SELECT_BOTH;
25
- #if defined(CAPNG_SELECT_AMBIENT)
25
+ #if defined(HAVE_CONST_CAPNG_SELECT_AMBIENT)
26
26
  } else if (strcmp(select_name, "ambient") == 0) {
27
27
  return CAPNG_SELECT_AMBIENT;
28
28
  #endif
29
- #if defined(CAPNG_SELECT_ALL)
29
+ #if defined(HAVE_CONST_CAPNG_SELECT_ALL)
30
30
  } else if (strcmp(select_name, "all") == 0) {
31
31
  return CAPNG_SELECT_ALL;
32
32
  #endif
@@ -36,7 +36,7 @@ select_name_to_select_type(char *select_name)
36
36
  }
37
37
 
38
38
  capng_act_t
39
- action_name_to_action_type(char *action_name)
39
+ action_name_to_action_type(char* action_name)
40
40
  {
41
41
  if (strcmp(action_name, "drop") == 0) {
42
42
  return CAPNG_DROP;
@@ -48,7 +48,7 @@ action_name_to_action_type(char *action_name)
48
48
  }
49
49
 
50
50
  capng_print_t
51
- print_name_to_print_type(char *print_name)
51
+ print_name_to_print_type(char* print_name)
52
52
  {
53
53
  if (strcmp(print_name, "stdout") == 0) {
54
54
  return CAPNG_PRINT_STDOUT;
@@ -60,7 +60,7 @@ print_name_to_print_type(char *print_name)
60
60
  }
61
61
 
62
62
  capng_type_t
63
- capability_type_name_to_capability_type(char *capability_name)
63
+ capability_type_name_to_capability_type(char* capability_name)
64
64
  {
65
65
  if (strcmp(capability_name, "effective") == 0) {
66
66
  return CAPNG_EFFECTIVE;
@@ -70,7 +70,7 @@ capability_type_name_to_capability_type(char *capability_name)
70
70
  return CAPNG_INHERITABLE;
71
71
  } else if (strcmp(capability_name, "bounding_set") == 0) {
72
72
  return CAPNG_BOUNDING_SET;
73
- #if defined(CAPNG_AMBIENT)
73
+ #if defined(HAVE_CONST_CAPNG_AMBIENT)
74
74
  } else if (strcmp(capability_name, "ambient") == 0) {
75
75
  return CAPNG_AMBIENT;
76
76
  #endif
@@ -2,24 +2,31 @@ require "capng/capng"
2
2
  require "capng/version"
3
3
 
4
4
  class CapNG
5
+ # Predefined Error class.
5
6
  class Error < StandardError; end
6
7
 
8
+ # :nodoc:
9
+ # @private
7
10
  alias_method :caps_file_raw, :caps_file
11
+ # :nodoc:
12
+ # @private
8
13
  alias_method :apply_caps_file_raw, :apply_caps_file
14
+ # :nodoc:
15
+ # @private
9
16
  alias_method :update_raw, :update
17
+ # :nodoc:
18
+ # @private
10
19
  alias_method :initialize_raw, :initialize
11
20
 
12
21
  def initialize(target = nil, pid_or_path = nil)
13
- if target.nil?
14
- initialize_raw
15
- elsif target && pid_or_path.is_a?(Integer)
22
+ if target && pid_or_path.is_a?(Integer)
16
23
  initialize_raw(target, pid_or_path)
17
24
  elsif target && pid_or_path.is_a?(String) && File.exist?(pid_or_path)
18
- File.open(pid_or_path) do
19
- initialize_raw(target, pid_or_path);
25
+ File.open(pid_or_path) do |file|
26
+ initialize_raw(target, file);
20
27
  end
21
28
  else
22
- initialize_raw
29
+ initialize_raw(target, pid_or_path)
23
30
  end
24
31
  end
25
32
 
@@ -38,7 +45,7 @@ class CapNG
38
45
  def apply_caps_file(file_or_string_path)
39
46
  if file_or_string_path.is_a?(String) && File.exist?(file_or_string_path)
40
47
  File.open(file_or_string_path) do |f|
41
- apply_cps_file_raw(f)
48
+ apply_caps_file_raw(f)
42
49
  end
43
50
  elsif file_or_string_path.is_a?(File)
44
51
  apply_caps_file_raw(file_or_string_path)
@@ -1,3 +1,3 @@
1
1
  class CapNG
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.7"
3
3
  end
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.2
4
+ version: 0.1.7
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-10-28 00:00:00.000000000 Z
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: 3.3.3
75
+ - !ruby/object:Gem::Dependency
76
+ name: yard
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.9'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.9'
75
89
  description: libcap-ng bindings for Ruby.
76
90
  email:
77
91
  - cosmo0920.wp@gmail.com
@@ -80,7 +94,10 @@ extensions:
80
94
  - ext/capng/extconf.rb
81
95
  extra_rdoc_files: []
82
96
  files:
97
+ - ".clang-format"
98
+ - ".github/workflows/apt.yml"
83
99
  - ".github/workflows/linux.yml"
100
+ - ".github/workflows/yum.yml"
84
101
  - ".gitignore"
85
102
  - Gemfile
86
103
  - LICENSE
@@ -89,9 +106,19 @@ files:
89
106
  - bin/console
90
107
  - bin/setup
91
108
  - capng_c.gemspec
109
+ - ci/apt-test.sh
110
+ - ci/yum-test.sh
111
+ - example/file_capability.rb
112
+ - example/process_capability.rb
113
+ - example/process_capability_without_root.rb
92
114
  - ext/capng/capability.c
93
115
  - ext/capng/capng.c
94
116
  - ext/capng/capng.h
117
+ - ext/capng/enum-action.c
118
+ - ext/capng/enum-flags.c
119
+ - ext/capng/enum-result.c
120
+ - ext/capng/enum-select.c
121
+ - ext/capng/enum-type.c
95
122
  - ext/capng/enum.c
96
123
  - ext/capng/extconf.rb
97
124
  - ext/capng/print.c
@@ -99,12 +126,13 @@ files:
99
126
  - ext/capng/utils.c
100
127
  - lib/capng.rb
101
128
  - lib/capng/version.rb
102
- homepage: https://github.com/cosmo0920/cap-ng_c
103
- licenses: []
129
+ homepage: https://github.com/fluent-plugins-nursery/cap-ng_c
130
+ licenses:
131
+ - Apache-2.0
104
132
  metadata:
105
133
  allowed_push_host: https://rubygems.org
106
- homepage_uri: https://github.com/cosmo0920/cap-ng_c
107
- source_code_uri: https://github.com/cosmo0920/cap-ng_c
134
+ homepage_uri: https://github.com/fluent-plugins-nursery/cap-ng_c
135
+ source_code_uri: https://github.com/fluent-plugins-nursery/cap-ng_c
108
136
  post_install_message:
109
137
  rdoc_options: []
110
138
  require_paths:
@@ -120,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
148
  - !ruby/object:Gem::Version
121
149
  version: '0'
122
150
  requirements: []
123
- rubygems_version: 3.1.4
151
+ rubygems_version: 3.0.3
124
152
  signing_key:
125
153
  specification_version: 4
126
154
  summary: libcap-ng bindings for Ruby.