1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 21:47:46 +00:00

CString::as_slice_with_nul -> CString::as_bytes_with_nul

This commit is contained in:
Michael Gehring 2015-02-22 10:06:26 +01:00
parent 4ad3e854ac
commit 09b1162912
2 changed files with 5 additions and 5 deletions

View file

@ -95,8 +95,8 @@ pub fn uumain(args: Vec<String>) -> 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())

View file

@ -134,7 +134,7 @@ pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
} 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<c_group> {
} 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)
}
};