sshkit 0.0.13 → 0.0.14

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/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  This file is written in reverse chronological order, newer releases will
4
4
  appear at the top.
5
5
 
6
+ ## 0.0.14
7
+
8
+ * Umasks can now be set on `Command` instances. It can be set globally with
9
+ `SSHKit.config.umask` (default, nil; meaning take the system default). This
10
+ can be used to set, for example a umask of `007` for allowing users with
11
+ the same primary group to share code without stepping on eachother's toes.
12
+
6
13
  ## 0.0.13
7
14
 
8
15
  * Correctly quote `as(user)` commands, previously it would expand to:
@@ -147,6 +147,9 @@ module SSHKit
147
147
  if options[:run_in_background]
148
148
  cs << 'nohup '
149
149
  end
150
+ if umask = SSHKit.config.umask
151
+ cs << "umask #{umask} && "
152
+ end
150
153
  cs << SSHKit.config.command_map[command.to_sym]
151
154
  if args.any?
152
155
  cs << ' '
@@ -2,6 +2,7 @@ module SSHKit
2
2
 
3
3
  class Configuration
4
4
 
5
+ attr_accessor :umask
5
6
  attr_writer :output, :backend, :default_env, :command_map
6
7
 
7
8
  def output
@@ -1,3 +1,3 @@
1
1
  module SSHKit
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -96,6 +96,30 @@ module SSHKit
96
96
  assert_equal "( A=b sudo su anotheruser -c \"nohup /usr/bin/env sleep 15 > /dev/null &\" )", String(c)
97
97
  end
98
98
 
99
+ def test_umask
100
+ SSHKit.config.umask = '007'
101
+ c = Command.new(:touch, 'somefile')
102
+ assert_equal "umask 007 && /usr/bin/env touch somefile", String(c)
103
+ end
104
+
105
+ def test_umask_with_working_directory
106
+ SSHKit.config.umask = '007'
107
+ c = Command.new(:touch, 'somefile', in: '/opt')
108
+ assert_equal "cd /opt && umask 007 && /usr/bin/env touch somefile", String(c)
109
+ end
110
+
111
+ def test_umask_with_working_directory_and_user
112
+ SSHKit.config.umask = '007'
113
+ c = Command.new(:touch, 'somefile', in: '/var', user: 'alice')
114
+ assert_equal "cd /var && sudo su alice -c \"umask 007 && /usr/bin/env touch somefile\"", String(c)
115
+ end
116
+
117
+ def test_umask_with_env_and_working_directory_and_user
118
+ SSHKit.config.umask = '007'
119
+ c = Command.new(:touch, 'somefile', user: 'bob', env: {a: 'b'}, in: '/var')
120
+ assert_equal "cd /var && ( A=b sudo su bob -c \"umask 007 && /usr/bin/env touch somefile\" )", String(c)
121
+ end
122
+
99
123
  def test_complete?
100
124
  c = Command.new(:whoami, raise_on_non_zero_exit: false)
101
125
  refute c.complete?
@@ -15,6 +15,12 @@ module SSHKit
15
15
  assert SSHKit.config.output = $stderr
16
16
  end
17
17
 
18
+ def test_umask
19
+ assert SSHKit.config.umask.nil?
20
+ assert SSHKit.config.umask = '007'
21
+ assert_equal '007', SSHKit.config.umask
22
+ end
23
+
18
24
  def test_default_env
19
25
  assert SSHKit.config.default_env
20
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: