Use dedicated pseudoterminal
This commit is contained in:
@@ -1,2 +1,6 @@
|
||||
#/usr/bin/env bash
|
||||
sudo /usr/lib/github-fast-env/github-fast-env.rb "$@"
|
||||
if [[ "$USER" == "git" ]] ; then
|
||||
/usr/lib/github-fast-env/github-fast-env.rb "$@"
|
||||
else
|
||||
sudo -u git /usr/lib/github-fast-env/github-fast-env.rb "$@"
|
||||
fi
|
||||
|
@@ -133,13 +133,13 @@ def clean_up_named_pipes(control_socket, connection_id)
|
||||
end
|
||||
|
||||
def set_up_pseudoterminal(control_socket, pseudoterminal_path)
|
||||
pseudoterminal_io = File.open(pseudoterminal_path, File::RDWR | File::NOCTTY)
|
||||
$pseudoterminal_io = File.open(pseudoterminal_path, File::RDWR | File::NOCTTY)
|
||||
|
||||
$original_stderr.puts " connecting to pseudoterminal #{pseudoterminal_path}"
|
||||
|
||||
$stdin.reopen(pseudoterminal_io)
|
||||
$stdout.reopen(pseudoterminal_io)
|
||||
$stderr.reopen(pseudoterminal_io)
|
||||
$stdin.reopen($pseudoterminal_io)
|
||||
$stdout.reopen($pseudoterminal_io)
|
||||
$stderr.reopen($pseudoterminal_io)
|
||||
|
||||
$original_stderr.puts " connected to pseudoterminal #{pseudoterminal_path}"
|
||||
|
||||
@@ -148,7 +148,7 @@ end
|
||||
|
||||
$original_stderr.puts "preloading common modules"
|
||||
|
||||
load "/usr/lib/github-fast-env/preload.rb"
|
||||
#load "/usr/lib/github-fast-env/preload.rb"
|
||||
|
||||
$original_stderr.puts "ready to serve requests"
|
||||
|
||||
@@ -207,18 +207,18 @@ while true
|
||||
set_up_pseudoterminal(control_socket, pseudoterminal_path)
|
||||
end
|
||||
|
||||
Process.gid = Process.egid = "git"
|
||||
Process.uid = Process.euid = "git"
|
||||
|
||||
$original_stderr.puts " executing script #{script_path} (#{process_id})"
|
||||
|
||||
begin
|
||||
begin
|
||||
load script_path, true
|
||||
$original_stderr.puts " finished executing script"
|
||||
rescue SystemExit => error
|
||||
$original_stderr.puts " exit code: #{error.status}"
|
||||
exit_code = error.status
|
||||
rescue StandardError => error
|
||||
$original_stderr.puts " error executing script"
|
||||
|
||||
$stdin = $original_stdin
|
||||
$stdout = $original_stdout
|
||||
$stderr = $original_stderr
|
||||
@@ -247,9 +247,11 @@ while true
|
||||
end
|
||||
|
||||
begin
|
||||
# TODO: submit correct exit code upon Ctrl + C
|
||||
control_socket.puts "done #{exit_code}"
|
||||
rescue
|
||||
end
|
||||
|
||||
control_socket.close
|
||||
|
||||
if mode == "named-pipes"
|
||||
@@ -257,6 +259,8 @@ while true
|
||||
end
|
||||
|
||||
$original_stderr.puts " finished handling request (#{process_id})"
|
||||
|
||||
$pseudoterminal_io.close
|
||||
end
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user