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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f96ad9d7f1439e815c23aebf272ff8ca0984dba7ec9775e22483d33a390e82b1
4
- data.tar.gz: 0eba5185a5c6c23660b69acd7982b5982830a50e2dad726b09c1f89f93325780
3
+ metadata.gz: 22886b993b258c672b8f37d59c51108e40027365f5932fe5ae841ec4ccfe4735
4
+ data.tar.gz: 0e04c670687c4575bec9e874d5f0748e280452f387ebe9ea7cbd9a06a82823ad
5
5
  SHA512:
6
- metadata.gz: af3f529c576999c3f11371b0ea4ffaf59ad62f0500185a3b238026d41744251732f24d1123590f981d9eeb260188599358b626fd634d69f25a13aafe5cfbb694
7
- data.tar.gz: d28a267db5871149c88a145aef192612d8f007826670ded888b5a96836593211431cf4d038e6fb314427ccefdc3dba7dd5b3439b14374f36a6d813dad201a0da
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
- _, status = Process.waitpid2 pid
170
- raise Marshal.load(io_r.read) if status.exitstatus != 0
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
- ensure
182
- exit! exit_status
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", NEWIPC, :ipc ] if const_defined?(:NEWIPC)
204
- list.push ["mnt", NEWNS, :mount ] if const_defined?(:NEWNS)
205
- list.push ["net", NEWNET, :network] if const_defined?(:NEWNET)
206
- list.push ["pid", NEWPID, :pid ] if const_defined?(:NEWPID)
207
- if File.exist? "/proc/#{pid}/ns/pid_for_children"
208
- list.last[0] = "pid_for_children"
209
- end
210
- list.push ["uts", NEWUTS, :uts ] if const_defined?(:NEWUTS)
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.each do |nstype, file|
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
- end
222
+ }.max or 0
227
223
  end
228
224
 
229
225
  def self.get_nstype_file_h flags, pid, options
@@ -1,3 +1,3 @@
1
1
  module HrrRbLxns
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: hrr_rb_lxns
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
  - hirura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
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.0.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.