mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
Fix non_snake_case warnings
This commit is contained in:
parent
80810da987
commit
f9e99c0c26
4 changed files with 28 additions and 27 deletions
|
@ -68,9 +68,9 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
let defaultShell: &'static str = "/bin/sh";
|
let default_shell: &'static str = "/bin/sh";
|
||||||
let defaultOption: &'static str = "-i";
|
let default_option: &'static str = "-i";
|
||||||
let userShell = std::os::getenv("SHELL");
|
let user_shell = std::os::getenv("SHELL");
|
||||||
|
|
||||||
let newroot = Path::new(opts.free[0].as_slice());
|
let newroot = Path::new(opts.free[0].as_slice());
|
||||||
if !newroot.is_dir() {
|
if !newroot.is_dir() {
|
||||||
|
@ -79,11 +79,11 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
|
||||||
let command: Vec<&str> = match opts.free.len() {
|
let command: Vec<&str> = match opts.free.len() {
|
||||||
1 => {
|
1 => {
|
||||||
let shell: &str = match userShell {
|
let shell: &str = match user_shell {
|
||||||
None => defaultShell,
|
None => default_shell,
|
||||||
Some(ref s) => s.as_slice()
|
Some(ref s) => s.as_slice()
|
||||||
};
|
};
|
||||||
vec!(shell, defaultOption)
|
vec!(shell, default_option)
|
||||||
}
|
}
|
||||||
_ => opts.free.slice(1, opts.free.len()).iter().map(|x| x.as_slice()).collect()
|
_ => opts.free.slice(1, opts.free.len()).iter().map(|x| x.as_slice()).collect()
|
||||||
};
|
};
|
||||||
|
@ -92,18 +92,18 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let executable = command[0].as_slice().to_c_str().unwrap();
|
let executable = command[0].as_slice().to_c_str().unwrap();
|
||||||
let mut commandParts: Vec<*const i8> = command.iter().map(|x| x.to_c_str().unwrap()).collect();
|
let mut command_parts: Vec<*const i8> = command.iter().map(|x| x.to_c_str().unwrap()).collect();
|
||||||
commandParts.push(std::ptr::null());
|
command_parts.push(std::ptr::null());
|
||||||
execvp(executable as *const libc::c_char, commandParts.as_ptr() as *mut *const libc::c_char) as int
|
execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_context(root: &Path, options: &getopts::Matches) {
|
fn set_context(root: &Path, options: &getopts::Matches) {
|
||||||
let userspecStr = options.opt_str("userspec");
|
let userspec_str = options.opt_str("userspec");
|
||||||
let userStr = options.opt_str("user").unwrap_or_default();
|
let user_str = options.opt_str("user").unwrap_or_default();
|
||||||
let groupStr = options.opt_str("group").unwrap_or_default();
|
let group_str = options.opt_str("group").unwrap_or_default();
|
||||||
let groupsStr = options.opt_str("groups").unwrap_or_default();
|
let groups_str = options.opt_str("groups").unwrap_or_default();
|
||||||
let userspec = match userspecStr {
|
let userspec = match userspec_str {
|
||||||
Some(ref u) => {
|
Some(ref u) => {
|
||||||
let s: Vec<&str> = u.as_slice().split(':').collect();
|
let s: Vec<&str> = u.as_slice().split(':').collect();
|
||||||
if s.len() != 2 {
|
if s.len() != 2 {
|
||||||
|
@ -113,26 +113,26 @@ fn set_context(root: &Path, options: &getopts::Matches) {
|
||||||
}
|
}
|
||||||
None => Vec::new()
|
None => Vec::new()
|
||||||
};
|
};
|
||||||
let user = if userspec.is_empty() { userStr.as_slice() } else { userspec[0].as_slice() };
|
let user = if userspec.is_empty() { user_str.as_slice() } else { userspec[0].as_slice() };
|
||||||
let group = if userspec.is_empty() { groupStr.as_slice() } else { userspec[1].as_slice() };
|
let group = if userspec.is_empty() { group_str.as_slice() } else { userspec[1].as_slice() };
|
||||||
|
|
||||||
enter_chroot(root);
|
enter_chroot(root);
|
||||||
|
|
||||||
set_groups_from_str(groupsStr.as_slice());
|
set_groups_from_str(groups_str.as_slice());
|
||||||
set_main_group(group);
|
set_main_group(group);
|
||||||
set_user(user);
|
set_user(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_chroot(root: &Path) {
|
fn enter_chroot(root: &Path) {
|
||||||
let rootStr = root.display();
|
let root_str = root.display();
|
||||||
if !std::os::change_dir(root) {
|
if !std::os::change_dir(root) {
|
||||||
crash!(1, "cannot chdir to {}", rootStr)
|
crash!(1, "cannot chdir to {}", root_str)
|
||||||
};
|
};
|
||||||
let err = unsafe {
|
let err = unsafe {
|
||||||
chroot(".".to_c_str().unwrap() as *const libc::c_char)
|
chroot(".".to_c_str().unwrap() as *const libc::c_char)
|
||||||
};
|
};
|
||||||
if err != 0 {
|
if err != 0 {
|
||||||
crash!(1, "cannot chroot to {}: {:s}", rootStr, strerror(err).as_slice())
|
crash!(1, "cannot chroot to {}: {:s}", root_str, strerror(err).as_slice())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,14 +167,14 @@ fn set_groups(groups: Vec<libc::gid_t>) -> libc::c_int {
|
||||||
|
|
||||||
fn set_groups_from_str(groups: &str) {
|
fn set_groups_from_str(groups: &str) {
|
||||||
if !groups.is_empty() {
|
if !groups.is_empty() {
|
||||||
let groupsVec: Vec<libc::gid_t> = FromIterator::from_iter(
|
let groups_vec: Vec<libc::gid_t> = FromIterator::from_iter(
|
||||||
groups.split(',').map(
|
groups.split(',').map(
|
||||||
|x| match get_group(x) {
|
|x| match get_group(x) {
|
||||||
None => crash!(1, "no such group: {}", x),
|
None => crash!(1, "no such group: {}", x),
|
||||||
Some(g) => g.gr_gid
|
Some(g) => g.gr_gid
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
let err = set_groups(groupsVec);
|
let err = set_groups(groups_vec);
|
||||||
if err != 0 {
|
if err != 0 {
|
||||||
crash!(1, "cannot set groups: {:s}", strerror(err).as_slice())
|
crash!(1, "cannot set groups: {:s}", strerror(err).as_slice())
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ pub struct BufReader<R> {
|
||||||
end: uint, // exclusive
|
end: uint, // exclusive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
pub mod Bytes {
|
pub mod Bytes {
|
||||||
pub trait Select {
|
pub trait Select {
|
||||||
fn select<'a>(&'a mut self, bytes: uint) -> Selected<'a>;
|
fn select<'a>(&'a mut self, bytes: uint) -> Selected<'a>;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#![allow(uppercase_variables)]
|
#![allow(non_snake_case)]
|
||||||
#![feature(macro_rules)]
|
#![feature(macro_rules)]
|
||||||
|
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
|
|
|
@ -64,19 +64,19 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut suffixPos = 0;
|
let mut suffix_pos = 0;
|
||||||
absfrom.components()
|
absfrom.components()
|
||||||
.zip(absto.components())
|
.zip(absto.components())
|
||||||
.take_while(
|
.take_while(
|
||||||
|&(f, t)| if f == t {
|
|&(f, t)| if f == t {
|
||||||
suffixPos += 1; true
|
suffix_pos += 1; true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}).last();
|
}).last();
|
||||||
|
|
||||||
let mut result = Path::new("");
|
let mut result = Path::new("");
|
||||||
absfrom.components().skip(suffixPos).map(|_| result.push("..")).last();
|
absfrom.components().skip(suffix_pos).map(|_| result.push("..")).last();
|
||||||
absto.components().skip(suffixPos).map(|x| result.push(x)).last();
|
absto.components().skip(suffix_pos).map(|x| result.push(x)).last();
|
||||||
|
|
||||||
println!("{}", result.display());
|
println!("{}", result.display());
|
||||||
0
|
0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue