git_chroot

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 1135106521ae3f47492a772f037d3d5f0653003f
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Wed, 17 Nov 2021 21:23:28 +0000

import gitdaemon chroot script 68

Diffstat:
Agitdaemon_chroot.sh | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+), 0 deletions(-)

diff --git a/gitdaemon_chroot.sh b/gitdaemon_chroot.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +set -eu + +# +# Script must be run as root. +# Tested on OpenBSD. +# + +# Change this to your chroot location. +CHROOT=/var/git +echo "Installing into '${CHROOT}' ..." + +mkdir -p ${CHROOT} +chgrp daemon ${CHROOT} + +# git-daemon requires /dev/null, create it +mkdir -p ${CHROOT}/dev +mknod -m 666 ${CHROOT}/dev/null c 3 2 + +# Check if nodev is a mount option +if grep var /etc/fstab | grep nodev; then + echo "error: /var mount has 'nodev' option; this must be removed" + echo " Do not forget to remount the filesystem afterwards." + exit 1 +fi + +# +# Copy dynamic library dependencies into CHROOT +# Knock off the first 2 lines of `ldd' output, field 7 contains the library +# path. +# +ldd /usr/local/libexec/git/git-daemon | tail -n +3 | awk '{ print $7 }' | +while read -r lib_path +do + mkdir -p ${CHROOT}/$(dirname $lib_path) + cp $lib_path ${CHROOT}/$lib_path +done + +# Copy git binary for `upload-pack'. +git_bin=/usr/local/bin/git +mkdir -p ${CHROOT}/$(dirname $git_bin) +cp $git_bin ${CHROOT}/$git_bin + +cat - << EOF > chroot_gitdaemon_68.diff +--- /etc/rc.d/gitdaemon.orig Sat Jan 18 17:47:47 2020 ++++ /etc/rc.d/gitdaemon Sat Jan 18 17:33:42 2020 +@@ -7,6 +7,10 @@ + + . /etc/rc.d/rc.subr + ++rc_start() { ++ chroot -u \${daemon_user} ${CHROOT} \${daemon} \${daemon_flags} ++} ++ + pexp="/usr/local/libexec/git/git-daemon --detach${daemon_flags:+ ${daemon_flags}}" + rc_reload=NO +EOF + +patch -d /etc/rc.d < chroot_gitdaemon_68.diff