diff options
author | keithp <keithp@kemper.freedesktop.org> | 2006-02-15 00:21:52 -0800 |
---|---|---|
committer | keithp <keithp@kemper.freedesktop.org> | 2006-02-15 00:21:52 -0800 |
commit | 5f5b4dd763b21f8b3f96307df8a8f3fff25425fb (patch) | |
tree | ef990a5c549abeb1c2da1775b7984dc95a499995 | |
parent | 5b0011a7de90e397b307b45a8042c41a0cde50cf (diff) |
Prototype version
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | ssh-bleach.c | 83 |
3 files changed, 99 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07901e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +ssh-bleach diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d18f4c7 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +project=ssh-bleach +prefix=/usr/local +bin=$(prefix)/bin +man=$(prefix)/share/man +man1=$(man)/man1 +lib=$(prefix)/lib +etc=$(prefix)/etc +libdir=$(lib)/$(project) + +OBJS = ssh-bleach.c + +CFLAGS=-g -DCONFDIR=\"$(libdir)\" + +$(project): $(OBJS) + $(CC) -o $@ $(CFLAGS) $(OBJS) diff --git a/ssh-bleach.c b/ssh-bleach.c index 7ba3d11..e4f6455 100644 --- a/ssh-bleach.c +++ b/ssh-bleach.c @@ -17,3 +17,86 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int cvs_server (char *line) { + if (!strcmp (line, "cvs server")) + return execl ("/usr/bin/cvs", "cvs", "server", NULL); + return 0; +} + +char *get_quoted_arg (char *line) +{ + char *first = strchr (line, '\''); + char *old; + char *last; + char *new, *n; + + if (!first) + return NULL; + last = strrchr (line, '\''); + if (!last || last == first) + return NULL; + first++; + new = malloc (last - first + 1); + if (!new) + return NULL; + n = new; + for (old = first; old < last; old++) { + if (*old == '\\') + continue; + *n++ = *old++; + } + *n++ = '\0'; + return new; +} + +int git_receive_pack (char *line) { + char *arg; + + if (!strncmp (line, "git-receive-pack '", 18) && + (arg = get_quoted_arg (line))) + { + return execl ("/usr/local/bin/git-receive-pack", + "git-receive-pack", + arg, + NULL); + } + return 0; +} + +int git_upload_pack (char *line) { + char *arg; + + if (!strncmp (line, "git-upload-pack '", 17) && + (arg = get_quoted_arg (line))) + { + return execl ("/usr/local/bin/git-upload-pack", + "git-upload-pack", + arg, + NULL); + } + return 0; +} + +int (*commands[]) (char *line) = { + cvs_server, + git_receive_pack, + git_upload_pack, + NULL +}; + +int main (int argc, char **argv) +{ + char *line = getenv ("SSH_ORIGINAL_COMMAND"); + int i; + + if (!line) + return 1; + for (i = 0; commands[i]; i++) + if ((*commands[i]) (line) != 0) + break; + return 1; +} |