TL;DR; The current issue is this error:
error: cannot run upload-pack: No such file or directory
Steps:
1) OpenBSD 6.5 fresh install
2) pkg_add git
3) make /var/www/dev/null
# mkdir dev
# mknod dev/null c 2 2
# chmod 666 dev/null
4) put `git-http-backend` into jail
# for f in `ldd /usr/local/libexec/git/git-http-backend | grep '/usr/' |
grep -v ':' | awk '{print $7}'`; do
d=`dirname $f | sed 's#^/##'`
mkdir -p $d
cp $f $d
done
5) put `git-upload-pack` into jail
# for f in `ldd /usr/local/libexec/git/git-upload-pack | grep '/usr/' |
grep -v ':' | awk '{print $7}'`; do
d=`dirname $f | sed 's#^/##'`
mkdir -p $d
cp $f $d
done
6) set /etc/httpd.conf
server "default" {
listen on 0.0.0.0 port 80
# these two rules are trying to match
https://git-scm.com/docs/git-http-backend
<https://git-scm.com/docs/git-http-backend>,
# but I suspect that I botched them...
location match
"^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx))$" {
request rewrite "/usr/local/libexec/git/git-http-backend/%1"
}
location match
"^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$" {
request rewrite "/usr/local/libexec/git/git-http-backend/%1"
}
location "/docs/*" {
fastcgi {
socket "/run/slowcgi.sock"
param DOCUMENT_ROOT "/"
param GIT_HTTP_EXPORT_ALL ""
param GIT_PROJECT_ROOT "/git-repos"
param SCRIPT_FILENAME
"/usr/local/libexec/git/git-http-backend"
}
}
}
7) create "docs" repo:
# mkdir git-repos
# git init --bare git-repos/docs
# cd git-repos/docs/; git update-server-info; cd -
8) In one window:
# httpd -d -vv
9) In another window:
# slowcgi -d
10) In a 3rd window:
# git clone http://127.0.0.1/docs <http://127.0.0.1/docs>
Cloning into 'docs'...
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
11) Observe output in the `httpd` window:
error: cannot run upload-pack: No such file or directory
default 127.0.0.1 - - [17/Jan/2020:11:36:35 -0500] "GET
/docs/info/refs?service=git-upload-pack HTTP/1.1" 200 0
server default, client 1 (1 active), 127.0.0.1:47830 -> 127.0.0.1, closed
Notables here:
# ls -l git-repos/docs/info/refs
-rw-r--r-- 1 root daemon 0 Jan 17 11:50 git-repos/docs/info/refs
# file git-repos/docs/info/refs
git-repos/docs/info/refs: empty
(but, from experience, I know that this is a text file, not something
that might take an HTTP query parameter)
12) Observe output in the `slowcgi` window:
slowcgi: inflight incremented, now 1
slowcgi: version: 1
slowcgi: type: 1
slowcgi: requestId: 1
slowcgi: contentLength: 8
slowcgi: paddingLength: 0
slowcgi: reserved: 0
slowcgi: role 1
slowcgi: flags 0
slowcgi: version: 1
slowcgi: type: 4
slowcgi: requestId: 1
slowcgi: contentLength: 729
slowcgi: paddingLength: 0
slowcgi: reserved: 0
slowcgi: env[0], PATH_INFO=/docs/info/refs
slowcgi: env[1], SCRIPT_NAME=
slowcgi: env[2], SCRIPT_FILENAME=/
slowcgi: env[3], QUERY_STRING=service=git-upload-pack
slowcgi: env[4], DOCUMENT_ROOT=/htdocs
slowcgi: env[5], DOCUMENT_URI=/docs/info/refs
slowcgi: env[6], GATEWAY_INTERFACE=CGI/1.1
slowcgi: env[7], HTTP_ACCEPT=*/*
slowcgi: env[8], HTTP_ACCEPT_ENCODING=deflate, gzip
slowcgi: env[9], HTTP_HOST=127.0.0.1
slowcgi: env[10], HTTP_PRAGMA=no-cache
slowcgi: env[11], HTTP_USER_AGENT=git/2.21.0
slowcgi: env[12], GIT_PROJECT_ROOT=/git-repos
slowcgi: env[13], GIT_HTTP_EXPORT_ALL=
slowcgi: env[14], SCRIPT_FILENAME=/usr/local/libexec/git/git-http-backend
slowcgi: env[15], GIT_PROJECT_ROOT=/git-repos
slowcgi: env[16], GIT_HTTP_EXPORT_ALL=
slowcgi: env[17], SCRIPT_FILENAME=/usr/local/libexec/git/git-http-backend
slowcgi: env[18], REMOTE_ADDR=127.0.0.1
slowcgi: env[19], REMOTE_PORT=47830
slowcgi: env[20], REQUEST_METHOD=GET
slowcgi: env[21], REQUEST_URI=/docs/info/refs?service=git-upload-pack
slowcgi: env[22], SERVER_ADDR=127.0.0.1
slowcgi: env[23], SERVER_PORT=80
slowcgi: env[24], SERVER_NAME=default
slowcgi: env[25], SERVER_PROTOCOL=HTTP/1.1
slowcgi: env[26], SERVER_SOFTWARE=OpenBSD httpd
slowcgi: version: 1
slowcgi: type: 4
slowcgi: requestId: 1
slowcgi: contentLength: 0
slowcgi: paddingLength: 0
slowcgi: reserved: 0
slowcgi: fork: /usr/local/libexec/git/git-http-backend
slowcgi: version: 1
slowcgi: type: 5
slowcgi: requestId: 1
slowcgi: contentLength: 0
slowcgi: paddingLength: 0
slowcgi: reserved: 0
slowcgi: resp version: 1
slowcgi: resp type: 6
slowcgi: resp requestId: 1
slowcgi: resp contentLength: 172
slowcgi: resp paddingLength: 4
slowcgi: resp reserved: 0
slowcgi: wait: /usr/local/libexec/git/git-http-backend
slowcgi: resp version: 1
slowcgi: resp type: 6
slowcgi: resp requestId: 1
slowcgi: resp contentLength: 34
slowcgi: resp paddingLength: 6
slowcgi: resp reserved: 0
slowcgi: resp version: 1
slowcgi: resp type: 7
slowcgi: resp requestId: 1
slowcgi: resp contentLength: 57
slowcgi: resp paddingLength: 7
slowcgi: resp reserved: 0
slowcgi: resp version: 1
slowcgi: resp type: 6
slowcgi: resp requestId: 1
slowcgi: resp contentLength: 0
slowcgi: resp paddingLength: 0
slowcgi: resp reserved: 0
slowcgi: resp version: 1
slowcgi: resp type: 7
slowcgi: resp requestId: 1
slowcgi: resp contentLength: 0
slowcgi: resp paddingLength: 0
slowcgi: resp reserved: 0
slowcgi: resp version: 1
slowcgi: resp type: 3
slowcgi: resp requestId: 1
slowcgi: resp contentLength: 8
slowcgi: resp paddingLength: 0
slowcgi: resp reserved: 0
slowcgi: resp appStatus: 1
slowcgi: resp protocolStatus: 0
Thanks in advance!
Kent