Commit graph

32 commits

Author SHA1 Message Date
Virgil Dupras
97b5882262 Refactoring: make SudoWrapper a bit more self-contained
By looking at the code, it seems that it was a goal to make the sudo
wrapper path configurable through the Vagrantfile, but it wasn't
effective and didn't make much sense (that kind of config is a per-host
config, not a per-guest one).

This caused the cause to be needlessly complex by giving the Provider
the responsibility of instanciating the wrapper. This commit gets rid of
that.

I didn't get rid of `sudo_wrapper` injection in `Driver` and
`Driver::CLI` constructors because they're needed for tests. I'm not
ready to tackle this yet.
2018-01-13 08:32:27 -05:00
Virgil Dupras
10c53c54d7 Support alternative lxcpath in sudo wrapper
The previously hardcoded lxc path prevented the sudo wrapper from
working in environment with alternative `lxcpath`.

I had to move `sudo_wrapper` from `provider` to `LXC` because the
concept of "provider" is tied to a machine when a command sush as
`sudoers` is not.

Fixes #413 and #399
2017-12-11 11:48:19 -05:00
Robin Gloster
4b78c04a47 Use /usr/bin/env CMD instead of hardcoded paths
This fixes commands that currently rely on hardcoded paths and break
on systems like NixOS that don't have all binaries in /usr/bin etc.
2015-08-02 10:15:55 +00:00
Fabio Rehm
758703ea6b provider: Use full which path when checking whether the lxc-create command is available
Fixes GH-322
2015-01-08 02:26:25 -02:00
Fabio Rehm
8b37056294 provider: Show an user friendly message when trying to use the plugin on non-Linux environments 2015-01-08 02:17:32 -02:00
Fabio Rehm
186d453621 Prefix action to fetch containers IP with ssh so that vagrant does not lock around its execution
Closes GH-321
2014-10-15 01:02:52 -03:00
Ray Ruvinskiy
dc55c914e4 Work around WaitForCommunicator lock race condition
The LXC provider issues the "fetch_ip" action to look up the IP address
of the container as part of its "ssh_info" action.
Vagrant::LXC::Action.action_fetch_ip checks the machine state using
Builtin::IsState, which calls Vagrant::Machine.state, which also updates
the state in the machine index and acquires a machine index entry lock to do that.
A race condition ensues in WaitForCommunicator.call, where ready_thr tries
to acquire the machine index lock while running ssh_info, and states_thr tries
to acquire the same lock doing its own state look up (env[:machine].state.id).
If they both try to acquire the lock at the same time, one will fail, and
an exception will be raised.

Work around this issue by checking for the desired machine state (:running) in
Vagrant::LXC::Provider.ssh_info, which can get the state from
Vagrant::LXC::Provider.state, which in turn does not write out the state into
the index file and does not acquire the index entry lock.
2014-09-29 16:47:29 -04:00
Jef Mathiot
94e175dc07 sudoers command now creates a safe wrapper script.
Sudoers now creates a safe wrapper script that performs sanity checks on sudo :
* wrapper generated in /usr/local/bin (name includes version to allow multiple wrappers on the same system)
* sudoers command now generates a one-line file in /etc/sudoers.d
* SudoWrapper use the new wrapper
* Removed unused Config#validate method
2014-04-09 15:53:20 +02:00
Fabio Rehm
005140099c Check for whether lxc is installed using lxc-create
Closes GH-214 and GH-211
2014-02-12 01:41:55 -02:00
Fabio Rehm
6066d22ad9 Simplify check for whether lxc is installed [GH-186] 2013-12-17 22:59:32 -02:00
Jan Vansteenkiste
9b7491c2e8 Attempt to find the lxc-version command using sudo
... if lxc-version is not found in the efault PATH

Fixes #195
2013-11-12 13:38:50 +01:00
Fabio Rehm
0385a64d31 Replace ugly driver builder with a more intelligent approach
References #118
2013-07-29 12:08:24 -03:00
Fabio Rehm
97f6edeed8 Error out if LXC is not installed
This is enough to close #11
2013-07-28 02:55:00 -03:00
Fabio Rehm
d62a053674 Add support for using a sudo wrapper script
Closes #90
2013-07-28 02:17:07 -03:00
Fabio Rehm
a9c4745b78 Hack in support for fetching container IPs from dnsmasq leases
Closes #49
2013-04-10 02:02:38 -03:00
Fabio Rehm
1eb7b52da9 💣 custom machine state class 2013-04-08 20:12:05 -03:00
Fabio Rehm
ed552b6af0 Driver#name -> Driver#container_name 2013-04-05 22:28:41 -03:00
Fabio Rehm
514736bdd6 Rename old container references to driver 2013-04-05 22:10:48 -03:00
Fabio Rehm
082f7dc5d3 Rename Container to Driver 2013-04-05 22:10:48 -03:00
Fabio Rehm
1fcdc07a3a Remove crazy TODO note 2013-04-05 22:10:48 -03:00
Fabio Rehm
78f8393536 Update comment reference 2013-03-29 12:31:36 -03:00
Fabio Rehm
31f60022d8 Allow setting guest ssh port from Vagrantfile 2013-03-29 12:29:24 -03:00
Fabio Rehm
d2a1eeeabc Use arp to grab container ip instead of dig (it seems to be more reliable)
References: #31
2013-03-10 01:55:18 -03:00
Fabio Rehm
238b5cd681 Move vendored_vagrant require to the right place 2013-03-10 00:45:27 -03:00
Fabio Rehm
9a168950fe First stab at handling a custom lxc-dhcp IP
Will help on #23
2013-03-08 04:32:47 -03:00
Fabio Rehm
22e5a48af5 Add ssh_info to provider 2013-03-02 16:45:14 -03:00
Fabio Rehm
849e9c73d7 Rename LXC::Actions to LXC::Action 2013-03-02 03:57:03 -03:00
Fabio Rehm
5291f13316 Handle stale machine id / container name 2013-03-02 01:18:38 -03:00
Fabio Rehm
661b00ea22 Remove LXC::Container dependency on a vagrant machine 2013-03-02 00:55:45 -03:00
Fabio Rehm
7168da249e Extract container object 2013-03-01 00:34:51 -03:00
Fabio Rehm
1bdd3f87a6 Hook up provider with some "placeholder" actions 2013-02-28 00:21:59 -03:00
Fabio Rehm
faa2aaa6ab Scaffold config, plugin and provider classes 2013-02-28 00:20:54 -03:00