hrr_rb_lxns 0.2.0 → 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.
- checksums.yaml +4 -4
- data/ext/hrr_rb_lxns/hrr_rb_lxns.c +6 -0
- data/lib/hrr_rb_lxns.rb +15 -19
- data/lib/hrr_rb_lxns/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22886b993b258c672b8f37d59c51108e40027365f5932fe5ae841ec4ccfe4735
|
4
|
+
data.tar.gz: 0e04c670687c4575bec9e874d5f0748e280452f387ebe9ea7cbd9a06a82823ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b55815a702403feff42698e15b8ada181bf32ac2da3362331b8cf87ccc8f5413462896f1a63181a3736954f743659f4e0d56004919c5bfbbb8774559a6211a92
|
7
|
+
data.tar.gz: 114b6d13402c24de77662525bfee59c6d3f7e02b680a76903f3810238cdd2ac91ce99cd5096dcbb22e195d9287d7252ecf1b86a6476c170eea1903abf2c3e98e
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "hrr_rb_lxns.h"
|
2
2
|
#define _GNU_SOURCE 1
|
3
3
|
#include <sched.h>
|
4
|
+
#include <linux/version.h>
|
4
5
|
|
5
6
|
VALUE rb_mHrrRbLxns;
|
6
7
|
VALUE rb_mHrrRbLxnsConst;
|
@@ -107,6 +108,11 @@ Init_hrr_rb_lxns(void)
|
|
107
108
|
/* Represents cgroup namespace. */
|
108
109
|
rb_define_const(rb_mHrrRbLxnsConst, "NEWCGROUP", INT2FIX(CLONE_NEWCGROUP));
|
109
110
|
#endif
|
111
|
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
|
112
|
+
# ifndef CLONE_NEWTIME
|
113
|
+
# define CLONE_NEWTIME 0x00000080
|
114
|
+
# endif
|
115
|
+
#endif
|
110
116
|
#ifdef CLONE_NEWTIME
|
111
117
|
/* Represents time namespace. */
|
112
118
|
rb_define_const(rb_mHrrRbLxnsConst, "NEWTIME", INT2FIX(CLONE_NEWTIME));
|
data/lib/hrr_rb_lxns.rb
CHANGED
@@ -166,20 +166,19 @@ module HrrRbLxns
|
|
166
166
|
io_w.write "1"
|
167
167
|
io_w.close
|
168
168
|
if pid_to_bind == Process.pid
|
169
|
-
|
170
|
-
raise Marshal.load(io_r.read)
|
169
|
+
Process.waitpid pid
|
170
|
+
raise Marshal.load(io_r.read) unless $?.to_i.zero?
|
171
171
|
end
|
172
172
|
ret
|
173
173
|
else
|
174
174
|
begin
|
175
|
-
exit_status = true
|
176
175
|
io_r.read 1
|
177
176
|
bind_ns_files flags, options, pid_to_bind
|
178
177
|
rescue Exception => e
|
179
|
-
exit_status = false
|
180
178
|
io_w.write Marshal.dump(e)
|
181
|
-
|
182
|
-
|
179
|
+
exit! false
|
180
|
+
else
|
181
|
+
exit! true
|
183
182
|
end
|
184
183
|
end
|
185
184
|
ensure
|
@@ -200,17 +199,14 @@ module HrrRbLxns
|
|
200
199
|
|
201
200
|
def self.bind_ns_files flags, options, pid
|
202
201
|
list = Array.new
|
203
|
-
list.push ["ipc",
|
204
|
-
list.push ["mnt",
|
205
|
-
list.push ["net",
|
206
|
-
list.push ["
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
list.push ["
|
211
|
-
list.push ["user", NEWUSER, :user ] if const_defined?(:NEWUSER)
|
212
|
-
list.push ["cgroup", NEWCGROUP, :cgroup ] if const_defined?(:NEWCGROUP)
|
213
|
-
list.push ["time", NEWTIME, :time ] if const_defined?(:NEWTIME)
|
202
|
+
list.push ["ipc", NEWIPC, :ipc ] if const_defined?(:NEWIPC)
|
203
|
+
list.push ["mnt", NEWNS, :mount ] if const_defined?(:NEWNS)
|
204
|
+
list.push ["net", NEWNET, :network] if const_defined?(:NEWNET)
|
205
|
+
list.push ["pid_for_children", NEWPID, :pid ] if const_defined?(:NEWPID)
|
206
|
+
list.push ["uts", NEWUTS, :uts ] if const_defined?(:NEWUTS)
|
207
|
+
list.push ["user", NEWUSER, :user ] if const_defined?(:NEWUSER)
|
208
|
+
list.push ["cgroup", NEWCGROUP, :cgroup ] if const_defined?(:NEWCGROUP)
|
209
|
+
list.push ["time_for_children", NEWTIME, :time ] if const_defined?(:NEWTIME)
|
214
210
|
list.each do |name, flag, key|
|
215
211
|
if (flags & flag).zero?.! && options[key]
|
216
212
|
HrrRbMount.bind "/proc/#{pid}/ns/#{name}", options[key]
|
@@ -219,11 +215,11 @@ module HrrRbLxns
|
|
219
215
|
end
|
220
216
|
|
221
217
|
def self.do_setns nstype_file_h
|
222
|
-
nstype_file_h.
|
218
|
+
nstype_file_h.map{ |nstype, file|
|
223
219
|
File.open(file, File::RDONLY) do |f|
|
224
220
|
__setns__ f.fileno, nstype
|
225
221
|
end
|
226
|
-
|
222
|
+
}.max or 0
|
227
223
|
end
|
228
224
|
|
229
225
|
def self.get_nstype_file_h flags, pid, options
|
data/lib/hrr_rb_lxns/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hrr_rb_lxns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hirura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hrr_rb_mount
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
|
-
rubygems_version: 3.
|
71
|
+
rubygems_version: 3.1.2
|
72
72
|
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: Utilities working with Linux namespaces for CRuby.
|