237 Commits

Author SHA1 Message Date
Stephen Fox
9537cb32ed security: Removed unsafe relative path sourcing.
The "vm" script is responsible for executing shell script
functions found in other vm-bhyve scripts. It does this by
sourcing other vm-bhyve shell scripts, which automatically
execute code that handles the user's input.

One of the first actions "vm" takes is to check if the relative
file "./lib/vm-core" exists. If this file exists, it sets
the parent directory for sourcing scripts to "./lib",
resulting in all shell scripts being sourced from a path
relative to the user's current working directory.

This is unsafe because sourcing from a relative file path
may result in execution of untrusted code.

For example, imagine the user cloned a git repository that
contains malicious code stored at "<git-dir>/lib/". If the
user were to "cd" to this imaginary cloned repository and
execute the "vm" script, they would inadvertently source and
execute code from that directory.

This commit removes this behavior. The "vm" script now
sources scripts exclusively from "/usr/local/lib/vm-bhyve/".
2022-04-09 17:08:43 -04:00
Dries Michiels
613dfc2901 Update vm 2018-12-24 17:11:37 +01:00
Matt Churchyard
b9c6008ecd Move all logic from vm into lib/vm-base
This makes it much easier to switch between versions or modify functionality
just by switching the library files. Very useful for development and also means
the version displayed by "vm version" is linked to the lib files being used, which
is far more appropriate than just the version of the vm executable you have in PATH.
2018-06-29 09:36:38 +00:00
Matt Churchyard
a8e3b1c5cc Change all option handling to be "vm subcommand <opts>"
To reduce code we originally parsed some options globally, such as "vm -f start ...".
However this was confusing and inconsistent, especially in relation to other commands
such as zfs(8).
2018-06-29 09:03:27 +00:00
Matt Churchyard
4929301769 Error in last commit regarding ZFS dataset name in vm::prestart 2018-06-28 12:20:33 +00:00
Matt Churchyard
8c117b33a5 Change prestart to pass ZFS dataset instead of filesystem path
Dataset is only of use if running on ZFS, but in that case it is very
useful if the script wants to create snapshots/etc, and the path can
be retrieved from pwd/cwd if needed.
2018-06-28 09:31:42 +00:00
Matt Churchyard
151a2f375c Add a prestart option to allow user code to run before guest starts 2018-06-28 09:17:45 +00:00
Matt Churchyard
6b4b97584e Tidy some functions up and limit switch names to 12 chars 2018-06-27 08:34:12 +00:00
Matt Churchyard
fed0ba11db Have a go at ordered shutdown request #194
Look at running guests and try to stop any listed in $vm_list in reverse order.
Anything else is told to stop in bulk first
2018-06-26 14:06:55 +00:00
Matt Churchyard
52de25c3e8 Fix #133. Can't repro but multiple confirmations that delay helps reboot error 2018-06-26 11:55:57 +00:00
Matt Churchyard
5af359386e Use groups to make managing interfaces a bit cleaner/easier 2018-06-26 10:31:30 +00:00
Matt Churchyard
ab73130132 Move master to next version 2018-06-26 09:56:51 +00:00
Matt Churchyard
6ea3ad8af9 Fix #225 - no command specified 2018-06-25 13:24:19 +00:00
Matt Churchyard
4169a47875 Add support for vm destroy guest@snap. Fixes #126 2018-06-25 12:20:47 +00:00
Matt Churchyard
058ec6da67 Remove nat setting from info as it's meaningless 2018-06-25 08:36:08 +00:00
Matt Churchyard
cd1db02bc8 Disable debug mode! 2018-06-25 08:22:27 +00:00
Matt Churchyard
728fb8d603 Fix vlan device naming and check all calls to switch::standard::id
return id is always set so we need to check return status
2018-06-25 08:21:22 +00:00
Matt Churchyard
c67fc3758e Fix #223 - switch::standard::id failure
Test causes an error return value on successful ifconfig
2018-06-25 08:01:58 +00:00
Matt Churchyard
47bfe768f9 Re-tag current release as a beta 2018-06-25 07:54:28 +00:00
Matt Churchyard
ec61996eac Remove the NAT commands other than the core command with a warning message
It's actually far easier and less error-prone to create a standard or manual
switch, then configure whichever NAT service the user wants to use manually.
2018-06-22 13:21:51 +00:00
Matt Churchyard
7db395ff76 Exiting early on a bad command broke option handling 2018-06-22 12:13:49 +00:00
Matt Churchyard
056b30d85e Rework switches to use the switch name as the actual bridge name
Makes identifying the correct interface easier and looks nicer in ifconfig
2018-06-22 11:54:20 +00:00
Matt Churchyard
1edf7155fa Don't output an entire screen of usage info for an invalid command 2018-06-22 08:33:43 +00:00
Matt Churchyard
769d030f26 remove defunct nmdm code 2018-06-22 08:00:21 +00:00
Matt Churchyard
8d11d35dce Add support for named nmdm consoles, and partial commands
It's now possible to run commands such as "vm l" or "vm conf <guest>"
Also named console ports allows us to not bother trying to find the next nmdm number
2018-06-22 07:41:53 +00:00
Matt Churchyard
6b74268c7b Simply code to check existance of custom bridge interface 2018-06-21 14:41:02 +00:00
Matt Churchyard
f720c67791 switch::vale::create broken - switch name is not passed as an argument 2018-06-21 13:40:49 +00:00
Matt Churchyard
9a908b95fc Add bhyveload_loader and also vtcon list to "vm info" 2018-06-21 12:22:35 +00:00
Matt Churchyard
ea58aaf6d7 Rewrite virtio-console support
Guest "virt_consoleX" option now supports both numbered & named ports.
Up to 16 can be added to a guest.
2018-06-21 11:12:20 +00:00
Matt Churchyard
1dc6135cc9 Fix #147. Exit with message if grub-bhyve requested but not found 2018-06-20 12:30:41 +00:00
Matt Churchyard
cb600bcc22 Add listing to guest info for issue #97
Think adding this to `vm list` adds too much complexity when the zfs commands
do a much better job. Having this in info output as commented is a nice idea though.
2018-06-20 12:14:40 +00:00
Matt Churchyard
b4c24b33e8 Finally address #110
Use the -f option to force commands such as reset/destroy/poweroff.
Unfortunately this same option is used for foreground mode when running a vm,
but -f ties up with the force option for many other commands.
2018-06-20 11:59:09 +00:00
Matt Churchyard
9f76d63817 Address #211 - default.conf should be availble by default
This allows basic guests to be created without getting an error about a missing
template, or requiring the user to manually create/copy it.
2018-06-20 09:39:35 +00:00
Matt Churchyard
6a75c20ca3 Try to address #221 - clone not changing mac address
Create new "generalise" function specifically to remove any fixed configuration
from a guest. This can then be used in any situation where a guest may be copied.
Tested with clone and both uuid & mac are removed. (Note this just removes settings, based
on the fact that these will be generated on next boot)
2018-06-20 09:18:00 +00:00
Matt Churchyard
2c77228708 Add ability to configure standard switch address 2018-06-18 08:22:17 +00:00
Matt Churchyard
805c074237 Minor fixes 2018-04-19 13:36:36 +00:00
Matt Churchyard
a85ef7c4e9 Make sure owner the owner can read disk image files 2018-02-09 09:52:23 +00:00
Matt Churchyard
8746a656c2 Add -S wired memory option to bhyveload if specified in custom options 2018-02-09 09:48:57 +00:00
Matt Churchyard
ab2229fa20 Add bhyve_options configuration option 2017-06-08 11:13:13 +01:00
Matt Churchyard
f4e4585424 Allow user to specific the -w bhyve option (ignore_bad_msr=yes) 2017-06-07 13:12:42 +01:00
Matt Churchyard
6de318504c Ignore error if there are no console .sock files 2017-04-18 13:59:14 +01:00
Matt Churchyard
7131ffb2f1 Forgot build number again... 2017-03-10 10:56:00 +00:00
Matt Churchyard
40f1b9ebe1 Add ability to configure private mode on existing switches
Note that we don't bother reconfiguring running guests, so changing
the setting only affects guests started from cold-boot afterwards.
2016-11-18 09:48:19 +00:00
Matt Churchyard
d1515cd04f Add support for switch address/mtu/private
New options to 'vm switch create' to allow an ip and/or mtu to
be assigned to standard/vxlan switches. Also standard,vxlan &
custom switches can be set as private so no guest interfaces can
communicate.
2016-11-16 20:38:23 +00:00
Matt Churchyard
ac2cc9265c Add support for virtio_console devices 2016-11-11 15:50:13 +00:00
Matt Churchyard
d988e52d2d Rework switch support while getting some SDN on
We already had 3 types of switch (although you could only test vale manually),
with fairly ugly code to handle the differences. Now that a fourth has been added,
split each type into their own 'module'. This adds test vxlan support which can
create arbitrary virtual L2 networks by tunneling traffic over UDP L3.
2016-11-10 11:16:43 +00:00
Matt Churchyard
af3f1a5216 Skip cpu checks if no dmesg.boot log
I don't want to fully rely on these checks as it could stop us from running
on a system that actually supports bhyve. If the system doesn't support bhyve,
and doesn't have dmesg.boot, then bhyve will just fail to run.
2016-10-19 09:07:44 +01:00
Matt Churchyard
11329ec421 Allow vm names up to 32 characters 2016-10-18 16:00:06 +01:00
Matt Churchyard
b77b7f80b6 Use column to reduce width of 'vm list' output 2016-08-30 14:36:25 +01:00
Matt Churchyard
7afd26a8b2 Reset member type for each interface 2016-08-24 09:54:46 +01:00