Skip to content

Commit

Permalink
Make Debian guest detection more reliable
Browse files Browse the repository at this point in the history
/etc/issue is far from being a reliable source for OS detection as it
can be changed by a user without affecting any OS functionality. As
newer Debian systems run systemd by default, check for /etc/os-release
and fallback to lsb_release for older Debian versions. Check hashicorp#7625 for
a similar issue. Even lsb_release is not manatory, therefore keep the
current code of parsing /etc/issue to avoid regressions.
  • Loading branch information
ganto authored and chrisroberts committed Oct 11, 2016
1 parent 29b0333 commit 6050b13
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugins/guests/debian/guest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ module VagrantPlugins
module GuestDebian
class Guest < Vagrant.plugin("2", :guest)
def detect?(machine)
machine.communicate.test("cat /etc/issue | grep 'Debian'")
machine.communicate.test <<-EOH.gsub(/^ {10}/, "")
if test -r /etc/os-release; then
source /etc/os-release && test xdebian = x$ID
elif test -x /usr/bin/lsb_release; then
/usr/bin/lsb_release -i 2>/dev/null | grep -q Debian
elif test -r /etc/issue; then
cat /etc/issue | grep 'Debian'
else
exit 1
fi
EOH
end
end
end
Expand Down

0 comments on commit 6050b13

Please sign in to comment.