Add environment variable hash for cmd being run

Convert input to keyword argument
GSoC/Meterpreter_Web_Console
Matthew Kienow 2018-08-29 14:22:29 -04:00
parent d747613149
commit f8bef79ba5
No known key found for this signature in database
GPG Key ID: 40787F8B1EAC6E41
1 changed files with 5 additions and 5 deletions

10
msfdb
View File

@ -56,13 +56,13 @@ require 'yaml'
}
def run_cmd(cmd, input = nil)
def run_cmd(cmd, input: nil, env: {})
exitstatus = 0
err = out = ""
puts "run_cmd: cmd=#{cmd}, input=#{input}" if @options[:debug]
puts "run_cmd: cmd=#{cmd}, input=#{input}, env=#{env}" if @options[:debug]
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
Open3.popen3(env, cmd) do |stdin, stdout, stderr, wait_thr|
stdin.puts(input) if input
if @options[:debug]
err = stderr.read
@ -216,9 +216,9 @@ def init_db
run_psql("alter role #{@options[:msf_db_user]} with password '#{@msf_pass}'")
run_psql("alter role #{@options[:msftest_db_user]} with password '#{@msftest_pass}'")
run_cmd("createdb -p #{@options[:db_port]} -O #{@options[:msf_db_user]} -h 127.0.0.1 -U #{@options[:msf_db_user]} -E UTF-8 -T template0 #{@options[:msf_db_name]}",
"#{@msf_pass}\n#{@msf_pass}\n")
input: "#{@msf_pass}\n#{@msf_pass}\n")
run_cmd("createdb -p #{@options[:db_port]} -O #{@options[:msftest_db_user]} -h 127.0.0.1 -U #{@options[:msftest_db_user]} -E UTF-8 -T template0 #{@options[:msftest_db_name]}",
"#{@msftest_pass}\n#{@msftest_pass}\n")
input: "#{@msftest_pass}\n#{@msftest_pass}\n")
write_db_client_auth_config
restart_db