capng_c 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09424f043b085bf67c01b1b452d4a4f2fc7c60c1afc6c747b1c0d2fe6a993885'
4
- data.tar.gz: 5ca5f2a6d6532d6a4a5e3101003790217704739be145c437194fbfc71f6bcd45
3
+ metadata.gz: a26ab3bf7c3169172ec3e2c162630f0079b161533ec473984e4d52737d522b91
4
+ data.tar.gz: 9f378edbfb74593fc731acb2f4ead7b591207b0f358f9ce4e1caf28e747188d3
5
5
  SHA512:
6
- metadata.gz: 8f3a2e7470baece0fe2b391a9b90f798b5a3eb1ba57327793212bc4fcfaaf419316dd42e7d08ac616705495dfcf33097dcaa6060cfaa256f2e3428ebfddb50bd
7
- data.tar.gz: e9fdef39ef5ae17e7f825cf3fea0cbc45a27345eecd7790d95eb0e90d2b83fc63d759bd57bb3081e32493f41175954db86f9d5f7f2a0830ba0c818ebc78c0954
6
+ metadata.gz: 92d50ae4dc1c276709d38a2bbac7421ac0ec68d8dee70d8f5d28c4b2aa3e33ef81ae179dafd7f214703d68a8eeda5b4f2220eca786f50fdd77838a88fec754fd
7
+ data.tar.gz: 2f2f6cff1a51adeb4fe038871b3e3a5e5ec7b9075b18f31653000a5aea785e610bce39570cc4a2252c4dc4518ecd9f0be20436a28473d3769a4329fa98a912ae
@@ -117,6 +117,27 @@ rb_capng_capability_from_name(VALUE self, VALUE rb_capability_name_or_symbol)
117
117
  return INT2NUM(capability);
118
118
  }
119
119
 
120
+ /*
121
+ * Obtain capability code and name pairs with enumerable.
122
+ *
123
+ * @yield [Integer, String]
124
+ * @return [nil]
125
+ *
126
+ */
127
+ static VALUE
128
+ rb_capng_capability_each(VALUE self)
129
+ {
130
+ RETURN_ENUMERATOR(self, 0, 0);
131
+
132
+ for (int i = 0; capabilityInfoTable[i].name != NULL; i++) {
133
+ rb_yield_values(2,
134
+ INT2NUM(capabilityInfoTable[i].code),
135
+ rb_str_new2(capabilityInfoTable[i].name));
136
+ }
137
+
138
+ return Qnil;
139
+ }
140
+
120
141
  void
121
142
  Init_capng_capability(VALUE rb_cCapNG)
122
143
  {
@@ -127,6 +148,7 @@ Init_capng_capability(VALUE rb_cCapNG)
127
148
  rb_define_method(rb_cCapability, "initialize", rb_capng_capability_initialize, 0);
128
149
  rb_define_method(rb_cCapability, "to_name", rb_capng_capability_to_name, 1);
129
150
  rb_define_method(rb_cCapability, "from_name", rb_capng_capability_from_name, 1);
151
+ rb_define_method(rb_cCapability, "each", rb_capng_capability_each, 0);
130
152
 
131
153
  // Capability constants.
132
154
 
@@ -0,0 +1,82 @@
1
+ /* capng_c */
2
+ /* Copyright 2020- Hiroshi Hatake*/
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
+ /* http://www.apache.org/licenses/LICENSE-2.0 */
8
+ /* Unless required by applicable law or agreed to in writing, software */
9
+ /* distributed under the License is distributed on an "AS IS" BASIS, */
10
+ /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
11
+ /* See the License for the specific language governing permissions and */
12
+ /* limitations under the License. */
13
+
14
+ #include <capng.h>
15
+
16
+ CapabilityInfo capabilityInfoTable[] = {
17
+ {CAP_CHOWN, "chown"},
18
+ {CAP_DAC_OVERRIDE, "dac_override"},
19
+ {CAP_DAC_READ_SEARCH, "dac_read_search"},
20
+ {CAP_FOWNER, "fowner"},
21
+ {CAP_FSETID, "fsetid"},
22
+ {CAP_KILL, "kill"},
23
+ {CAP_SETGID, "setgid"},
24
+ {CAP_SETUID, "setuid"},
25
+ {CAP_SETPCAP, "setpcap"},
26
+ {CAP_LINUX_IMMUTABLE, "linux_immutable"},
27
+ {CAP_NET_BIND_SERVICE, "net_bind_service"},
28
+ {CAP_NET_BROADCAST, "net_broadcast"},
29
+ {CAP_NET_ADMIN, "net_admin"},
30
+ {CAP_NET_RAW, "net_raw"},
31
+ {CAP_IPC_LOCK, "ipc_lock"},
32
+ {CAP_IPC_OWNER, "ipc_owner"},
33
+ {CAP_SYS_MODULE, "sys_module"},
34
+ {CAP_SYS_RAWIO, "sys_rawio"},
35
+ {CAP_SYS_CHROOT, "sys_chroot"},
36
+ {CAP_SYS_PTRACE, "sys_ptrace"},
37
+ {CAP_SYS_PACCT, "sys_pacct"},
38
+ {CAP_SYS_ADMIN, "sys_admin"},
39
+ {CAP_SYS_BOOT, "sys_boot"},
40
+ {CAP_SYS_NICE, "sys_nice"},
41
+ {CAP_SYS_RESOURCE, "sys_resource"},
42
+ {CAP_SYS_TIME, "sys_time"},
43
+ {CAP_SYS_TTY_CONFIG, "sys_tty_config"},
44
+ {CAP_MKNOD, "mknod"},
45
+ {CAP_LEASE, "lease"},
46
+ {CAP_AUDIT_WRITE, "audit_write"},
47
+ {CAP_AUDIT_CONTROL, "audit_control"},
48
+ #ifdef CAP_SETFCAP
49
+ {CAP_SETFCAP, "setfcap"},
50
+ #endif
51
+ #ifdef CAP_MAC_OVERRIDE
52
+ {CAP_MAC_OVERRIDE, "mac_override"},
53
+ #endif
54
+ #ifdef CAP_MAC_ADMIN
55
+ {CAP_MAC_ADMIN, "mac_admin"},
56
+ #endif
57
+ #ifdef CAP_SYSLOG
58
+ {CAP_SYSLOG, "syslog"},
59
+ #endif
60
+ #ifdef CAP_EPOLLWAKEUP
61
+ {CAP_EPOLLWAKEUP, "epollwakeup"},
62
+ #endif
63
+ #ifdef CAP_WAKE_ALARM
64
+ {CAP_WAKE_ALARM, "wake_alarm"},
65
+ #endif
66
+ #ifdef CAP_BLOCK_SUSPEND
67
+ {CAP_BLOCK_SUSPEND, "block_suspend"},
68
+ #endif
69
+ #ifdef CAP_AUDIT_READ
70
+ {CAP_AUDIT_READ, "audit_read"},
71
+ #endif
72
+ #ifdef CAP_PERFMON
73
+ {CAP_PERFMON, "perfmon"},
74
+ #endif
75
+ #ifdef CAP_BPF
76
+ {CAP_BPF, "bpf"},
77
+ #endif
78
+ #ifdef CAP_CHECKPOINT_RESTORE
79
+ {CAP_CHECKPOINT_RESTORE, "checkpoint_restore"},
80
+ #endif
81
+ {-1, NULL},
82
+ };
@@ -44,6 +44,13 @@ print_name_to_print_type(char* print_name);
44
44
  capng_type_t
45
45
  capability_type_name_to_capability_type(char* capability_name);
46
46
 
47
+ typedef struct {
48
+ int code;
49
+ const char* name;
50
+ } CapabilityInfo;
51
+
52
+ extern CapabilityInfo capabilityInfoTable[];
53
+
47
54
  void Init_capng_capability(VALUE);
48
55
  void Init_capng_enum(VALUE);
49
56
  void Init_capng_enum_action(VALUE);
@@ -1,3 +1,3 @@
1
1
  class CapNG
2
- VERSION = "0.2.0"
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.2.0
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-10 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
@@ -112,6 +112,7 @@ files:
112
112
  - example/process_capability.rb
113
113
  - example/process_capability_without_root.rb
114
114
  - ext/capng/capability.c
115
+ - ext/capng/capability_info.c
115
116
  - ext/capng/capng.c
116
117
  - ext/capng/capng.h
117
118
  - ext/capng/enum-action.c