aws_runas 0.1.3 → 0.2.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +10 -0
- data/README.md +20 -2
- data/lib/aws_runas/cli.rb +9 -4
- data/lib/aws_runas/main.rb +8 -7
- data/lib/aws_runas/utils.rb +32 -0
- data/lib/aws_runas/version.rb +1 -1
- data/spec/aws_runas/main_spec.rb +1 -0
- data/spec/aws_runas/utils_spec.rb +52 -0
- data.tar.gz.sig +3 -3
- metadata +6 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0753f807b2e12d78b47b70a2c0ad8a794cdd909
|
4
|
+
data.tar.gz: fc978832ef89c676bd8369b078b261b201a6a6dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce7f192507b0633bd339a031d8dc630353358882a8eb1fb78dd51185835538ab2e5da2c8ca2740e3015dc0677f0e06858affc5b069997737603d1bceccfc2761
|
7
|
+
data.tar.gz: 7d16f79ea126d0485afa513404c02b3bdcac7437e8caa6ec97e6faf8c84584789d035800100fef32707d7e293ab7629822e1b1cd935d3d207d0aafa9ec0d054b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
aws_runas CHANGELOG
|
2
2
|
====================
|
3
3
|
|
4
|
+
0.2.0 (Sat Jan 16 23:44:56 PST 2016)
|
5
|
+
-------------------------------------
|
6
|
+
|
7
|
+
* `$SHELL` is now supported - if this environment variable exists, the shell
|
8
|
+
in it will be launched.
|
9
|
+
* Windows support:
|
10
|
+
* `cmd.exe` is set as the default shell on non-Cygwin Windows systems.
|
11
|
+
* Fixes to support mingw32 such as IO flushing and detection of a lack of
|
12
|
+
`noecho` support.
|
13
|
+
|
4
14
|
0.1.3 (Fri 27 Nov 2015 08:05:45 PST)
|
5
15
|
-------------------------------------
|
6
16
|
|
data/README.md
CHANGED
@@ -36,8 +36,8 @@ aws-runas: Run commands under AWS IAM roles
|
|
36
36
|
Usage:
|
37
37
|
aws-runas [options] COMMAND ARGS
|
38
38
|
|
39
|
-
If COMMAND is omitted, the default shell (/bin/sh
|
40
|
-
launch.
|
39
|
+
If COMMAND is omitted, the default shell ($SHELL, /bin/sh, or cmd.exe,
|
40
|
+
depending on your system) will launch.
|
41
41
|
|
42
42
|
[options] are:
|
43
43
|
-p, --path=<s> Path to the AWS config file
|
@@ -52,6 +52,24 @@ following order:
|
|
52
52
|
* `~/.aws/config`, in your user directory.
|
53
53
|
|
54
54
|
|
55
|
+
Usage on Windows
|
56
|
+
-----------------
|
57
|
+
|
58
|
+
`aws_runas` works on Windows platforms, but YMMV. The gem has been tested
|
59
|
+
lightly on Cygwin and MinGW32, and if I needed to recommend one over the other,
|
60
|
+
I would recommend Cygwin.
|
61
|
+
|
62
|
+
If you want to use the gem on Windows without Cygwin, the following below may
|
63
|
+
be necessary:
|
64
|
+
|
65
|
+
### OpenSSL Cert Bundle for Windows
|
66
|
+
|
67
|
+
OpenSSL does not come pre-bundled with a CA certificate bundle on non-Cygwin
|
68
|
+
Windows installations. To get this working with that, you will need to get
|
69
|
+
the certificate bundle from somewhere like [here](http://curl.haxx.se/docs/caextract.html)
|
70
|
+
and set your `SSL_CERT_FILE` environment variable to go to the file.
|
71
|
+
|
72
|
+
|
55
73
|
Author
|
56
74
|
-------
|
57
75
|
|
data/lib/aws_runas/cli.rb
CHANGED
@@ -30,8 +30,8 @@ module AwsRunAs
|
|
30
30
|
Usage:
|
31
31
|
aws-runas [options] COMMAND ARGS
|
32
32
|
|
33
|
-
If COMMAND is omitted, the default shell (/bin/sh
|
34
|
-
launch.
|
33
|
+
If COMMAND is omitted, the default shell ($SHELL, /bin/sh, or cmd.exe,
|
34
|
+
depending on your system) will launch.
|
35
35
|
|
36
36
|
[options] are:
|
37
37
|
EOS
|
@@ -57,8 +57,13 @@ module AwsRunAs
|
|
57
57
|
def read_mfa_if_needed(path: nil, profile: 'default')
|
58
58
|
@cfg = AwsRunAs::Config.new(path: path, profile: profile)
|
59
59
|
return nil unless @cfg.mfa_required?
|
60
|
-
puts 'Enter MFA code:'
|
61
|
-
|
60
|
+
STDOUT.puts 'Enter MFA code:'
|
61
|
+
STDOUT.flush
|
62
|
+
begin
|
63
|
+
STDIN.noecho(&:gets).chomp
|
64
|
+
rescue Errno::EBADF
|
65
|
+
STDIN.gets.chomp
|
66
|
+
end
|
62
67
|
end
|
63
68
|
end
|
64
69
|
end
|
data/lib/aws_runas/main.rb
CHANGED
@@ -13,19 +13,20 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
require 'aws_runas/config'
|
16
|
+
require 'aws_runas/utils'
|
16
17
|
require 'aws-sdk'
|
17
18
|
|
18
19
|
module AwsRunAs
|
19
20
|
# Main program logic for aws-runas - sets up sts asession and assumed role,
|
20
21
|
# and hands off environment to called process.
|
21
22
|
class Main
|
22
|
-
# Instantiate the object and set up the path, profile, and
|
23
|
+
# Instantiate the object and set up the path, profile, and populate MFA
|
23
24
|
def initialize(path: nil, profile: default, mfa_code: nil)
|
24
|
-
if path
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
cfg_path = if path
|
26
|
+
path
|
27
|
+
else
|
28
|
+
AwsRunAs::Config.find_config_file
|
29
|
+
end
|
29
30
|
@cfg = AwsRunAs::Config.new(path: cfg_path, profile: profile)
|
30
31
|
@mfa_code = mfa_code
|
31
32
|
end
|
@@ -62,7 +63,7 @@ module AwsRunAs
|
|
62
63
|
|
63
64
|
def handoff(command: nil, argv: nil)
|
64
65
|
env = credentials_env
|
65
|
-
command =
|
66
|
+
command = AwsRunAs::Utils.shell unless command
|
66
67
|
exec(env, command, *argv)
|
67
68
|
end
|
68
69
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright 2016 Chris Marchesi
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'rbconfig'
|
16
|
+
|
17
|
+
module AwsRunAs
|
18
|
+
# Utility functions that aren't specifically tied to a class.
|
19
|
+
module Utils
|
20
|
+
# load the shell for a specific operating system.
|
21
|
+
# if $SHELL exists, load that.
|
22
|
+
def self.shell
|
23
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw32/i
|
24
|
+
'cmd.exe'
|
25
|
+
elsif ENV.include?('SHELL')
|
26
|
+
ENV['SHELL']
|
27
|
+
else
|
28
|
+
'/bin/sh'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/aws_runas/version.rb
CHANGED
data/spec/aws_runas/main_spec.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Copyright 2016 Chris Marchesi
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'spec_helper'
|
16
|
+
|
17
|
+
describe AwsRunAs::Utils do
|
18
|
+
describe '::shell' do
|
19
|
+
context 'Non-Windows OS' do
|
20
|
+
context 'No $SHELL set' do
|
21
|
+
before(:context) do
|
22
|
+
ENV.delete('SHELL')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns /bin/sh as the shell' do
|
26
|
+
expect(AwsRunAs::Utils.shell).to eq '/bin/sh'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'With $SHELL set as /bin/bash' do
|
31
|
+
before(:context) do
|
32
|
+
ENV.store('SHELL', '/bin/bash')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns /bin/bash as the shell' do
|
36
|
+
expect(AwsRunAs::Utils.shell).to eq '/bin/bash'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'Windows OS' do
|
42
|
+
before(:context) do
|
43
|
+
ENV.delete('SHELL')
|
44
|
+
RbConfig::CONFIG.store('host_os', 'windows')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns cmd.exe as the shell' do
|
48
|
+
expect(AwsRunAs::Utils.shell).to eq 'cmd.exe'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
1Z����8)2��#�����$�7%�A"�����g
|
2
|
+
|*0t�ut�
|
3
|
+
Q-\3da�Zs4�g�N�*ö2�.��a��\Fz�
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws_runas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Marchesi
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
reriQxVYXGlD8ZDuaKlDyVqUbF026ZHIlHKIgg90O037qFPxCBACTtxtYTP2hwug
|
32
32
|
Yis=
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
34
|
+
date: 2016-01-17 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: aws-sdk
|
@@ -154,10 +154,12 @@ files:
|
|
154
154
|
- lib/aws_runas/cli.rb
|
155
155
|
- lib/aws_runas/config.rb
|
156
156
|
- lib/aws_runas/main.rb
|
157
|
+
- lib/aws_runas/utils.rb
|
157
158
|
- lib/aws_runas/version.rb
|
158
159
|
- spec/aws_runas/cli_spec.rb
|
159
160
|
- spec/aws_runas/config_spec.rb
|
160
161
|
- spec/aws_runas/main_spec.rb
|
162
|
+
- spec/aws_runas/utils_spec.rb
|
161
163
|
- spec/helpers/config_spec.rb
|
162
164
|
- spec/helpers/files/aws_config
|
163
165
|
- spec/spec_helper.rb
|
@@ -181,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
183
|
version: '0'
|
182
184
|
requirements: []
|
183
185
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.2.2
|
185
187
|
signing_key:
|
186
188
|
specification_version: 4
|
187
189
|
summary: Run a command or shell under an assumed AWS IAM role
|
@@ -189,6 +191,7 @@ test_files:
|
|
189
191
|
- spec/aws_runas/cli_spec.rb
|
190
192
|
- spec/aws_runas/config_spec.rb
|
191
193
|
- spec/aws_runas/main_spec.rb
|
194
|
+
- spec/aws_runas/utils_spec.rb
|
192
195
|
- spec/helpers/config_spec.rb
|
193
196
|
- spec/helpers/files/aws_config
|
194
197
|
- spec/spec_helper.rb
|
metadata.gz.sig
CHANGED
Binary file
|