From: Mike Hommey <mh@glandium.org>
To: git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH] Allow git-shell to be used as a ssh forced-command
Date: Thu, 16 Apr 2009 23:10:56 +0200 [thread overview]
Message-ID: <1239916256-10878-1-git-send-email-mh@glandium.org> (raw)
When using a forced-command, OpenSSH sets the SSH_ORIGINAL_COMMAND
variable to what would otherwise be passed to $SHELL -c. When this
variable is set, we use it instead of the contents of argv.
Signed-off-by: Mike Hommey <mh@glandium.org>
---
I was unsure whether I needed to give more information about
forced-commands in the commit message itself, anyways, just in case
you don't know what it is:
http://oreilly.com/catalog/sshtdg/chapter/ch08.html#22858
I'm not sure if it's worth adding a check for SSH2_ORIGINAL_COMMAND.
Are people using the commercial SSH2 ?
shell.c | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/shell.c b/shell.c
index e339369..14ff266 100644
--- a/shell.c
+++ b/shell.c
@@ -62,20 +62,25 @@ int main(int argc, char **argv)
die("opening /dev/null failed (%s)", strerror(errno));
close (devnull_fd);
- /*
- * Special hack to pretend to be a CVS server
- */
- if (argc == 2 && !strcmp(argv[1], "cvs server"))
- argv--;
+ /* Use original command if we were run from a ssh forced-command */
+ prog = getenv("SSH_ORIGINAL_COMMAND");
+ if (!prog) {
+ /*
+ * Special hack to pretend to be a CVS server
+ */
+ if (argc == 2 && !strcmp(argv[1], "cvs server"))
+ argv--;
- /*
- * We do not accept anything but "-c" followed by "cmd arg",
- * where "cmd" is a very limited subset of git commands.
- */
- else if (argc != 3 || strcmp(argv[1], "-c"))
- die("What do you think I am? A shell?");
+ /*
+ * We do not accept anything but "-c" followed by "cmd arg",
+ * where "cmd" is a very limited subset of git commands.
+ */
+ else if (argc != 3 || strcmp(argv[1], "-c"))
+ die("What do you think I am? A shell?");
+
+ prog = argv[2];
+ }
- prog = argv[2];
if (!strncmp(prog, "git", 3) && isspace(prog[3]))
/* Accept "git foo" as if the caller said "git-foo". */
prog[3] = '-';
--
1.6.3.rc0.1.g8bd72.dirty
next reply other threads:[~2009-04-16 21:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-16 21:10 Mike Hommey [this message]
2009-04-17 16:24 ` [PATCH] Allow git-shell to be used as a ssh forced-command Dmitry Potapov
2009-04-17 19:49 ` Mike Hommey
2009-04-17 21:00 ` Dmitry Potapov
2009-04-17 22:36 ` Mike Hommey
2009-04-17 22:41 ` Shawn O. Pearce
2009-04-17 23:44 ` Mike Hommey
2009-04-18 7:46 ` Matthieu Moy
2009-04-17 23:40 ` Junio C Hamano
2009-04-17 23:48 ` Tommi Virtanen
2009-04-18 1:24 ` Junio C Hamano
2009-04-18 6:31 ` Mike Hommey
2009-04-21 5:43 ` [PATCH v2] " Mike Hommey
2009-04-21 8:05 ` Dmitry Potapov
2009-04-21 9:46 ` Eygene Ryabinkin
2009-04-21 8:13 ` Junio C Hamano
2009-04-21 9:09 ` Mike Hommey
2009-04-21 11:16 ` Dmitry Potapov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1239916256-10878-1-git-send-email-mh@glandium.org \
--to=mh@glandium.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).