kanrisuru 0.16.11 → 0.16.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/kanrisuru/core/group/commands/create_group.rb +2 -0
- data/lib/kanrisuru/core/mount/commands/umount.rb +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/lib/kanrisuru.rb +1 -1
- data/spec/functional/core/group_spec.rb +8 -1
- data/spec/functional/core/mount_spec.rb +2 -0
- data/spec/support/shared_examples/integration/core/user.rb +15 -1
- data/spec/unit/kanrisuru_spec.rb +4 -0
- 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: f2d1d9331232a2c1c343da0fd4a8d11fcef4b0197aea108fe1d6047a60c390f7
|
4
|
+
data.tar.gz: 8e8cbf4381da58b367fbb9aa2ac29fa68d8c4eed68ca3197cfaedf71cec69f85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5eaa5caba5ae1f48e02fc4d6dadc03ab0ff6a94c47353e365adca6235424189e76ccb41fe513121d97013b819bd149636edef726d988c436269f4d230e524b8
|
7
|
+
data.tar.gz: 9ab07c9fdcf14fc3a314cbce0d9952456fa0daccb77bfeb2e8de92ad4a131f4d5f661033a3ef41c540adc18b73be0e11574b86b65a2392f2d446baaa043f13a0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## Kanrisuru 0.16.15 (January 07, 2022) ##
|
2
|
+
* Add recursive and all_targets opts to `umount` command.
|
3
|
+
|
4
|
+
## Kanrisuru 0.16.14 (January 02, 2022) ##
|
5
|
+
* Fix `get_user` command by parsing output to get user name if uid is passed in.
|
6
|
+
|
7
|
+
## Kanrisuru 0.16.13 (January 01, 2022) ##
|
8
|
+
* Add `non_unique` and `system` opts to `create_group` command
|
9
|
+
|
10
|
+
## Kanrisuru 0.16.12 (January 01, 2022) ##
|
11
|
+
* Update date ranges for 2022 on license files.
|
12
|
+
* Add unit test case for `Kanrisuru::Logger`.
|
13
|
+
|
1
14
|
## Kanrisuru 0.16.11 (December 28, 2021) ##
|
2
15
|
* Add functional and integration test cases for the `Kanrisuru::Remote::Cluster` class.
|
3
16
|
* Allow for passing a command instance into `execute` and `execute_shell` on a cluster instance, by deep copying a command object.
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,9 @@ module Kanrisuru
|
|
16
16
|
|
17
17
|
command.append_flag('-l', opts[:lazy])
|
18
18
|
command.append_flag('-f', opts[:force])
|
19
|
+
|
20
|
+
command.append_flag('--all-targets', opts[:all_targets])
|
21
|
+
command.append_flag('--recursive', opts[:recursive])
|
19
22
|
|
20
23
|
if Kanrisuru::Util.present?(all)
|
21
24
|
command.append_flag('-a')
|
@@ -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
data/lib/kanrisuru.rb
CHANGED
@@ -21,7 +21,14 @@ RSpec.describe Kanrisuru::Core::Group do
|
|
21
21
|
|
22
22
|
it 'prepares create_group command' do
|
23
23
|
expect_command(host.create_group('admin'), 'groupadd admin')
|
24
|
-
expect_command(host.create_group('admin',
|
24
|
+
expect_command(host.create_group('admin',
|
25
|
+
gid: 9000,
|
26
|
+
non_unique: true
|
27
|
+
),
|
28
|
+
'groupadd admin -g 9000 -o'
|
29
|
+
)
|
30
|
+
|
31
|
+
expect_command(host.create_group('admin', gid: 12, system: true), 'groupadd admin -g 12 -r')
|
25
32
|
end
|
26
33
|
|
27
34
|
it 'prepares delete_group command' do
|
@@ -95,6 +95,8 @@ RSpec.describe Kanrisuru::Core::Mount do
|
|
95
95
|
|
96
96
|
it 'prepares umount command' do
|
97
97
|
expect_command(host.umount, 'umount')
|
98
|
+
expect_command(host.umount(recursive: true, all_targets: true), 'umount --all-targets --recursive')
|
99
|
+
|
98
100
|
expect_command(host.umount(
|
99
101
|
fake: true,
|
100
102
|
no_canonicalize: true,
|
@@ -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')
|
data/spec/unit/kanrisuru_spec.rb
CHANGED
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-07 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
|