summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-03-26 15:31:33 (GMT)
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-03-26 15:31:33 (GMT)
commitef5aba9e7a2470055c01cc53f98b5bab79e60d28 (patch)
tree8cdd5cb29436de95418ee645fc0e6fd9d1b5de44
parent6449d723aa1327017baaf48b82650f0d125c0508 (diff)
parent24eb626ab38e82c109f189704f95fb81410c65a8 (diff)
downloadbaserock-chroot-ef5aba9e7a2470055c01cc53f98b5bab79e60d28.tar.gz
Merge branch 'baserock/danielsilverstone/forward-ssh-agent'
Reviewed-By: Richard Maw <richard.maw@codethink.co.uk> Reviewed-By: Sam Thursfield <sam.thursfield@codethink.co.uk>
-rw-r--r--debian/changelog7
-rw-r--r--debian/control2
-rwxr-xr-xenter-baserock18
3 files changed, 25 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index 68a5b85..6540df6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+baserock-chroot (2) unstable; urgency=low
+
+ * Add support for SSH authentication agent sockets.
+ * Also depends on socat now.
+
+ -- Daniel Silverstone <daniel.silverstone@codethink.co.uk> Wed, 26 Mar 2014 14:09:58 +0000
+
baserock-chroot (1) unstable; urgency=low
* Initial version
diff --git a/debian/control b/debian/control
index daefe92..f9b53ff 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,7 @@ Standards-Version: 3.6.1
Package: baserock-chroot
Architecture: all
-Depends: schroot, wget, sudo
+Depends: schroot, wget, sudo, socat
Description: Baserock chroot related tools
Manage chroots which contain baserock on [XKL]Ubuntu systems.
diff --git a/enter-baserock b/enter-baserock
index d133364..4ce2b52 100755
--- a/enter-baserock
+++ b/enter-baserock
@@ -38,4 +38,20 @@ if test "x$CHOSEN" = "x"; then
fi
cd /
-exec sudo -H schroot -c "baserock-$CHOSEN"
+
+if test "x$SSH_AUTH_SOCK" != "x"; then
+ echo "Forwarding SSH agent into chroot"
+ TDIR=$(mktemp --tmpdir=/tmp -d)
+ SOCK="${TDIR}/auth-sock"
+ socat "UNIX-LISTEN:${SOCK},fork" "UNIX-CONNECT:${SSH_AUTH_SOCK}" >/dev/null 2>/dev/null &
+ SOCAT_PID=$!
+ cleanup () {
+ echo "Clearing up SSH agent forwarding"
+ kill $SOCAT_PID >/dev/null 2>/dev/null
+ rm -rf "${TDIR}"
+ }
+ trap cleanup 0
+ sudo -H schroot -c "baserock-$CHOSEN" -- /usr/bin/env "SSH_AUTH_SOCK=$SOCK" /bin/bash -l
+else
+ exec sudo -H schroot -c "baserock-$CHOSEN"
+fi