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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7e691e6227ba9b1c056be999461a641fd28a425a4d75cb02af41265b724b0af
4
- data.tar.gz: a44f3470adab298c100ada9e954e775df42a38f933bf6533f6f54de096158745
3
+ metadata.gz: f2d1d9331232a2c1c343da0fd4a8d11fcef4b0197aea108fe1d6047a60c390f7
4
+ data.tar.gz: 8e8cbf4381da58b367fbb9aa2ac29fa68d8c4eed68ca3197cfaedf71cec69f85
5
5
  SHA512:
6
- metadata.gz: 631d251e1833edc36568eb00907850a45f39bf623e85b4bc2f45806800ce71de97f1f60e129d4f452d7696f265de1aaa9a8228a67c013edadbd3bdcee94c1f85
7
- data.tar.gz: fee6dcab58110f2addc66c93394b679d6dcc5ac0b83fb619102dd3aed1556a3a4a224f34ad87cda7be79cc8e0d39fd3248e2c7340bc50b64ec5130b79ee640fe
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
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020-2021 Avamia, LLC
3
+ Copyright (c) 2020-2022 Avamia, LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <h1>
2
- <img src="./logo/kanrisuru-logo.png" alt="Kanrisuru" width="400" height="100%"/>
2
+ <img src="https://s3.us-east-2.amazonaws.com/kanrisuru.com/kanrisuru-logo.png" alt="Kanrisuru" width="400" height="100%"/>
3
3
  </h1>
4
4
 
5
5
  <p>
@@ -8,6 +8,8 @@ module Kanrisuru
8
8
 
9
9
  command = Kanrisuru::Command.new("groupadd #{group}")
10
10
  command.append_arg('-g', gid)
11
+ command.append_flag('-o', opts[:non_unique])
12
+ command.append_flag('-r', opts[:system])
11
13
 
12
14
  execute_shell(command)
13
15
 
@@ -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
- ## Get user id
12
- result = get_uid(user)
13
- break if result.failure?
14
-
15
- uid = result.to_i
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
- cmd = Kanrisuru::Command.new("getent passwd #{user}")
28
- cmd | "awk -F: '{print $6, $7}'"
31
+ command2 = Kanrisuru::Command.new("getent passwd #{user}")
32
+ command2 | "awk -F: '{print $6, $7}'"
29
33
 
30
- execute(cmd)
34
+ execute(command2)
31
35
 
32
- result = Kanrisuru::Result.new(cmd) do |cmd2|
36
+ result = Kanrisuru::Result.new(command2) do |cmd2|
33
37
  Parser::Getent.parse(cmd2)
34
38
  end
35
39
 
@@ -2,3 +2,4 @@
2
2
 
3
3
  require_relative 'parsers/getent'
4
4
  require_relative 'parsers/groups'
5
+ require_relative 'parsers/user'
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanrisuru
4
- VERSION = '0.16.11'
4
+ VERSION = '0.16.15'
5
5
  end
data/lib/kanrisuru.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2020-2021 Avamia, LLC
4
+ # Copyright (c) 2020-2022 Avamia, LLC
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
@@ -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', { gid: 9000 }), 'groupadd admin -g 9000')
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')
@@ -6,4 +6,8 @@ RSpec.describe Kanrisuru do
6
6
  it 'has a version number' do
7
7
  expect(Kanrisuru::VERSION).not_to be nil
8
8
  end
9
+
10
+ it 'has logger class' do
11
+ expect(Kanrisuru::Logger).not_to be nil
12
+ end
9
13
  end
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.11
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: 2021-12-29 00:00:00.000000000 Z
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