serverspec 0.2.27 → 0.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  .config
5
5
  .yardoc
6
6
  .rspec
7
+ .idea/
7
8
  Gemfile.lock
8
9
  InstalledFiles
9
10
  _yardoc
@@ -6,10 +6,7 @@ module Serverspec
6
6
  class NotImplementedError < Exception; end
7
7
 
8
8
  def check_access_by_user file, user, access
9
- # - Maybe it could also use the darwin one...
10
- # but using runuser bcs in linux it's common to change the default sudo configuration.
11
- # - Using specific shell to avoid system users not logging in
12
- "runuser -s /bin/sh -c \"test -#{access} #{file}\" #{user}"
9
+ "su -s /bin/sh -c \"/usr/bin/test -#{access} #{file}\" #{user}"
13
10
  end
14
11
 
15
12
  def check_iptables_rule rule, table=nil, chain=nil
@@ -1,6 +1,11 @@
1
1
  module Serverspec
2
2
  module Commands
3
3
  class RedHat < Linux
4
+ def check_access_by_user file, user, access
5
+ # Redhat-specific
6
+ "runuser -s /bin/sh -c \"test -#{access} #{file}\" #{user}"
7
+ end
8
+
4
9
  def check_enabled service
5
10
  "chkconfig --list #{escape(service)} | grep 3:on"
6
11
  end
@@ -87,7 +87,7 @@ module Serverspec
87
87
  # http://docs.oracle.com/cd/E23823_01/html/816-5166/su-1m.html
88
88
  ## No need for login shell as it seems that behavior as superuser is favorable for us, but needs
89
89
  ## to be better tested under real solaris env
90
- "su #{user} test -#{access} #{file}"
90
+ "su #{user} -c \"/usr/bin/test -#{access} #{file}\""
91
91
  end
92
92
  end
93
93
  end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.2.27"
2
+ VERSION = "0.2.28"
3
3
  end
@@ -229,16 +229,16 @@ end
229
229
  describe 'check_access_by_user', :os => :debian do
230
230
  context 'read access' do
231
231
  subject {commands.check_access_by_user '/tmp/something', 'dummyuser1', 'r'}
232
- it { should eq 'runuser -s /bin/sh -c "test -r /tmp/something" dummyuser1' }
232
+ it { should eq 'su -s /bin/sh -c "/usr/bin/test -r /tmp/something" dummyuser1' }
233
233
  end
234
234
 
235
235
  context 'write access' do
236
236
  subject {commands.check_access_by_user '/tmp/somethingw', 'dummyuser2', 'w'}
237
- it { should eq 'runuser -s /bin/sh -c "test -w /tmp/somethingw" dummyuser2' }
237
+ it { should eq 'su -s /bin/sh -c "/usr/bin/test -w /tmp/somethingw" dummyuser2' }
238
238
  end
239
239
 
240
240
  context 'execute access' do
241
241
  subject {commands.check_access_by_user '/tmp/somethingx', 'dummyuser3', 'x'}
242
- it { should eq 'runuser -s /bin/sh -c "test -x /tmp/somethingx" dummyuser3' }
242
+ it { should eq 'su -s /bin/sh -c "/usr/bin/test -x /tmp/somethingx" dummyuser3' }
243
243
  end
244
244
  end
@@ -227,16 +227,17 @@ end
227
227
  describe 'check_access_by_user', :os => :gentoo do
228
228
  context 'read access' do
229
229
  subject {commands.check_access_by_user '/tmp/something', 'dummyuser1', 'r'}
230
- it { should eq 'runuser -s /bin/sh -c "test -r /tmp/something" dummyuser1' }
230
+ it { should eq 'su -s /bin/sh -c "/usr/bin/test -r /tmp/something" dummyuser1' }
231
231
  end
232
232
 
233
233
  context 'write access' do
234
234
  subject {commands.check_access_by_user '/tmp/somethingw', 'dummyuser2', 'w'}
235
- it { should eq 'runuser -s /bin/sh -c "test -w /tmp/somethingw" dummyuser2' }
235
+ it { should eq 'su -s /bin/sh -c "/usr/bin/test -w /tmp/somethingw" dummyuser2' }
236
236
  end
237
237
 
238
238
  context 'execute access' do
239
239
  subject {commands.check_access_by_user '/tmp/somethingx', 'dummyuser3', 'x'}
240
- it { should eq 'runuser -s /bin/sh -c "test -x /tmp/somethingx" dummyuser3' }
240
+ it { should eq 'su -s /bin/sh -c "/usr/bin/test -x /tmp/somethingx" dummyuser3' }
241
241
  end
242
242
  end
243
+
@@ -240,17 +240,17 @@ end
240
240
  describe 'check_access_by_user', :os => :solaris do
241
241
  context 'read access' do
242
242
  subject {commands.check_access_by_user '/tmp/something', 'dummyuser1', 'r'}
243
- it { should eq 'su dummyuser1 test -r /tmp/something' }
243
+ it { should eq 'su dummyuser1 -c "/usr/bin/test -r /tmp/something"' }
244
244
  end
245
245
 
246
246
  context 'write access' do
247
247
  subject {commands.check_access_by_user '/tmp/somethingw', 'dummyuser2', 'w'}
248
- it { should eq 'su dummyuser2 test -w /tmp/somethingw' }
248
+ it { should eq 'su dummyuser2 -c "/usr/bin/test -w /tmp/somethingw"' }
249
249
  end
250
250
 
251
251
  context 'execute access' do
252
252
  subject {commands.check_access_by_user '/tmp/somethingx', 'dummyuser3', 'x'}
253
- it { should eq 'su dummyuser3 test -x /tmp/somethingx' }
253
+ it { should eq 'su dummyuser3 -c "/usr/bin/test -x /tmp/somethingx"' }
254
254
  end
255
255
  end
256
256
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- hash: 33
4
+ hash: 47
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 27
10
- version: 0.2.27
9
+ - 28
10
+ version: 0.2.28
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gosuke Miyashita