aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/blogc-git-receiver.1.ronn23
-rw-r--r--src/blogc-git-receiver/post-receive.c5
-rw-r--r--src/blogc-git-receiver/pre-receive.c5
-rw-r--r--src/blogc-git-receiver/shell.c5
-rwxr-xr-xtests/blogc-git-receiver/check_post_receive.sh.in2
-rwxr-xr-xtests/blogc-git-receiver/check_pre_receive.sh.in2
6 files changed, 31 insertions, 11 deletions
diff --git a/man/blogc-git-receiver.1.ronn b/man/blogc-git-receiver.1.ronn
index 355aa75..7386909 100644
--- a/man/blogc-git-receiver.1.ronn
+++ b/man/blogc-git-receiver.1.ronn
@@ -145,13 +145,24 @@ mirror, you can run its `post-receive` hook manually in the server:
WARNING: If you push manually and your server's repository is empty, you'll clean
your mirror repository.
-## ENVIRONMENT VARIABLES
+## ENVIRONMENT
-`blogc-git-receiver` will export an environment variable called `BLOGC_GIT_RECEIVER`
-when calling `gmake` to build websites. This variable can be used to enable building
-of content that should only be built when running in production environment, for
-example. This variable will not be added when using blogc-make(1), whose builds are
-always considered to be "production" (blogc-make(1) is never called with `-D`).
+The following variable can be set in the SSH Server (usually in `~/.ssh/environment`)
+to change `blogc-git-receiver` behaviour:
+
+ * `BLOGC_GIT_RECEIVER_BASEDIR`:
+ Path to a directory that should be used by `blogc-git-receiver` instead of the
+ user's home directory. Useful for shared hosting environments that only provide
+ one shell user.
+
+The following variable is exported by `blogc-git-receiver` when building websites
+with make(1):
+
+ * `BLOGC_GIT_RECEIVER=1`:
+ This variable can be used to enable building of content that should only be
+ built when running in production environment, for example. This variable will
+ not be exported when using blogc-make(1), whose builds are always considered to
+ be "production" (blogc-make(1) is never called with `-D`).
## BUGS
diff --git a/src/blogc-git-receiver/post-receive.c b/src/blogc-git-receiver/post-receive.c
index 3593bb5..93cae25 100644
--- a/src/blogc-git-receiver/post-receive.c
+++ b/src/blogc-git-receiver/post-receive.c
@@ -76,7 +76,10 @@ bgr_post_receive_hook(int argc, char *argv[])
goto push;
}
- char *home = getenv("HOME");
+ char *home = getenv("BLOGC_GIT_RECEIVER_BASEDIR");
+ if (home == NULL) {
+ home = getenv("HOME");
+ }
if (home == NULL) {
fprintf(stderr, "warning: failed to find user home path, "
"mirroring disabled\n");
diff --git a/src/blogc-git-receiver/pre-receive.c b/src/blogc-git-receiver/pre-receive.c
index b059753..20c6738 100644
--- a/src/blogc-git-receiver/pre-receive.c
+++ b/src/blogc-git-receiver/pre-receive.c
@@ -177,7 +177,10 @@ bgr_pre_receive_hook(int argc, char *argv[])
goto cleanup;
}
- char *home = getenv("HOME");
+ char *home = getenv("BLOGC_GIT_RECEIVER_BASEDIR");
+ if (home == NULL) {
+ home = getenv("HOME");
+ }
if (home == NULL) {
fprintf(stderr, "error: failed to find user home path\n");
rv = 3;
diff --git a/src/blogc-git-receiver/shell.c b/src/blogc-git-receiver/shell.c
index 1ad8f20..eb859e8 100644
--- a/src/blogc-git-receiver/shell.c
+++ b/src/blogc-git-receiver/shell.c
@@ -35,7 +35,10 @@ bgr_shell(int argc, char *argv[])
}
// get home path
- char *home = getenv("HOME");
+ char *home = getenv("BLOGC_GIT_RECEIVER_BASEDIR");
+ if (home == NULL) {
+ home = getenv("HOME");
+ }
if (home == NULL) {
fprintf(stderr, "error: failed to find user home path\n");
rv = 3;
diff --git a/tests/blogc-git-receiver/check_post_receive.sh.in b/tests/blogc-git-receiver/check_post_receive.sh.in
index 9c6ded1..f0dde80 100755
--- a/tests/blogc-git-receiver/check_post_receive.sh.in
+++ b/tests/blogc-git-receiver/check_post_receive.sh.in
@@ -110,7 +110,7 @@ mirror = ${TEMP}/repos/bar6.git
mirror = lol
EOF
git init --bare "${TEMP}/repos/bar6.git" &> /dev/null
-HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./repos/foo.git/hooks/post-receive 2>&1 | tee "${TEMP}/output.txt"
+BLOGC_GIT_RECEIVER_BASEDIR="${TEMP}" ${TESTS_ENVIRONMENT} ./repos/foo.git/hooks/post-receive 2>&1 | tee "${TEMP}/output.txt"
grep "[new branch] *master" "${TEMP}/output.txt" &> /dev/null
rm "${TEMP}/output.txt"
diff --git a/tests/blogc-git-receiver/check_pre_receive.sh.in b/tests/blogc-git-receiver/check_pre_receive.sh.in
index e9181eb..6021cfb 100755
--- a/tests/blogc-git-receiver/check_pre_receive.sh.in
+++ b/tests/blogc-git-receiver/check_pre_receive.sh.in
@@ -199,7 +199,7 @@ EOF
0000000000000000000000000000000000000000 $(git rev-parse HEAD) refs/heads/master
EOF
- SHELL="${SELF}" HOME="${TEMP}" PATH="@abs_top_builddir@:${PATH}" GIT_DIR=. ${TESTS_ENVIRONMENT} ./hooks/pre-receive < "${TEMP}/payload.txt" 2>&1 | tee "${TEMP}/output.txt" || true
+ SHELL="${SELF}" BLOGC_GIT_RECEIVER_BASEDIR="${TEMP}" PATH="@abs_top_builddir@:${PATH}" GIT_DIR=. ${TESTS_ENVIRONMENT} ./hooks/pre-receive < "${TEMP}/payload.txt" 2>&1 | tee "${TEMP}/output.txt" || true
grep "blogc-make: error: settings: " "${TEMP}/output.txt" &> /dev/null
fi