From b8197a65b44e0b46c7d66c7b273cb3c64a343407 Mon Sep 17 00:00:00 2001 From: Ralf Brunckhorst Date: Sun, 17 Apr 2022 09:37:56 +0200 Subject: [PATCH] Fix sed command for Solaris "sed -i" is specific to GNU sed and is not a posix standard option. The default sed command in Solaris is not GNU sed though it is possible to install the GNU-sed which includes /usr/bin/gsed --- plugins/guests/solaris/cap/remove_public_key.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/guests/solaris/cap/remove_public_key.rb b/plugins/guests/solaris/cap/remove_public_key.rb index 170d63870..9a5fe7984 100644 --- a/plugins/guests/solaris/cap/remove_public_key.rb +++ b/plugins/guests/solaris/cap/remove_public_key.rb @@ -5,14 +5,14 @@ module VagrantPlugins module Cap class RemovePublicKey def self.remove_public_key(machine, contents) - # TODO: code is identical to linux/cap/remove_public_key + # "sed -i" is specific to GNU sed and is not a posix standard option contents = contents.chomp contents = Vagrant::Util::ShellQuote.escape(contents, "'") machine.communicate.tap do |comm| if comm.test("test -f ~/.ssh/authorized_keys") comm.execute( - "sed -i '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys") + "cp ~/.ssh/authorized_keys ~/.ssh/authorized_keys.temp && sed '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys.temp > ~/.ssh/authorized_keys && rm ~/.ssh/authorized_keys.temp") end end end