summaryrefslogtreecommitdiff
path: root/setup.d
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2015-04-30 11:43:15 +0200
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2015-04-30 11:43:15 +0200
commit627706210c40d0547f42a31e7c6a626029272c93 (patch)
treeb34cc3e5ba162d7af6c1ef4457949cfa84363f91 /setup.d
parenta3fad9ea53e83c31c186b8cb1019c136fdb2c830 (diff)
Fix problem with accessing SSH_AUTH_SOCK
Jenkins uses custom ssh-agent configuration with socket created under /tmp. Since we don't want to share /tmp, we are bind-mounting the single file/socket using 11mount-ssh schroot setup script. This is a slightly-edited version from a /usr/share/doc/schroot/contrib/setup.d/10mount-ssh
Diffstat (limited to 'setup.d')
-rwxr-xr-xsetup.d/11mount-ssh47
1 files changed, 47 insertions, 0 deletions
diff --git a/setup.d/11mount-ssh b/setup.d/11mount-ssh
new file mode 100755
index 0000000..1c17bba
--- /dev/null
+++ b/setup.d/11mount-ssh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# Copyright © 2010 Sascha Silbe <sascha-pgp@silbe.org>
+#
+# schroot is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 3
+# as published by the Free Software Foundation.
+#
+# schroot is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+#####################################################################
+# 10mount-ssh: "Forward" ssh-agent to chroot.
+# Performs a bind-mount of the ssh-agent socket directory. Clean-up
+# happens at session end in setup.d/10mount.
+#####################################################################
+
+set -e
+
+ACTION="$1"
+STATUS="$2"
+
+if [ "$STATUS" != ok ] ; then
+ exit 0
+fi
+
+# Extract SSH_AUTH_SOCK from environment of schroot process ($PID)
+SSH_AUTH_SOCK="$(tr '\0' '\n' < /proc/"$PID"/environ | grep ^SSH_AUTH_SOCK | head -n 1 |sed -e 's/^SSH_AUTH_SOCK=//')"
+if [ -z "${SSH_AUTH_SOCK:-}" ] ; then
+ exit 0
+fi
+
+SOCK_DIR="$(dirname "${SSH_AUTH_SOCK}")"
+
+if [ "$ACTION" = "setup-start" ] ; then
+ if [ -e "${CHROOT_PATH}/${SSH_AUTH_SOCK}" ] ; then
+ exit 0
+ fi
+ mkdir -p "${CHROOT_PATH}/${SOCK_DIR}"
+ touch "${CHROOT_PATH}/${SSH_AUTH_SOCK}"
+ mount -o bind "${SSH_AUTH_SOCK}" "${CHROOT_PATH}/${SSH_AUTH_SOCK}"
+fi