specinfra 2.80.0 → 2.81.0

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
  SHA1:
3
- metadata.gz: c8d0e4faade38fa3aa500bd8682dbc261fa7f568
4
- data.tar.gz: 1a3aed9b7fdb66048e31b0dce53c0056b697efb4
3
+ metadata.gz: 111c7d5597fd8dd3b5e7cd5d579116f0d737a8a7
4
+ data.tar.gz: deb4176282e0c2cf3ebbeeaa4762d8dcb6ddba91
5
5
  SHA512:
6
- metadata.gz: e0ec48e0126fad8c4448ff22dd613b961ff76c239f9169621a76679dbb9becd6cd56202ebcd3736e6740f97837f8dde7e831dce4a7392cfb9be9b4efc20ef49e
7
- data.tar.gz: 50bdc7278dd4d467f3affc2fb45f050b3077e2d9a707b43bf4ec2ffa50818af99a03e5eede7a076ebf137c7977af821128ccce2967da5fe4242ba1c47a2bf741
6
+ metadata.gz: d4c1a4b94b2d292c1ea6377df2663a378061b9e4fb81d99f330f20fab0f857191d8008d8ccf86ed361f81227d50b1c3811cc51ff011f9db08d0fb351b32bfa27
7
+ data.tar.gz: b450a2fe01de72c1c3df2ee0bd944253e95bb042c25f36e9def21e5fa391ec1e68c0f848b92506cda6fa9bcee83449c274a8123d42532dff96c7483d9349e60f
@@ -8,6 +8,14 @@ class Specinfra::Command::Base::Group < Specinfra::Command::Base
8
8
  "getent group #{escape(group)} | cut -f 3 -d ':' | grep -w -- #{escape(gid)}"
9
9
  end
10
10
 
11
+ def check_is_system_group(group)
12
+ exists = "getent group #{escape(group)} > /dev/null 2>&1"
13
+ gid = "getent group #{escape(group)} | cut -f 3 -d ':'"
14
+ sys_gid_min = "awk 'BEGIN{sys_gid_min=101} {if($1~/^SYS_GID_MIN/){sys_gid_min=$2}} END{print sys_gid_min}' /etc/login.defs"
15
+ sys_gid_max = "awk 'BEGIN{sys_gid_max=0;gid_min=1000} {if($1~/^SYS_GID_MAX/){sys_gid_max=$2}if($1~/^GID_MIN/){gid_min=$2}} END{if(sys_gid_max!=0){print sys_gid_max}else{print gid_min-1}}' /etc/login.defs"
16
+ %Q|#{exists} && test "$(#{gid})" -ge "$(#{sys_gid_min})" && test "$(#{gid})" -le "$(#{sys_gid_max})"|
17
+ end
18
+
11
19
  def get_gid(group)
12
20
  "getent group #{escape(group)} | cut -f 3 -d ':'"
13
21
  end
@@ -12,6 +12,14 @@ class Specinfra::Command::Base::User < Specinfra::Command::Base
12
12
  "id -gn #{escape(user)}| grep ^#{escape(group)}$"
13
13
  end
14
14
 
15
+ def check_is_system_user(user)
16
+ exists = "getent passwd #{escape(user)} > /dev/null 2>&1"
17
+ uid = "getent passwd #{escape(user)} | cut -f 3 -d ':'"
18
+ sys_uid_min = "awk 'BEGIN{sys_uid_min=101} {if($1~/^SYS_UID_MIN/){sys_uid_min=$2}} END{print sys_uid_min}' /etc/login.defs"
19
+ sys_uid_max = "awk 'BEGIN{sys_uid_max=0;uid_min=1000} {if($1~/^SYS_UID_MAX/){sys_uid_max=$2}if($1~/^UID_MIN/){uid_min=$2}} END{if(sys_uid_max!=0){print sys_uid_max}else{print uid_min-1}}' /etc/login.defs"
20
+ %Q|#{exists} && test "$(#{uid})" -ge "$(#{sys_uid_min})" && test "$(#{uid})" -le "$(#{sys_uid_max})"|
21
+ end
22
+
15
23
  def check_has_uid(user, uid)
16
24
  regexp = "^uid=#{uid}("
17
25
  "id #{escape(user)} | grep -- #{escape(regexp)}"
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.80.0"
2
+ VERSION = "2.81.0"
3
3
  end
@@ -17,3 +17,7 @@ end
17
17
  describe get_command(:add_group, 'foo', :system_group => true) do
18
18
  it { should eq 'groupadd -r foo' }
19
19
  end
20
+
21
+ describe get_command(:check_group_is_system_group, 'foo') do
22
+ it { should eq "getent group foo > /dev/null 2>&1 && test \"$(getent group foo | cut -f 3 -d ':')\" -ge \"$(awk 'BEGIN{sys_gid_min=101} {if($1~/^SYS_GID_MIN/){sys_gid_min=$2}} END{print sys_gid_min}' /etc/login.defs)\" && test \"$(getent group foo | cut -f 3 -d ':')\" -le \"$(awk 'BEGIN{sys_gid_max=0;gid_min=1000} {if($1~/^SYS_GID_MAX/){sys_gid_max=$2}if($1~/^GID_MIN/){gid_min=$2}} END{if(sys_gid_max!=0){print sys_gid_max}else{print gid_min-1}}' /etc/login.defs)\"" }
23
+ end
@@ -57,3 +57,7 @@ end
57
57
  describe get_command(:update_user_login_shell, 'foo', '/bin/bash') do
58
58
  it { should eq 'usermod -s /bin/bash foo' }
59
59
  end
60
+
61
+ describe get_command(:check_user_is_system_user, 'foo') do
62
+ it { should eq "getent passwd foo > /dev/null 2>&1 && test \"$(getent passwd foo | cut -f 3 -d ':')\" -ge \"$(awk 'BEGIN{sys_uid_min=101} {if($1~/^SYS_UID_MIN/){sys_uid_min=$2}} END{print sys_uid_min}' /etc/login.defs)\" && test \"$(getent passwd foo | cut -f 3 -d ':')\" -le \"$(awk 'BEGIN{sys_uid_max=0;uid_min=1000} {if($1~/^SYS_UID_MAX/){sys_uid_max=$2}if($1~/^UID_MIN/){uid_min=$2}} END{if(sys_uid_max!=0){print sys_uid_max}else{print uid_min-1}}' /etc/login.defs)\"" }
63
+ 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.80.0
4
+ version: 2.81.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: 2019-07-29 00:00:00.000000000 Z
11
+ date: 2019-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp