mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 05:57:46 +00:00
CString::as_slice_with_nul -> CString::as_bytes_with_nul
This commit is contained in:
parent
4ad3e854ac
commit
09b1162912
2 changed files with 5 additions and 5 deletions
|
@ -95,8 +95,8 @@ pub fn uumain(args: Vec<String>) -> isize {
|
||||||
set_context(&newroot, &opts);
|
set_context(&newroot, &opts);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let executable = CString::from_slice(command[0].as_bytes()).as_slice_with_nul().as_ptr();
|
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_slice_with_nul().as_ptr()).collect();
|
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());
|
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
|
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();
|
let root_str = root.display();
|
||||||
std::os::change_dir(root).unwrap();
|
std::os::change_dir(root).unwrap();
|
||||||
let err = unsafe {
|
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 {
|
if err != 0 {
|
||||||
crash!(1, "cannot chroot to {}: {}", root_str, strerror(err).as_slice())
|
crash!(1, "cannot chroot to {}: {}", root_str, strerror(err).as_slice())
|
||||||
|
|
|
@ -134,7 +134,7 @@ pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
|
||||||
} else {
|
} else {
|
||||||
let pw_pointer = unsafe {
|
let pw_pointer = unsafe {
|
||||||
let cstr = CString::from_slice(username.as_bytes());
|
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() {
|
if !pw_pointer.is_null() {
|
||||||
Some(unsafe { read(pw_pointer) })
|
Some(unsafe { read(pw_pointer) })
|
||||||
|
@ -153,7 +153,7 @@ pub fn get_group(groupname: &str) -> Option<c_group> {
|
||||||
} else {
|
} else {
|
||||||
unsafe {
|
unsafe {
|
||||||
let cstr = CString::from_slice(groupname.as_bytes());
|
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)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue