From: William Strecker-Kellogg <willsk@bnl.gov>
To: Git List <git@vger.kernel.org>
Cc: William Strecker-Kellogg <willsk@bnl.gov>, spearce@spearce.org
Subject: [PATCH] Make http-backend REMOTE_USER configurable
Date: Thu, 29 Mar 2012 15:58:59 -0400 [thread overview]
Message-ID: <1333051139-14262-1-git-send-email-willsk@bnl.gov> (raw)
The http-backend looks at $REMOTE_USER and sets $GIT_COMMITTER_NAME to
that for use in the hooks. At our site we have a third party
authentication module for our proxy (Shibboleth) which sets an alternative
environment variable that our backend sees instead of REMOTE USER.
This patch adds the config option http.remoteuser which changes what
environment variable is inspected by the http-backend code (it defaults
to REMOTE_USER).
Reported-by: Jason Smith <smithj4@bnl.gov>
Tested-by: William Strecker-Kellogg <willsk@bnl.gov>
Signed-off-by: William Strecker-Kellogg <willsk@bnl.gov>
---
I do not know if anyone else may find this useful, but FWIW, this works
for us. It may even be a good idea to add the ability to overwrite other
default CGI environment variables, although I can't think of any other
ones at the moment.
Documentation/git-http-backend.txt | 14 ++++++++++----
http-backend.c | 13 +++++++++++--
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-http-backend.txt b/Documentation/git-http-backend.txt
index f4e0741..b320a45 100644
--- a/Documentation/git-http-backend.txt
+++ b/Documentation/git-http-backend.txt
@@ -42,6 +42,10 @@ http.getanyfile::
It is enabled by default, but a repository can disable it
by setting this configuration item to `false`.
+http.remoteuser::
+ This setting, if present, changes what environment variable is inspected
+ to determine the remote user (the default is "REMOTE_USER").
+
http.uploadpack::
This serves 'git fetch-pack' and 'git ls-remote' clients.
It is enabled by default, but a repository can disable it
@@ -175,10 +179,12 @@ The GIT_HTTP_EXPORT_ALL environmental variable may be passed to
'git-http-backend' to bypass the check for the "git-daemon-export-ok"
file in each repository before allowing export of that repository.
-The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' and
-GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
-ensuring that any reflogs created by 'git-receive-pack' contain some
-identifying information of the remote user who performed the push.
+The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' (or
+if http.remoteuser is present it sets it to $\{http.remoteuser\})
+and GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
+ensuring that any reflogs created by 'git-receive-pack' contain
+some identifying information of the remote user who performed the
+push.
All CGI environment variables are available to each of the hooks
invoked by the 'git-receive-pack'.
diff --git a/http-backend.c b/http-backend.c
index 869d515..69756f0 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -11,6 +11,7 @@
static const char content_type[] = "Content-Type";
static const char content_length[] = "Content-Length";
static const char last_modified[] = "Last-Modified";
+static char *remoteuser = "REMOTE_USER";
static int getanyfile = 1;
static struct string_list *query_params;
@@ -225,6 +226,14 @@ static int http_config(const char *var, const char *value, void *cb)
return 0;
}
+ if(!strcmp(var, "http.remoteuser")) {
+ char *tmp;
+ if(git_config_string(&tmp, var, value) == 0) {
+ remoteuser = tmp;
+ }
+ return 0;
+ }
+
if (!prefixcmp(var, "http.")) {
int i;
@@ -261,7 +270,7 @@ static struct rpc_service *select_service(const char *name)
forbidden("Unsupported service: '%s'", name);
if (svc->enabled < 0) {
- const char *user = getenv("REMOTE_USER");
+ const char *user = getenv(remoteuser);
svc->enabled = (user && *user) ? 1 : 0;
}
if (!svc->enabled)
@@ -315,7 +324,7 @@ done:
static void run_service(const char **argv)
{
const char *encoding = getenv("HTTP_CONTENT_ENCODING");
- const char *user = getenv("REMOTE_USER");
+ const char *user = getenv(remoteuser);
const char *host = getenv("REMOTE_ADDR");
char *env[3];
struct strbuf buf = STRBUF_INIT;
--
1.7.7.6
next reply other threads:[~2012-03-29 20:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 19:58 William Strecker-Kellogg [this message]
2012-03-29 22:02 ` [PATCH] Make http-backend REMOTE_USER configurable Junio C Hamano
2012-03-29 22:22 ` Jeff King
2012-03-29 22:26 ` Jeff King
2012-03-30 1:52 ` Junio C Hamano
2012-03-30 3:24 ` William Strecker-Kellogg
2012-03-30 7:01 ` Jeff King
2012-03-30 16:13 ` Junio C Hamano
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=1333051139-14262-1-git-send-email-willsk@bnl.gov \
--to=willsk@bnl.gov \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/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).