From c57bb54748250fb24ecbddc9178a03471a5b3ee7 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 27 Nov 2017 15:54:45 -0800 Subject: [PATCH] Config.pm: add disable_jailsetup knob It's possible to configure and run Girocco with full fetch and push support without needing any special root privileges to set it up. Such an installation will, obviously, only support pushing via https through Girocco and will never run a Girocco sshd chroot jail. It's possible that ssh push and fetch access may still be available via an ssh mechanism outside Girocco's purview, but in such a case Girocco itself should never set up its own chroot sshd jail area. Normally this happens automatically simply by running `make install` as a non-root user. However, fingers that have been trained to type `sudo make install` might do so by accident and possibly even while an `sudo -v` condition is still active. Such an accident could be tedious to undo (although it should not cause any data loss). Provide a new $Girocco::Config::disable_jailsetup option that can be set to a true value to always prevent the sshd chroot jail setup part of `make install` from happening no matter how it's run. This should make those trained to use `sudo make install` somewhat happier maintaining a non-sshd-chroot-jail Girocco installation. Signed-off-by: Kyle J. McKay --- Girocco/Config.pm | 9 +++++++++ install.sh | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Girocco/Config.pm b/Girocco/Config.pm index 3b39a10..2713a59 100644 --- a/Girocco/Config.pm +++ b/Girocco/Config.pm @@ -370,6 +370,14 @@ our $jailreporoot = "srv/git"; # data even in non-chroot setups our $chroot = "/home/repo/j"; +# An installation that will never run a chrooted sshd should set this +# to a true value (e.g. 1) to guarantee that jailsetup for a chrooted +# sshd never takes place no matter what user runs `make install`. +# Note that the "jailsetup.sh" script will still run to do the database +# setup that's stored in $chroot regardless of this settig, it will just +# always run in "dbonly" mode when this setting is true. +our $disable_jailsetup = 0; + # The gitweb files web directory (corresponds to $gitwebfiles) # Note that it is safe to place this under $basedir since it's set up after # $basedir is completely replaced during install time. Be WARNED, however, @@ -903,6 +911,7 @@ $screen_acl_file = "$basedir/screen/giroccoacl" unless $screen_acl_file; $jailreporoot =~ s,^/+,,; ($reporoot) or die "Girocco::Config \$reporoot must be set"; ($jailreporoot) or die "Girocco::Config \$jailreporoot must be set"; +$disable_jailsetup = $disable_jailsetup ? 1 : ''; (not $mob or $mob eq 'mob') or die "Girocco::Config \$mob must be undef (or '') or 'mob'"; (not $min_key_length or $min_key_length =~ /^[1-9][0-9]*$/) or die "Girocco::Config \$min_key_length must be undef or numeric"; diff --git a/install.sh b/install.sh index 1a8d609..17444c6 100755 --- a/install.sh +++ b/install.sh @@ -623,7 +623,7 @@ chmod 02775 "$cfg_reporoot" || echo "WARNING: Cannot chmod $cfg_reporoot properl chmod 02775 "$cfg_reporoot/_recyclebin" || echo "WARNING: Cannot chmod $cfg_reporoot/_recyclebin properly" -if [ -n "$cfg_chrooted" ]; then +if [ "${cfg_disable_jailsetup:-0}" = "0" ] && [ -n "$cfg_chrooted" ]; then echo "*** Setting up chroot jail for pushing..." if [ "$(id -u)" -eq 0 ]; then # jailsetup may install things from $cfg_basedir/bin into the -- 2.11.4.GIT