kanrisuru 0.16.13 → 0.16.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/kanrisuru/core/user/commands/get_user.rb +13 -9
- data/lib/kanrisuru/core/user/parser.rb +1 -0
- data/lib/kanrisuru/core/user/parsers/user.rb +21 -0
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/support/shared_examples/integration/core/user.rb +15 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8db62531b521e5f8606ed7bb2520100d2f2f1fe20d78c1c8ae43759926e44ee
|
4
|
+
data.tar.gz: d3372a41fe3058ffaf938ce8ca31e7458f71fe981b380ac14143c46f2be9692b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bfafcc5e78e8545a1a2c6565bdbd9f5e581186c40b97696c1c4cd5b80426b03306f98a400db289293e86f4b919ee1b9cad622323c03b63264344a73c555f777
|
7
|
+
data.tar.gz: a1166a9650b3f3fe95a270abfa4950afb2b36fa3acde33ad4ed237944a44eddef6c4cc1d85352b87c0f672aed69d50dd60801295127c88ffc8b56a3ebd3e35e9
|
data/CHANGELOG.md
CHANGED
@@ -8,11 +8,15 @@ module Kanrisuru
|
|
8
8
|
execute_shell(command)
|
9
9
|
|
10
10
|
Kanrisuru::Result.new(command) do |cmd|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
if Kanrisuru::Util.numeric?(user)
|
12
|
+
uid = user.to_i
|
13
|
+
user = Parser::User.parse(cmd)
|
14
|
+
else
|
15
|
+
## Get user id
|
16
|
+
result = get_uid(user)
|
17
|
+
break if result.failure?
|
18
|
+
uid = result.to_i
|
19
|
+
end
|
16
20
|
|
17
21
|
## Get all groups for the user, with gid and group name
|
18
22
|
array = Parser::Groups.parse(cmd)
|
@@ -24,12 +28,12 @@ module Kanrisuru
|
|
24
28
|
end
|
25
29
|
|
26
30
|
## Get home / shell path information
|
27
|
-
|
28
|
-
|
31
|
+
command2 = Kanrisuru::Command.new("getent passwd #{user}")
|
32
|
+
command2 | "awk -F: '{print $6, $7}'"
|
29
33
|
|
30
|
-
execute(
|
34
|
+
execute(command2)
|
31
35
|
|
32
|
-
result = Kanrisuru::Result.new(
|
36
|
+
result = Kanrisuru::Result.new(command2) do |cmd2|
|
33
37
|
Parser::Getent.parse(cmd2)
|
34
38
|
end
|
35
39
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module User
|
6
|
+
module Parser
|
7
|
+
class User
|
8
|
+
def self.parse(command)
|
9
|
+
string = command.to_s
|
10
|
+
string = string.split[0]
|
11
|
+
|
12
|
+
matches = string.match(/uid=\d+\((.+)\)/)
|
13
|
+
return if !matches || !matches.captures
|
14
|
+
|
15
|
+
matches.captures.first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -35,7 +35,7 @@ RSpec.shared_examples 'user' do |os_name, host_json, _spec_dir|
|
|
35
35
|
expect(host.get_uid('asdf').to_i).to eq(nil)
|
36
36
|
end
|
37
37
|
|
38
|
-
it 'gets a user details' do
|
38
|
+
it 'gets a user details by name' do
|
39
39
|
result = host.get_user(host_json['username'])
|
40
40
|
expect(result.uid).to eq(1000)
|
41
41
|
expect(result.name).to eq(host_json['username'])
|
@@ -49,6 +49,20 @@ RSpec.shared_examples 'user' do |os_name, host_json, _spec_dir|
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
it 'gets a user details by uid' do
|
53
|
+
result = host.get_user(1000)
|
54
|
+
expect(result.uid).to eq(1000)
|
55
|
+
expect(result.name).to eq(host_json['username'])
|
56
|
+
expect(result.home.path).to eq(host_json['home'])
|
57
|
+
|
58
|
+
case os_name
|
59
|
+
when 'opensuse', 'sles'
|
60
|
+
expect(result.groups[0]).to have_attributes(gid: 100, name: 'users')
|
61
|
+
else
|
62
|
+
expect(result.groups[0]).to have_attributes(gid: 1000, name: host_json['username'])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
52
66
|
it 'manages a user' do
|
53
67
|
## Need priviledge escalation to manage group
|
54
68
|
host.su('root')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanrisuru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel_tests
|
@@ -347,6 +347,7 @@ files:
|
|
347
347
|
- lib/kanrisuru/core/user/parser.rb
|
348
348
|
- lib/kanrisuru/core/user/parsers/getent.rb
|
349
349
|
- lib/kanrisuru/core/user/parsers/groups.rb
|
350
|
+
- lib/kanrisuru/core/user/parsers/user.rb
|
350
351
|
- lib/kanrisuru/core/user/types.rb
|
351
352
|
- lib/kanrisuru/core/yum.rb
|
352
353
|
- lib/kanrisuru/core/yum/commands.rb
|