vagrant-norequiretty 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b12dc68ddc3bb61e2561b11a2dc5ff5ba230a2f4
4
+ data.tar.gz: 24fa9df78f7003c212f64ebb00d239f369023c97
5
+ SHA512:
6
+ metadata.gz: 97c18ebf6ec5b57664887d1f1dd59d967a17456ae918c22fb9804ac4cd5198487794c0caa499f4bbf20283e79e357b98d16de41b70e8328ad99b35aa44fa24ad
7
+ data.tar.gz: 0c12b01a2498b93c93a2660450a484578213277d082000b2a8d0f11450ba40d11e05bba31846ea787ab22aade222975256506bd9bbb7cfb2831234ceba426ed8
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .bundle
2
+ .ruby-version
3
+ .yardoc
4
+ /doc
5
+ Gemfile.lock
6
+ Gemfile.local
7
+ *.gem
data/README.markdown ADDED
@@ -0,0 +1,52 @@
1
+ vagrant-norequiretty
2
+ ====================
3
+
4
+ A Vagrant plugin that disables `requiretty` on Linux guests. We've all seen it
5
+ before. The dreaded "you must have a tty to run sudo" error:
6
+
7
+ ```
8
+ The following SSH command responded with a non-zero exit status.
9
+ Vagrant assumes that this means the command failed!
10
+
11
+ Stderr from the command:
12
+
13
+ sudo: sorry, you must have a tty to run sudo
14
+ ```
15
+
16
+ Simply install this plugin and it will attempt to make that error disappear by
17
+ hooking into the Vagrant startup sequence and sanitizing `/etc/sudoers` before
18
+ other commands run.
19
+
20
+ To install, simply run:
21
+
22
+ vagrant plugin install vagrant-norequiretty
23
+
24
+ Everything else should start happening automagically™.
25
+
26
+ Synopsis
27
+ ========
28
+
29
+ This error is caused by many VM templates and default installations requiring
30
+ a TTY to use `sudo` due to concerns about eching plaintext passwords in the
31
+ clear. For many cases,
32
+ [this requirement is questionable](https://bugzilla.redhat.com/show_bug.cgi?id=1020147):
33
+
34
+ > Well, I know how to work around this.
35
+ >
36
+ > But nobody has yet explained why I have to.
37
+ >
38
+ > The problem is not that it's annoying, the problem is that it's annoying for no value. The case that it was supposed to handle is handled just fine without it.
39
+ >
40
+ > So let me re-state the cons of this:
41
+ >
42
+ > 1) it adds no security
43
+ > 2) it breaks valid usage
44
+ > 3) it diverges from the upstream
45
+ >
46
+ > I see no pros. Do you?
47
+
48
+ This Vagrant plugin hooks into startup actions for VirtualBox, vSphere and
49
+ VMware Desktop providers and runs a `sed` command to purge the `requiretty`
50
+ setting before provisioners, synced folders and networking actions are executed.
51
+
52
+ Support for additional providers coming soon.
@@ -0,0 +1,4 @@
1
+ module VagrantHosts
2
+ require 'vagrant-norequiretty/version'
3
+ require 'vagrant-norequiretty/plugin'
4
+ end
@@ -0,0 +1,37 @@
1
+ module VagrantNoRequireTTY
2
+ class Action
3
+ def initialize(app, env)
4
+ @app = app
5
+ @env = env
6
+ @machine = env[:machine]
7
+ @set = false
8
+ end
9
+
10
+ def call(env)
11
+ # So nice, we call it twice.
12
+ disable_requiretty!
13
+
14
+ @app.call(env)
15
+
16
+ disable_requiretty!
17
+ end
18
+
19
+ private
20
+
21
+ def disable_requiretty!
22
+ if supports_requiretty?(@machine) && (not @set)
23
+ @machine.guest.capability(:norequiretty)
24
+ @set = true
25
+ end
26
+ end
27
+
28
+ def supports_requiretty?(machine)
29
+ machine.communicate.ready? && machine.guest.capability?(:norequiretty)
30
+ rescue Vagrant::Errors::VagrantError
31
+ # WinRM will raise an error if the VM isn't running instead of
32
+ # returning false.
33
+ false
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,16 @@
1
+ class VagrantNoRequireTTY::Cap
2
+
3
+ # @return [void]
4
+ def self.norequiretty(machine)
5
+ old_pty_setting = machine.config.ssh.pty
6
+ machine.config.ssh.pty = true
7
+
8
+ machine.ui.info ("Ensuring requiretty is disabled...")
9
+ machine.communicate.sudo(<<-'EOS', pty: true)
10
+ sed -i'.bk' -e 's/^\(Defaults\s\+requiretty\)/# \1/' /etc/sudoers
11
+ EOS
12
+ ensure
13
+ machine.config.ssh.pty = old_pty_setting
14
+ end
15
+
16
+ end
@@ -0,0 +1,30 @@
1
+ require 'vagrant'
2
+ require 'vagrant-norequiretty'
3
+
4
+ class VagrantNoRequireTTY::Plugin < Vagrant.plugin(2)
5
+ name 'norequiretty'
6
+
7
+ description <<-DESC
8
+ This plugin adds one provisioner, norequiretty, which EnDs tHE mADneSssss..
9
+
10
+ https://bugzilla.redhat.com/show_bug.cgi?id=1020147
11
+ DESC
12
+
13
+ action_hook('Disable requiretty') do |hook|
14
+ require_relative 'action'
15
+ action = VagrantNoRequireTTY::Action
16
+
17
+ # For RSync.
18
+ hook.after(Vagrant::Action::Builtin::SyncedFolders, action)
19
+ # For everything else.
20
+ # For great justice.
21
+ end
22
+
23
+ [:linux].each do |os|
24
+ guest_capability(os, :norequiretty) do
25
+ require_relative 'cap'
26
+ VagrantNoRequireTTY::Cap
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,3 @@
1
+ module VagrantNoRequireTTY
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-norequiretty/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'vagrant-norequiretty'
8
+ spec.version = VagrantNoRequireTTY::VERSION
9
+ spec.authors = ['Charlie Sharpsteen']
10
+ spec.email = ['source@sharpsteen.net']
11
+ spec.license = 'Apache 2.0'
12
+
13
+ spec.summary = 'A Vagrant Plugin that ensures requiretty is disabled'
14
+ spec.homepage = 'https://github.com/oscar-stack/vagrant-norequiretty'
15
+ spec.description = <<-EOS
16
+ Ever get a "sorry, you must have a tty to run sudo" error? Maybe
17
+ this plugin can help!
18
+ EOS
19
+
20
+ spec.files = %x[git ls-files].split($/)
21
+ spec.require_paths = ['lib']
22
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-norequiretty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Charlie Sharpsteen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ Ever get a "sorry, you must have a tty to run sudo" error? Maybe
15
+ this plugin can help!
16
+ email:
17
+ - source@sharpsteen.net
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".gitignore"
23
+ - README.markdown
24
+ - lib/vagrant-norequiretty.rb
25
+ - lib/vagrant-norequiretty/action.rb
26
+ - lib/vagrant-norequiretty/cap.rb
27
+ - lib/vagrant-norequiretty/plugin.rb
28
+ - lib/vagrant-norequiretty/version.rb
29
+ - vagrant-norequiretty.gemspec
30
+ homepage: https://github.com/oscar-stack/vagrant-norequiretty
31
+ licenses:
32
+ - Apache 2.0
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.4.5.1
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: A Vagrant Plugin that ensures requiretty is disabled
54
+ test_files: []
55
+ has_rdoc: