Fix ssh/scp/rsync sandboxing

Change-Id: I1e94c028fafa78d4792a50790a76ab32bc4e10b2
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/debian/rsync.BUILD b/debian/rsync.BUILD
index 4fe45b1..d761ace 100644
--- a/debian/rsync.BUILD
+++ b/debian/rsync.BUILD
@@ -1,5 +1,26 @@
-filegroup(
+genrule(
+    name = "copy_rsync_wrapper",
+    srcs = ["@//debian:rsync_wrapper.sh"],
+    outs = ["rsync_wrapper.sh"],
+    cmd = "cp $< $@",
+)
+
+sh_binary(
     name = "rsync",
-    srcs = ["usr/bin/rsync"],
+    srcs = [
+        "rsync_wrapper.sh",
+    ],
+    data = [
+        "usr/bin/rsync",
+        ":libs",
+        "@bazel_tools//tools/bash/runfiles",
+    ],
     visibility = ["//visibility:public"],
 )
+
+filegroup(
+    name = "libs",
+    srcs = glob([
+        "usr/lib/x86_64-linux-gnu/**",
+    ]),
+)