File: helper.rb

package info (click to toggle)
ruby-train 3.13.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,208 kB
  • sloc: ruby: 10,002; sh: 17; makefile: 8
file content (58 lines) | stat: -rw-r--r-- 1,436 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require "minitest/autorun"
require "minitest/spec"

# Tests configuration:
module Test
  class << self
    # MTime tracks the maximum range of modification time in seconds.
    # i.e. MTime == 60*60*1 is 1 hour of modification time range,
    # which translates to a modification time range of:
    #   [ now-1hour, now ]
    def mtime
      60 * 60 * 24 * 1
    end

    def dup(o)
      Marshal.load(Marshal.dump(o))
    end

    def root_group(os)
      case os[:family]
      when "freebsd"
        "wheel"
      when "aix"
        "system"
      else
        "root"
      end
    end

    def selinux_label(backend, path = nil)
      return nil if backend.class.to_s =~ /docker/i

      os = backend.os
      labels = {}

      h = {}
      h.default = Hash.new(nil)
      h["redhat"] = {}
      h["redhat"].default = "unconfined_u:object_r:user_tmp_t:s0"
      h["redhat"]["5.11"] = "user_u:object_r:tmp_t"
      h["centos"] = h["fedora"] = h["redhat"]
      labels.default = dup(h)

      h["redhat"].default = "unconfined_u:object_r:tmp_t:s0"
      labels["/tmp/block_device"] = dup(h)

      h = {}
      h.default = Hash.new(nil)
      h["redhat"] = {}
      h["redhat"].default = "system_u:object_r:null_device_t:s0"
      h["redhat"]["5.11"] = "system_u:object_r:null_device_t"
      h["centos"] = h["fedora"] = h["redhat"]
      labels["/dev/null"] = dup(h)

      labels[path][os[:family]][os[:release]]
    end
  end
end