app/models/terminal_executor.rb
# write script to a file so it cannot be seen via `ps`
write script to a file so it cannot be seen via `ps`
write script to a file so it cannot be seen via ` ps `
def script_as_executable(script)
    suffix = +""
    suffix << "-#{@project.permalink}"
    suffix << "-#{@deploy.id}" if @deploy
    Tempfile.create("samson-terminal-executor#{suffix}-") do |f|
      File.chmod(0o700, f.path) 
      f.write script
      f.close
      command = f.path
      if RbConfig::CONFIG['host_os'].include?('darwin')
        executor = File.expand_path("../../bin/script-executor", __dir__)
        command = "export FILE=#{f.path.shellescape} && #{executor.shellescape}"
      end
      yield command
    end
  end
def script_as_executable ( script ) suffix = + "" suffix << "-#{@project.permalink}" suffix << "-#{@deploy.id}" if @deploy Tempfile . create ( "samson-terminal-executor#{suffix}-" ) do | f | File . chmod ( 0o700 , f . path ) f . write script f . close command = f . path if RbConfig :: CONFIG [ 'host_os' ] . include? ( 'darwin' ) executor = File . expand_path ( "../../bin/script-executor" , __dir__ ) command = "export FILE=#{f.path.shellescape} && #{executor.shellescape}" end yield command end end
write script to a file so it cannot be seen via `ps`
write script to a file so it cannot be seen via ` ps `
# making sure nobody can read it before we add content # osx has a 4s startup delay for each new executable, so we keep the executable stable
script