Snap for 7302914 from 23838c955e111a2d24fe2aadc60892d94e79c4b7 to sc-release

Change-Id: I1469f2379fadd09581a98645f84e7449d30fef22
diff --git a/rust/minijail/src/lib.rs b/rust/minijail/src/lib.rs
index d4f5787..ba9c8af 100644
--- a/rust/minijail/src/lib.rs
+++ b/rust/minijail/src/lib.rs
@@ -640,11 +640,11 @@
     /// FDs 0, 1, and 2 are overwritten with /dev/null FDs unless they are included in the
     /// inheritable_fds list. This function may abort in the child on error because a partially
     /// entered jail isn't recoverable.
-    pub fn run<P: AsRef<Path>>(
+    pub fn run<P: AsRef<Path>, S: AsRef<str>>(
         &self,
         cmd: P,
         inheritable_fds: &[RawFd],
-        args: &[&str],
+        args: &[S],
     ) -> Result<pid_t> {
         self.run_remap(
             cmd,
@@ -658,11 +658,11 @@
 
     /// Behaves the same as `run()` except `inheritable_fds` is a list of fd
     /// mappings rather than just a list of fds to preserve.
-    pub fn run_remap<P: AsRef<Path>>(
+    pub fn run_remap<P: AsRef<Path>, S: AsRef<str>>(
         &self,
         cmd: P,
         inheritable_fds: &[(RawFd, RawFd)],
-        args: &[&str],
+        args: &[S],
     ) -> Result<pid_t> {
         let cmd_os = cmd
             .as_ref()
@@ -674,8 +674,9 @@
         // into a null terminated array, suitable for use as an argv parameter to `execve`.
         let mut args_cstr = Vec::with_capacity(args.len());
         let mut args_array = Vec::with_capacity(args.len());
-        for &arg in args {
-            let arg_cstr = CString::new(arg).map_err(|_| Error::StrToCString(arg.to_owned()))?;
+        for arg in args {
+            let arg_cstr = CString::new(arg.as_ref())
+                .map_err(|_| Error::StrToCString(arg.as_ref().to_owned()))?;
             args_array.push(arg_cstr.as_ptr());
             args_cstr.push(arg_cstr);
         }
@@ -850,6 +851,7 @@
     use super::*;
 
     const SHELL: &str = "/bin/sh";
+    const EMPTY_STRING_SLICE: &[&str] = &[];
 
     #[test]
     fn create_and_free() {
@@ -883,9 +885,9 @@
             // Using libc to open/close FDs for testing.
             const FILE_PATH: &[u8] = b"/dev/null\0";
             let j = Minijail::new().unwrap();
-            let first = libc::open(FILE_PATH.as_ptr() as *const i8, libc::O_RDONLY);
+            let first = libc::open(FILE_PATH.as_ptr() as *const c_char, libc::O_RDONLY);
             assert!(first >= 0);
-            let second = libc::open(FILE_PATH.as_ptr() as *const i8, libc::O_RDONLY);
+            let second = libc::open(FILE_PATH.as_ptr() as *const c_char, libc::O_RDONLY);
             assert!(second >= 0);
             let fds: Vec<RawFd> = vec![0, 1, 2, first];
             if j.fork(Some(&fds)).unwrap() == 0 {
@@ -911,7 +913,7 @@
     #[test]
     fn wait_success() {
         let j = Minijail::new().unwrap();
-        j.run("/bin/true", &[1, 2], &[]).unwrap();
+        j.run("/bin/true", &[1, 2], &EMPTY_STRING_SLICE).unwrap();
         expect_result!(j.wait(), Ok(()));
     }
 
@@ -930,21 +932,22 @@
     #[test]
     fn wait_returncode() {
         let j = Minijail::new().unwrap();
-        j.run("/bin/false", &[1, 2], &[]).unwrap();
+        j.run("/bin/false", &[1, 2], &EMPTY_STRING_SLICE).unwrap();
         expect_result!(j.wait(), Err(Error::ReturnCode(1)));
     }
 
     #[test]
     fn wait_noaccess() {
         let j = Minijail::new().unwrap();
-        j.run("/dev/null", &[1, 2], &[]).unwrap();
+        j.run("/dev/null", &[1, 2], &EMPTY_STRING_SLICE).unwrap();
         expect_result!(j.wait(), Err(Error::NoAccess));
     }
 
     #[test]
     fn wait_nocommand() {
         let j = Minijail::new().unwrap();
-        j.run("/bin/does not exist", &[1, 2], &[]).unwrap();
+        j.run("/bin/does not exist", &[1, 2], &EMPTY_STRING_SLICE)
+            .unwrap();
         expect_result!(j.wait(), Err(Error::NoCommand));
     }
 
@@ -984,6 +987,13 @@
     #[test]
     fn run() {
         let j = Minijail::new().unwrap();
-        j.run("/bin/true", &[], &[]).unwrap();
+        j.run("/bin/true", &[], &EMPTY_STRING_SLICE).unwrap();
+    }
+
+    #[test]
+    fn run_string_vec() {
+        let j = Minijail::new().unwrap();
+        let args = vec!["ignored".to_string()];
+        j.run(Path::new("/bin/true"), &[], &args).unwrap();
     }
 }