Class: Vagrant::LXC::Command::Sudoers
- Inherits:
-
Object
- Object
- Vagrant::LXC::Command::Sudoers
- Defined in:
- lib/vagrant-lxc/command/sudoers.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv, env) ⇒ Sudoers
constructor
A new instance of Sudoers.
- #sudoers_path ⇒ Object
Constructor Details
#initialize(argv, env) ⇒ Sudoers
Returns a new instance of Sudoers.
11 12 13 14 15 |
# File 'lib/vagrant-lxc/command/sudoers.rb', line 11 def initialize(argv, env) super @argv @env = env end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-lxc/command/sudoers.rb', line 17 def execute = { user: ENV['USER'] } opts = OptionParser.new do |opts| opts. = "Usage: vagrant lxc sudoers" opts.separator "" opts.on('-u user', '--user user', String, "The user for which to create the policy (defaults to '#{options[:user]}')") do |u| [:user] = u end end argv = (opts) return unless argv wrapper_path = SudoWrapper.dest_path wrapper = create_wrapper! sudoers = create_sudoers!([:user], wrapper_path) su_copy([ {source: wrapper, target: wrapper_path, mode: "0555"}, {source: sudoers, target: sudoers_path, mode: "0440"} ]) end |
#sudoers_path ⇒ Object
41 42 43 |
# File 'lib/vagrant-lxc/command/sudoers.rb', line 41 def sudoers_path "/etc/sudoers.d/vagrant-lxc" end |