1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-08-28 23:26:18 +02:00

respect windows

This commit is contained in:
Christian Mehlmauer 2017-07-17 09:58:20 +02:00
parent d24e2943ca
commit 7d6992c0e8
No known key found for this signature in database
GPG Key ID: DCF54A05D6E62591
3 changed files with 21 additions and 2 deletions

View File

@ -21,3 +21,4 @@ end
# Executable generation and encoding
require 'msf/util/exe'
require 'msf/util/helper'

19
lib/msf/util/helper.rb Normal file
View File

@ -0,0 +1,19 @@
# -*- coding: binary -*-
module Msf
module Util
class Helper
# Cross-platform way of finding an executable in the $PATH.
#
# which('ruby') #=> /usr/bin/ruby
def self.which(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each { |ext|
exe = File.join(path, "#{cmd}#{ext}")
return exe if File.executable?(exe) && !File.directory?(exe)
}
end
return nil
end
end

View File

@ -25,8 +25,7 @@ Gem::Specification.new do |spec|
spec.license = 'BSD-3-clause'
# only do a git ls-files if the .git folder exists and we have a git binary in PATH
if File.directory?(File.join(File.dirname(__FILE__), ".git")) &&
ENV['PATH'].split(':').collect {|d| Dir.entries d if Dir.exists? d}.flatten.include?("git")
if File.directory?(File.join(File.dirname(__FILE__), ".git")) && Msf::Util::Helper.which("git")
spec.files = `git ls-files`.split($/).reject { |file|
file =~ /^documentation|^external/
}