MisterTea / EternalTerminal

Re-Connectable secure remote shell
https://mistertea.github.io/EternalTerminal/
Apache License 2.0
3.02k stars 173 forks source link

git clone crashes #184

Closed vegesm closed 5 years ago

vegesm commented 5 years ago

Git clone fails when running from et:

$ git clone https://github.com/CMU-Perceptual-Computing-Lab/panoptic-toolbox
Cloning into 'panoptic-toolbox'...
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 241 (delta 6), reused 22 (delta 6), pack-reused 219
Receiving objects: 100% (241/241), 6.99 MiB | 1.55 MiB/s, done.
Resolving deltas: 100% (83/83), done.
error: waitpid for index-pack failed: No child processes
fatal: index-pack failed
error: waitpid for fetch-pack failed: No child processes

The same witpid error is raised when trying to commit. Using normal ssh, everything work fine. My et version is 5.1.9

MisterTea commented 5 years ago

Hmm, I git clone all the time and haven't seen this. What OS are you running on the server?

vegesm commented 5 years ago

It's ubuntu 16.04, kernel: 4.4.0-141-generic

MisterTea commented 5 years ago

Is this a home machine or are you using a public cloud? It sounds like some SELinux restrictions

vegesm commented 5 years ago

It is a workplace computer, SElinux is turned off but I run etserver in user space.

I did a bit of digging around and it seems the main culprit is that ET somehow disables SIGCHLD. When running trap in et:

$ trap
trap -- '' SIGCHLD
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU

In ssh:

$ trap
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU

According to strace git uses clone and wait4 to fork a subprocess and wait for it to finish. If the SIGCHLD handler is set to ignore then wait4 reports ECHILD (link). If I run the following code, everything works fine:

#include <unistd.h> 
#include <signal.h>

int main() 
{ 
    signal(SIGCHLD, SIG_DFL);  // Reset SIGCHLD handler to default
    execl("/usr/bin/git", "git", "clone", "path_to_repo", (char*)NULL);
    return 0;
}

Interestingly, in ET trap does not work on SIGCHLD, whatever I try, the SIGCHLD action is always ignore. Using ssh, I can change the signal action without any problem.

MisterTea commented 5 years ago

etserver should run in root mode.

vegesm commented 5 years ago

Tried it with sudo, no change. I'm not sure etserver has anything to do with this as the remote shell is started by etterminal which in turn is started by the local client through ssh.

Anyway, I created a workaround by calling the above C program with bash in .profile.

Phelerox commented 5 years ago

I also have this issue. At first I didn't imagine et could be the culprit but I tried over SSH instead which worked, and the issue resurfaced when I switched back to et.

Maybe you can find some clues on how to fix it by looking at how tmux fixed a similar issue in the past: https://github.com/tmux/tmux/issues/1007

MisterTea commented 5 years ago

This should be fixed in et 6. Please re-open if it isn't.