Skip to content

Commit 1e233fb

Browse files
committed
even more data collection
1 parent 1d614f9 commit 1e233fb

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lib/arduino_ci/host.rb

+17-4
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,34 @@ def self.os
4545
def self.symlink(old_path, new_path)
4646
return FileUtils.ln_s(old_path.to_s, new_path.to_s) unless RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/
4747

48+
op = old_path
49+
orp = old_path.realpath
50+
STDERR.puts "Old path #{op} #{op.exist?}"
51+
STDERR.puts "Old realpath #{orp} #{orp?}"
52+
4853
# windows mklink syntax is reverse of unix ln -s
4954
# windows mklink is built into cmd.exe
5055
# vulnerable to command injection, but okay because this is a hack to make a cli tool work.
51-
stdout, stderr, exitstatus = Open3.capture3('cmd.exe', "/c mklink /D #{new_path} #{old_path}")
56+
stdout, stderr, exitstatus = Open3.capture3('cmd.exe', "/C mklink /D #{new_path} #{old_path.realpath}")
57+
STDERR.puts stdout
58+
STDERR.puts stderr
59+
return exitstatus if new_path.exist?
60+
61+
STDERR.puts "initial try failed, trying short runas"
62+
63+
stdout, stderr, exitstatus = Open3.capture3('runas.exe', "/user:administrator", "mklink /D #{new_path} #{orp}")
64+
5265
STDERR.puts stdout
5366
STDERR.puts stderr
5467
return exitstatus if new_path.exist?
5568

56-
STDERR.puts "initial try failed, trying elevated"
69+
STDERR.puts "initial try failed, trying long runas"
5770

58-
stdout, stderr, exitstatus = Open3.capture3('runas.exe', "/user:administrator", "cmd /C mklink /D #{new_path} #{old_path}")
71+
stdout, stderr, exitstatus = Open3.capture3('runas.exe', "/user:administrator", "cmd /C mklink /D #{new_path} #{orp}")
5972

6073
STDERR.puts stdout
6174
STDERR.puts stderr
62-
return exitstatus
75+
exitstatus
6376
end
6477
end
6578
end

0 commit comments

Comments
 (0)