Merge pull request #10198 from mkostrikin/sudo_ps_systemd_detect

Hardened proc disallow systemd detection
This commit is contained in:
Brian Cain 2018-09-10 09:19:00 -07:00 committed by GitHub
commit 95bec5953c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,7 @@ module Vagrant
#
# @return [Boolean]
def systemd?(comm)
comm.test("ps -o comm= 1 | grep systemd")
comm.test("sudo ps -o comm= 1 | grep systemd")
end
# systemd-networkd.service is in use

View File

@ -67,7 +67,7 @@ describe "VagrantPlugins::GuestDebian::Cap::ConfigureNetworks" do
before do
allow(comm).to receive(:test).with("nmcli -t d show eth1").and_return(false)
allow(comm).to receive(:test).with("nmcli -t d show eth2").and_return(false)
allow(comm).to receive(:test).with("ps -o comm= 1 | grep systemd").and_return(false)
allow(comm).to receive(:test).with("sudo ps -o comm= 1 | grep systemd").and_return(false)
allow(comm).to receive(:test).with("sudo systemctl status systemd-networkd.service").and_return(false)
allow(comm).to receive(:test).with("netplan -h").and_return(false)
end
@ -85,7 +85,7 @@ describe "VagrantPlugins::GuestDebian::Cap::ConfigureNetworks" do
context "with systemd" do
before do
expect(comm).to receive(:test).with("ps -o comm= 1 | grep systemd").and_return(true)
expect(comm).to receive(:test).with("sudo ps -o comm= 1 | grep systemd").and_return(true)
allow(comm).to receive(:test).with("netplan -h").and_return(false)
end