Add executable flag to sbox copy requests

Add a boolean flag to the sbox proto to request the executable bit
to be set after copying a file.  This will be used for sandboxing
tools when copying a file in from the source tree that would
normally get its executable bit set during installation.

Bug: 124313442
Test: sbox_test.go
Change-Id: Ie2c197bb5183ffc1bf63fd6effd175143cd324d4
diff --git a/cmd/sbox/sbox.go b/cmd/sbox/sbox.go
index a4f57ea..f8919a4 100644
--- a/cmd/sbox/sbox.go
+++ b/cmd/sbox/sbox.go
@@ -337,7 +337,7 @@
 	for _, copyPair := range copies {
 		fromPath := joinPath(fromDir, copyPair.GetFrom())
 		toPath := joinPath(toDir, copyPair.GetTo())
-		err := copyOneFile(fromPath, toPath)
+		err := copyOneFile(fromPath, toPath, copyPair.GetExecutable())
 		if err != nil {
 			return fmt.Errorf("error copying %q to %q: %w", fromPath, toPath, err)
 		}
@@ -346,7 +346,7 @@
 }
 
 // copyOneFile copies a file.
-func copyOneFile(from string, to string) error {
+func copyOneFile(from string, to string, executable bool) error {
 	err := os.MkdirAll(filepath.Dir(to), 0777)
 	if err != nil {
 		return err
@@ -358,6 +358,9 @@
 	}
 
 	perm := stat.Mode()
+	if executable {
+		perm = perm | 0100 // u+x
+	}
 
 	in, err := os.Open(from)
 	if err != nil {