I’m trying to set up a git repository on my remote linux server such that I can connect via ssh and share the single login with a few friends in a fairly secure way. I’m running into issues because my sshd calls duo security via FORCE_COMMAND set in the ssh config (points to '/usr/sbin/login_duo'). I decided to work around this; so I checked out the git code and picked up enough C to make the changes (in shell.c) so that it ignores the /usr/sbin/login_duo call and calls run_shell() that creates the normal git-shell prompt. (I’m now pretty sure this is not the right solution because I wouldn’t expect a git clone call to end up in a shell, but this question still seems valid)
Anyway, I managed to get the git> prompt to appear but it doesn’t seem to process the input I pass in (Once I’ve typed enter/exit and then hit return). I would expect it to print “git got x” but it just sits there. Any ideas?
fprintf(stderr, "git> ");
if (strbuf_getline(&line, stdin, '\n') == EOF) {
fprintf(stderr, "\n");
strbuf_release(&line);
break;
}
fprintf(stderr, "git got %s\n", line );
Example:
egwor@mars:~/projects/test$ git clone ssh://git@localhost/home/git/repo1
Cloning into repo1...
git@localhost's password:
login_duo ignored <-- where I split off and call the shell function
git> exit
<--hangs-->`
lineis of type:fprintf(stderr, "git got %s\n", line )should generate a compiler warning along the lines of:warning: format ‘%s’ expects argument of type ‘char *’...Ignoring this warning and running the code is likely to cause a seg-fault or other bad-crumble.
Try this instead: