capng_c 0.1.5 → 0.2.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.
@@ -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,18 @@ 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
10
- alias_method :initialize_raw, :initialize
11
-
12
- def initialize(target = nil, pid_or_path = nil)
13
- if target && pid_or_path.is_a?(Integer)
14
- initialize_raw(target, pid_or_path)
15
- elsif target && pid_or_path.is_a?(String) && File.exist?(pid_or_path)
16
- File.open(pid_or_path) do |file|
17
- initialize_raw(target, file);
18
- end
19
- else
20
- initialize_raw(target, pid_or_path)
21
- end
22
- end
23
17
 
24
18
  def caps_file(file_or_string_path)
25
19
  if file_or_string_path.is_a?(String) && File.exist?(file_or_string_path)
@@ -1,3 +1,3 @@
1
1
  class CapNG
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.1"
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.5
4
+ version: 0.2.1
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-02 00:00:00.000000000 Z
11
+ date: 2020-11-16 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,12 +106,20 @@ files:
89
106
  - bin/console
90
107
  - bin/setup
91
108
  - capng_c.gemspec
109
+ - ci/apt-test.sh
110
+ - ci/yum-test.sh
92
111
  - example/file_capability.rb
93
112
  - example/process_capability.rb
94
113
  - example/process_capability_without_root.rb
95
114
  - ext/capng/capability.c
115
+ - ext/capng/capability_info.c
96
116
  - ext/capng/capng.c
97
117
  - ext/capng/capng.h
118
+ - ext/capng/enum-action.c
119
+ - ext/capng/enum-flags.c
120
+ - ext/capng/enum-result.c
121
+ - ext/capng/enum-select.c
122
+ - ext/capng/enum-type.c
98
123
  - ext/capng/enum.c
99
124
  - ext/capng/extconf.rb
100
125
  - ext/capng/print.c
@@ -102,13 +127,13 @@ files:
102
127
  - ext/capng/utils.c
103
128
  - lib/capng.rb
104
129
  - lib/capng/version.rb
105
- homepage: https://github.com/cosmo0920/cap-ng_c
130
+ homepage: https://github.com/fluent-plugins-nursery/capng_c
106
131
  licenses:
107
132
  - Apache-2.0
108
133
  metadata:
109
134
  allowed_push_host: https://rubygems.org
110
- homepage_uri: https://github.com/cosmo0920/cap-ng_c
111
- source_code_uri: https://github.com/cosmo0920/cap-ng_c
135
+ homepage_uri: https://github.com/fluent-plugins-nursery/capng_c
136
+ source_code_uri: https://github.com/fluent-plugins-nursery/capng_c
112
137
  post_install_message:
113
138
  rdoc_options: []
114
139
  require_paths: