From f8bef79ba5f6a3033894a4362b051ae451f05319 Mon Sep 17 00:00:00 2001 From: Matthew Kienow Date: Wed, 29 Aug 2018 14:22:29 -0400 Subject: [PATCH] Add environment variable hash for cmd being run Convert input to keyword argument --- msfdb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/msfdb b/msfdb index 4996902949..820df1b88e 100755 --- a/msfdb +++ b/msfdb @@ -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