shells 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/lib/shells/bash_common.rb +30 -0
- data/lib/shells/errors.rb +0 -0
- data/lib/shells/pf_sense_common.rb +0 -0
- data/lib/shells/pf_sense_serial_session.rb +0 -0
- data/lib/shells/pf_sense_ssh_session.rb +0 -0
- data/lib/shells/serial_session.rb +0 -0
- data/lib/shells/shell_base.rb +1 -0
- data/lib/shells/ssh_session.rb +2 -1
- data/lib/shells/version.rb +1 -1
- data/lib/shells.rb +0 -0
- data/shells.gemspec +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff3218a25e2f8801926946df4d8f1d5c99cd4485
|
4
|
+
data.tar.gz: c882cd4c588766c21dd819817c22d8a9dd2db154
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fcb625d9d48f2096a858326e5430555527d9956bda1747fb7fafc2911b73c6cb8b5fc5de0d0e5c6989ca7457b9d239183b7793cc20c0ba1009fe1ecc50a00ed
|
7
|
+
data.tar.gz: 5738c4d03f81e93b05806bd8ff76933afc37110ed53e4e826550771bb21c78b59be97d0e33aa4aa06d59f9a5686a779ec114b9a6fc7552f5c8f55c582fff6e4f
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/lib/shells/bash_common.rb
CHANGED
@@ -35,6 +35,36 @@ module Shells
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
##
|
39
|
+
# Executes an elevated command using the 'sudo' command.
|
40
|
+
def sudo_exec(command, options = {}, &block)
|
41
|
+
sudo_prompt = '[sp:'
|
42
|
+
sudo_match = /[\r\n]\[sp:$/
|
43
|
+
sudo_strip = /\[sp:[^\n]*\n/
|
44
|
+
ret = exec("sudo -p \"#{sudo_prompt}\" bash -c \"#{command.gsub('"', '\\"')}\"", options) do |data,type|
|
45
|
+
test_data = data.to_s
|
46
|
+
desired_length = sudo_prompt.length + 1 # prefix a NL before the prompt.
|
47
|
+
|
48
|
+
# pull from the current stdout to get the full test data, but only if we received some new data.
|
49
|
+
if test_data.length > 0 && test_data.length < desired_length
|
50
|
+
test_data = stdout[-desired_length..-1].to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
if test_data =~ sudo_match
|
54
|
+
options[:password]
|
55
|
+
else
|
56
|
+
if block
|
57
|
+
block.call(data, type)
|
58
|
+
else
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
# remove the sudo prompts.
|
64
|
+
ret.gsub(sudo_strip, '')
|
65
|
+
end
|
66
|
+
|
67
|
+
|
38
68
|
protected
|
39
69
|
|
40
70
|
##
|
data/lib/shells/errors.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/shells/shell_base.rb
CHANGED
data/lib/shells/ssh_session.rb
CHANGED
@@ -22,7 +22,8 @@ module Shells
|
|
22
22
|
# The user to login with. This option is required.
|
23
23
|
# +password+::
|
24
24
|
# The password to login with.
|
25
|
-
# If our public key is an authorized key on the host, the password is ignored.
|
25
|
+
# If our public key is an authorized key on the host, the password is ignored for connection.
|
26
|
+
# The #sudo_exec method for bash-like shells will also use this password for elevation.
|
26
27
|
# +prompt+::
|
27
28
|
# The prompt used to determine when processes finish execution.
|
28
29
|
# Defaults to '~~#', but if that doesn't work for some reason because it is valid output from one or more
|
data/lib/shells/version.rb
CHANGED
data/lib/shells.rb
CHANGED
File without changes
|
data/shells.gemspec
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shells
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beau Barker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|