From 09b1162912152104b441e48ea1c3defe50ada5a7 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 22 Feb 2015 10:06:26 +0100 Subject: [PATCH] CString::as_slice_with_nul -> CString::as_bytes_with_nul --- src/chroot/chroot.rs | 6 +++--- src/common/c_types.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index c88f3b35f..daa6795ec 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -95,8 +95,8 @@ pub fn uumain(args: Vec) -> isize { set_context(&newroot, &opts); unsafe { - let executable = CString::from_slice(command[0].as_bytes()).as_slice_with_nul().as_ptr(); - let mut command_parts: Vec<*const i8> = command.iter().map(|x| CString::from_slice(x.as_bytes()).as_slice_with_nul().as_ptr()).collect(); + let executable = CString::from_slice(command[0].as_bytes()).as_bytes_with_nul().as_ptr(); + let mut command_parts: Vec<*const i8> = command.iter().map(|x| CString::from_slice(x.as_bytes()).as_bytes_with_nul().as_ptr()).collect(); command_parts.push(std::ptr::null()); execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as isize } @@ -131,7 +131,7 @@ fn enter_chroot(root: &Path) { let root_str = root.display(); std::os::change_dir(root).unwrap(); let err = unsafe { - chroot(CString::from_slice(b".").as_slice_with_nul().as_ptr() as *const libc::c_char) + chroot(CString::from_slice(b".").as_bytes_with_nul().as_ptr() as *const libc::c_char) }; if err != 0 { crash!(1, "cannot chroot to {}: {}", root_str, strerror(err).as_slice()) diff --git a/src/common/c_types.rs b/src/common/c_types.rs index 78fde5648..50fcb287e 100644 --- a/src/common/c_types.rs +++ b/src/common/c_types.rs @@ -134,7 +134,7 @@ pub fn get_pw_from_args(free: &Vec) -> Option { } else { let pw_pointer = unsafe { let cstr = CString::from_slice(username.as_bytes()); - getpwnam(cstr.as_slice_with_nul().as_ptr()) + getpwnam(cstr.as_bytes_with_nul().as_ptr()) }; if !pw_pointer.is_null() { Some(unsafe { read(pw_pointer) }) @@ -153,7 +153,7 @@ pub fn get_group(groupname: &str) -> Option { } else { unsafe { let cstr = CString::from_slice(groupname.as_bytes()); - getgrnam(cstr.as_slice_with_nul().as_ptr() as *const c_char) + getgrnam(cstr.as_bytes_with_nul().as_ptr() as *const c_char) } };