Add virtualization support to git-daemon
PATCH 1/1 Add virtualization support to git-daemon
---
Junio,
Here is a rebase of my patches to support virtual hosts in git-daemon. This rebase accounts for the changes in handling the table of daemon services recently introduced.
I use an inetd invocation like this example:
git stream tcp nowait nobody /usr/bin/git-daemon git-daemon --inetd
--verbose --syslog
--export-all --interpolated-path=/pub/%H/%D
/pub/software /software
/pub/www.example.com/software
/pub/www.example.org/software
/pubStill room for improvements, of course.
Thanks,
jdl
Makefile | 4 ++ daemon.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++------ interpolate.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++ interpolate.h | 13 +++++++ 4 files changed, 189 insertions(+), 11 deletions(-)
Makefile +3 -1
@@ -244,7 +244,9 @@ DIFF_OBJS = \ LIB_OBJS = \ blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \ - date.o diff-delta.o entry.o exec_cmd.o ident.o lockfile.o \ + date.o diff-delta.o entry.o exec_cmd.o ident.o \ + interpolate.o \ + lockfile.o \ object.o pack-check.o patch-delta.o path.o pkt-line.o \ quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \ server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
daemon.c +90 -10
184 lines not on this page · raw message
interpolate.c new file +83 -0
83 lines not on this page · raw message
interpolate.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* Copyright 2006 Jon Loeliger +*/ + +struct interp { +char *name; +char *value; +}; + +extern int interpolate (char *result,int reslen, +char *orig, +struct interp *interps,int ninterps); +
I have a few stylistic comments but the contents look quite sane and fine.
Quoted 9 lines
I use an inetd invocation like this example:
git stream tcp nowait nobody /usr/bin/git-daemon git-daemon --inetd --verbose --syslog --export-all --interpolated-path=/pub/%H/%D /pub/software /software /pub/www.example.com/software /pub/www.example.org/software /pub
This would be nice to have as an example in the documentation.
Quoted 9 lines
daemon.c +5
-0@@ -45,6 +51,23 @@ static const char *user_path;static unsigned int timeout;static unsigned int init_timeout; +/* +* Static table for now. Ugh. +* Feel free to make dynamic as needed. +*/ +#define INTERP_SLOT_HOST (0)
daemon.c static const char *user_path; · line 68
Quoted 10 lines
daemon.c +10
-0+#define INTERP_SLOT_DIR (1) +#define INTERP_SLOT_PERCENT (2) + +struct interp interp_table[] = { + {"%H" ,0 }, + {"%D" ,0 }, + {"%%" ,"%" }, +}; + +#define N_INTERPS (sizeof(interp_table) / sizeof(struct interp))
Shouldn't this variable static to the file?
We seem to use ARRAY_SIZE() macro, which is not particularly my favorite but other places already use it so probably we would want to keep consistency.
daemon.c static char *path_ok(char *dir) · line 229
Quoted 9 lines
daemon.c +9
-0+loginfo ("Before interpolation '%s'" , dir); +loginfo ("Interp slot 0 (%s,%s)" , + interp_table[0 ].name, interp_table[0 ].value); +loginfo ("Interp slot 1 (%s,%s)" , + interp_table[1 ].name, interp_table[1 ].value); +interpolate (interp_path,PATH_MAX , interpolated_path, + interp_table,N_INTERPS ); +loginfo ("After interpolation '%s'" , interp_path); + dir = interp_path;
Do we really want to see each step of interpolation in the log? Sounds more like logdebug than loginfo to me.
daemon.c static char *path_ok(char *dir) · line 241
Quoted 5 lines
daemon.c +5
-0+snprintf (rpath,PATH_MAX ,"%s%s" , base_path, dir); +loginfo ("dir was %s" , dir); +loginfo ("base_path is %s" , base_path); +loginfo ("rpath now %s" , rpath); + dir = rpath;
Likewise.
daemon.c static void make_service_overridable(con · line 401
Quoted 5 lines
daemon.c +1
-0@@ -351,6 +398,29 @@ static void make_service_overridable(condie ("No such service %s" , name); } +void parse_extra_args (char *extra_args,int buflen)
static?
daemon.c #endif · line 467
Quoted 8 lines
daemon.c +4
-0@@ -391,13 +461,19 @@ #endifif (len && line[len-1 ] =='\n' ) line[--len] =0 ; +if (len != pktlen) { +parse_extra_args (line + len +1 , pktlen - len -1 ); + } +
No { } around single statement.
interpolate.c line 31
Quoted 5 lines
interpolate.c new file +5
-0+int +interpolate (char *result,int reslen, +char *orig, +struct interp *interps,int ninterps) +{
"int interpolate(..."; the return type and function name on the same line (again, not my preference but just doing as Romans do).
interpolate.c line 40
Quoted 1 line
interpolate.c new file +1
-0+bzero (result, reslen);
memset(result, 0, reslen);
interpolate.h
Quoted 6 lines
interpolate.h new file +0
-0@@ -0,0 +1,13 @@
#ifndef INTERPOLATE_H
#define INTERPOLATE_H
...
#endifQuoted 14 lines
interpolate.h new file +13
-0+/* +* Copyright 2006 Jon Loeliger +*/ + +struct interp { +char *name; +char *value; +}; + +extern int interpolate (char *result,int reslen, +char *orig, +struct interp *interps,int ninterps); +
So, like, the other day Junio C Hamano mumbled:
Quoted 2 lines
I have a few stylistic comments but the contents look quite sane and fine.
Let me clean it up some and respin.
Quoted 11 lines
Quoted 9 lines
I use an inetd invocation like this example:
git stream tcp nowait nobody /usr/bin/git-daemon git-daemon --inetd --verbose --syslog --export-all --interpolated-path=/pub/%H/%D /pub/software /software /pub/www.example.com/software /pub/www.example.org/software /pubThis would be nice to have as an example in the documentation.
Will do.
jdl