specinfra 2.57.5 → 2.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/specinfra/command/base/file.rb +8 -0
- data/lib/specinfra/command/base/inventory.rb +5 -0
- data/lib/specinfra/host_inventory.rb +1 -0
- data/lib/specinfra/host_inventory/user.rb +32 -0
- data/lib/specinfra/version.rb +1 -1
- data/spec/command/base/file_spec.rb +8 -0
- data/spec/host_inventory/base/user_spec.rb +68 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b96d6c291a4ad614c1fb935b276b60a48712c2de
|
4
|
+
data.tar.gz: 7d06566103e0dadc909f8a60a6d329db5326dc19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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
|
data/lib/specinfra/version.rb
CHANGED
@@ -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.
|
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-
|
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
|