From 95493d6c599c22fc40f3c7d03573f657b2eda7f2 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 17 Dec 2018 12:46:30 -0800 Subject: [PATCH] Validate hostnamectl command is in working state When checking if the hostnamectl command should be used for configuring the guest hostname, ensure the command returns a valid result. The hostnamectl command relies on dbus and if dbus is not available the command will simply fail. --- lib/vagrant/util/guest_inspection.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/guest_inspection.rb b/lib/vagrant/util/guest_inspection.rb index cd0a96d3e..468bb658d 100644 --- a/lib/vagrant/util/guest_inspection.rb +++ b/lib/vagrant/util/guest_inspection.rb @@ -36,8 +36,12 @@ module Vagrant # # @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator # @return [Boolean] + # NOTE: This test includes actually calling `hostnamectl` to verify + # that it is in working order. This prevents attempts to use the + # hostnamectl command when it is available, but dbus is not which + # renders the command useless def hostnamectl?(comm) - comm.test("command -v hostnamectl") + comm.test("command -v hostnamectl && hostnamectl") end ## netplan helpers