specinfra 2.57.5 → 2.58.0

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
  SHA1:
3
- metadata.gz: f586423693b0da37a4f1a8810058139fccc1179c
4
- data.tar.gz: e2cc4df5060fb0f3b027d2913c098523bcca0a98
3
+ metadata.gz: b96d6c291a4ad614c1fb935b276b60a48712c2de
4
+ data.tar.gz: 7d06566103e0dadc909f8a60a6d329db5326dc19
5
5
  SHA512:
6
- metadata.gz: dbad079333fd78df01964e5b2cab1fa63117a7d4a1dedfa98e5ccd55126d147674a148534a4ff40c20901e17e27c3dedbf8a6bea7ef17de909be266b1bcbe740
7
- data.tar.gz: b6bfc3fc62f369cddc748aa979cd2e982d51ea13273b12472d5454b37112e234e9c65988b06bccc60d8483203e7dbda43a5700fef8a8cc7669cec353d3ea9a12
6
+ metadata.gz: 8a604b92ac11245c1a1812b1cbbdb946ff7378d714c040839e85b54d84cc27195adfd6e35e44a966e8b1efa46d67d79a273ff7fdd4777f3bafd2346dc78f7e40
7
+ data.tar.gz: 40a5677d5ca94efcc1e3af7852391830a6ebaa152191b32ff6bc42aee9b412ba71057979364b43fdbad5ce3be37b06dce23ee58483a9be54dbc95f51a1c380a3
@@ -129,6 +129,14 @@ class Specinfra::Command::Base::File < Specinfra::Command::Base
129
129
  "readlink #{escape(link)}"
130
130
  end
131
131
 
132
+ def get_link_realpath(link)
133
+ "readlink -e #{escape(link)}"
134
+ end
135
+
136
+ def check_is_dereferenceable(link)
137
+ %Q|test -n "$(readlink -e #{escape(link)})"|
138
+ end
139
+
132
140
  def get_mtime(file)
133
141
  "stat -c %Y #{escape(file)}"
134
142
  end
@@ -1,2 +1,7 @@
1
1
  class Specinfra::Command::Base::Inventory < Specinfra::Command::Base
2
+ class << self
3
+ def get_user
4
+ 'getent passwd'
5
+ end
6
+ end
2
7
  end
@@ -13,6 +13,7 @@ module Specinfra
13
13
  virtualization
14
14
  kernel
15
15
  block_device
16
+ user
16
17
  }
17
18
 
18
19
  include Enumerable
@@ -0,0 +1,32 @@
1
+ module Specinfra
2
+ class HostInventory
3
+ class User < Base
4
+ def get
5
+ cmd = backend.command.get(:get_inventory_user)
6
+ ret = backend.run_command(cmd)
7
+ if ret.exit_status == 0
8
+ parse(ret.stdout)
9
+ else
10
+ nil
11
+ end
12
+ end
13
+
14
+ def parse(cmd_ret)
15
+ users = {}
16
+ lines = cmd_ret.split(/\n/)
17
+ lines.each do |line|
18
+ user = line.split(':')
19
+ users[user[0]] = {
20
+ 'name' => user[0],
21
+ 'uid' => user[2],
22
+ 'gid' => user[3],
23
+ 'gecos' => user[4],
24
+ 'directory' => user[5],
25
+ 'shell' => user[6]
26
+ }
27
+ end
28
+ users
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.57.5"
2
+ VERSION = "2.58.0"
3
3
  end
@@ -94,6 +94,14 @@ describe get_command(:get_file_link_target, '/tmp') do
94
94
  it { should eq 'readlink /tmp' }
95
95
  end
96
96
 
97
+ describe get_command(:get_file_link_realpath, '/tmp') do
98
+ it { should eq 'readlink -e /tmp' }
99
+ end
100
+
101
+ describe get_command(:check_file_is_dereferenceable, '/tmp') do
102
+ it { should eq 'test -n "$(readlink -e /tmp)"' }
103
+ end
104
+
97
105
  describe get_command(:check_file_exists, '/tmp') do
98
106
  it { should eq 'test -e /tmp' }
99
107
  end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ str = <<-EOH
4
+ root:x:0:0:root:/root:/bin/bash
5
+ bin:x:1:1:bin:/bin:/sbin/nologin
6
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
7
+ adm:x:3:4:adm:/var/adm:/sbin/nologin
8
+ lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
9
+ sync:x:5:0:sync:/sbin:/bin/sync
10
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
11
+ halt:x:7:0:halt:/sbin:/sbin/halt
12
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
13
+ operator:x:11:0:operator:/root:/sbin/nologin
14
+ games:x:12:100:games:/usr/games:/sbin/nologin
15
+ ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
16
+ nobody:x:99:99:Nobody:/:/sbin/nologin
17
+ avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
18
+ systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
19
+ systemd-network:x:998:996:systemd Network Management:/:/sbin/nologin
20
+ dbus:x:81:81:System message bus:/:/sbin/nologin
21
+ polkitd:x:997:995:User for polkitd:/:/sbin/nologin
22
+ tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
23
+ postfix:x:89:89::/var/spool/postfix:/sbin/nologin
24
+ sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
25
+ ntp:x:38:38::/etc/ntp:/sbin/nologin
26
+ hoge:x:1000:1000::/home/hoge:/bin/bash
27
+ saslauth:x:499:76:Saslauthd user:/run/saslauthd:/sbin/nologin
28
+ apache:x:48:48:Apache:/opt/rh/httpd24/root/usr/share/httpd:/sbin/nologin
29
+ postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
30
+ EOH
31
+
32
+ describe Specinfra::HostInventory::User do
33
+ let(:host_inventory) { nil }
34
+ describe 'Example of CentOS Linux release 7.2.1511' do
35
+ ret = Specinfra::HostInventory::User.new(host_inventory).parse(str)
36
+ example do
37
+ expect(ret).to include(
38
+ 'root' => {'name' => 'root', 'uid' => '0', 'gid' => '0', 'gecos' => 'root', 'directory' => '/root', 'shell' => '/bin/root'},
39
+ 'adm' => {'name'=>'adm', 'uid'=>'3', 'gid'=>'4', 'gecos'=>'adm', 'directory'=>'/var/adm', 'shell'=>'/sbin/nologin'},
40
+ 'apache' => {'name'=>'apache', 'uid'=>'48', 'gid'=>'48', 'gecos'=>'Apache', 'directory'=>'/opt/rh/httpd24/root/usr/share/httpd', 'shell'=>'/sbin/nologin'},
41
+ 'avahi-autoipd' => {'name'=>'avahi-autoipd', 'uid'=>'170', 'gid'=>'170', 'gecos'=>'Avahi IPv4LL Stack', 'directory'=>'/var/lib/avahi-autoipd', 'shell'=>'/sbin/nologin'},
42
+ 'bin' => {'name'=>'bin', 'uid'=>'1', 'gid'=>'1', 'gecos'=>'bin', 'directory'=>'/bin', 'shell'=>'/sbin/nologin'},
43
+ 'daemon' => {'name'=>'daemon', 'uid'=>'2', 'gid'=>'2', 'gecos'=>'daemon', 'directory'=>'/sbin', 'shell'=>'/sbin/nologin'},
44
+ 'dbus' => {'name'=>'dbus', 'uid'=>'81', 'gid'=>'81', 'gecos'=>'System message bus', 'directory'=>'/', 'shell'=>'/sbin/nologin'},
45
+ 'ftp' => {'name'=>'ftp', 'uid'=>'14', 'gid'=>'50', 'gecos'=>'FTP User', 'directory'=>'/var/ftp', 'shell'=>'/sbin/nologin'},
46
+ 'games' => {'name'=>'games', 'uid'=>'12', 'gid'=>'100', 'gecos'=>'games', 'directory'=>'/usr/games', 'shell'=>'/sbin/nologin'},
47
+ 'halt' => {'name'=>'halt', 'uid'=>'7', 'gid'=>'0', 'gecos'=>'halt', 'directory'=>'/sbin', 'shell'=>'/sbin/halt'},
48
+ 'hoge' => {'name'=>'hoge', 'uid'=>'1000', 'gid'=>'1000', 'gecos'=>'', 'directory'=>'/home/hoge', 'shell'=>'/bin/bash'},
49
+ 'lp' => {'name'=>'lp', 'uid'=>'4', 'gid'=>'7', 'gecos'=>'lp', 'directory'=>'/var/spool/lpd', 'shell'=>'/sbin/nologin'},
50
+ 'mail' => {'name'=>'mail', 'uid'=>'8', 'gid'=>'12', 'gecos'=>'mail', 'directory'=>'/var/spool/mail', 'shell'=>'/sbin/nologin'},
51
+ 'nobody' => {'name'=>'nobody', 'uid'=>'99', 'gid'=>'99', 'gecos'=>'Nobody', 'directory'=>'/', 'shell'=>'/sbin/nologin'},
52
+ 'ntp' => {'name'=>'ntp', 'uid'=>'38', 'gid'=>'38', 'gecos'=>'', 'directory'=>'/etc/ntp', 'shell'=>'/sbin/nologin'},
53
+ 'operator' => {'name'=>'operator', 'uid'=>'11', 'gid'=>'0', 'gecos'=>'operator', 'directory'=>'/root', 'shell'=>'/sbin/nologin'},
54
+ 'polkitd' => {'name'=>'polkitd', 'uid'=>'997', 'gid'=>'995', 'gecos'=>'User for polkitd', 'directory'=>'/', 'shell'=>'/sbin/nologin'},
55
+ 'postfix' => {'name'=>'postfix', 'uid'=>'89', 'gid'=>'89', 'gecos'=>'', 'directory'=>'/var/spool/postfix', 'shell'=>'/sbin/nologin'},
56
+ 'postgres' => {'name'=>'postgres', 'uid'=>'26', 'gid'=>'26', 'gecos'=>'PostgreSQL Server', 'directory'=>'/var/lib/pgsql', 'shell'=>'/bin/bash'},
57
+ 'root' => {'name'=>'root', 'uid'=>'0', 'gid'=>'0', 'gecos'=>'root', 'directory'=>'/root', 'shell'=>'/bin/bash'},
58
+ 'saslauth' => {'name'=>'saslauth', 'uid'=>'499', 'gid'=>'76', 'gecos'=>'Saslauthd user', 'directory'=>'/run/saslauthd', 'shell'=>'/sbin/nologin'},
59
+ 'shutdown' => {'name'=>'shutdown', 'uid'=>'6', 'gid'=>'0', 'gecos'=>'shutdown', 'directory'=>'/sbin', 'shell'=>'/sbin/shutdown'},
60
+ 'sshd' => {'name'=>'sshd', 'uid'=>'74', 'gid'=>'74', 'gecos'=>'Privilege-separated SSH', 'directory'=>'/var/empty/sshd', 'shell'=>'/sbin/nologin'},
61
+ 'sync' => {'name'=>'sync', 'uid'=>'5', 'gid'=>'0', 'gecos'=>'sync', 'directory'=>'/sbin', 'shell'=>'/bin/sync'},
62
+ 'systemd-bus-proxy' => {'name'=>'systemd-bus-proxy', 'uid'=>'999', 'gid'=>'997', 'gecos'=>'systemd Bus Proxy', 'directory'=>'/', 'shell'=>'/sbin/nologin'},
63
+ 'systemd-network' => {'name'=>'systemd-network', 'uid'=>'998', 'gid'=>'996', 'gecos'=>'systemd Network Management', 'directory'=>'/', 'shell'=>'/sbin/nologin'},
64
+ 'tss' => {'name'=>'tss', 'uid'=>'59', 'gid'=>'59', 'gecos'=>'Account used by the trousers package to sandbox the tcsd daemon', 'directory'=>'/dev/null', 'shell'=>'/sbin/nologin'}
65
+ )
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.57.5
4
+ version: 2.58.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-25 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp
@@ -461,6 +461,7 @@ files:
461
461
  - lib/specinfra/host_inventory/memory.rb
462
462
  - lib/specinfra/host_inventory/platform.rb
463
463
  - lib/specinfra/host_inventory/platform_version.rb
464
+ - lib/specinfra/host_inventory/user.rb
464
465
  - lib/specinfra/host_inventory/virtualization.rb
465
466
  - lib/specinfra/processor.rb
466
467
  - lib/specinfra/properties.rb
@@ -538,6 +539,7 @@ files:
538
539
  - spec/helper/properties_spec.rb
539
540
  - spec/helper/set_spec.rb
540
541
  - spec/host_inventory/aix/filesystem_spec.rb
542
+ - spec/host_inventory/base/user_spec.rb
541
543
  - spec/host_inventory/darwin/filesystem_spec.rb
542
544
  - spec/host_inventory/freebsd/filesystem_spec.rb
543
545
  - spec/host_inventory/linux/block_device_spec.rb
@@ -649,6 +651,7 @@ test_files:
649
651
  - spec/helper/properties_spec.rb
650
652
  - spec/helper/set_spec.rb
651
653
  - spec/host_inventory/aix/filesystem_spec.rb
654
+ - spec/host_inventory/base/user_spec.rb
652
655
  - spec/host_inventory/darwin/filesystem_spec.rb
653
656
  - spec/host_inventory/freebsd/filesystem_spec.rb
654
657
  - spec/host_inventory/linux/block_device_spec.rb