From fcd05aca8dd559fef7f81cb38b07288af8ea12d2 Mon Sep 17 00:00:00 2001 From: Vsevolod Velichko Date: Tue, 17 Jun 2014 02:07:16 +0400 Subject: [PATCH] Use gid_t instead of uid_t for groups --- chroot/chroot.rs | 6 +++--- common/c_types.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chroot/chroot.rs b/chroot/chroot.rs index 2b280f070..454f2e10f 100644 --- a/chroot/chroot.rs +++ b/chroot/chroot.rs @@ -21,7 +21,7 @@ use libc::funcs::posix88::unistd::{execvp, setuid, setgid}; extern { fn chroot(path: *libc::c_char) -> libc::c_int; - fn setgroups(size: libc::c_int, list: *libc::uid_t) -> libc::c_int; + fn setgroups(size: libc::c_int, list: *libc::gid_t) -> libc::c_int; } static NAME: &'static str = "chroot"; @@ -145,7 +145,7 @@ fn set_main_group(group: &str) { fn set_groups(groups: &str) { if !groups.is_empty() { - let groupsVec: Vec = FromIterator::from_iter( + let groupsVec: Vec = FromIterator::from_iter( groups.split(',').map( |x| match get_group(x) { None => { crash!(1, "no such group: {}", x) } @@ -154,7 +154,7 @@ fn set_groups(groups: &str) { ); let err = unsafe { setgroups(groupsVec.len() as libc::c_int, - groupsVec.as_slice().as_ptr() as *libc::uid_t) + groupsVec.as_slice().as_ptr() as *libc::gid_t) }; if err != 0 { crash!(1, "cannot set groups: {:s}", strerror(err).as_slice()) diff --git a/common/c_types.rs b/common/c_types.rs index 5de352d53..e4a891722 100644 --- a/common/c_types.rs +++ b/common/c_types.rs @@ -124,7 +124,7 @@ pub fn get_pw_from_args(free: &Vec) -> Option { pub fn get_group(groupname: &str) -> Option { let group = if groupname.chars().all(|c| c.is_digit()) { - unsafe { getgrgid(from_str::(groupname).unwrap()) } + unsafe { getgrgid(from_str::(groupname).unwrap()) } } else { unsafe { getgrnam(groupname.to_c_str().unwrap() as *c_char) } };