Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change setuid Calls to setreuid, and the Same for setgid. #55

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions daemonize/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ impl<T> Daemonize<T> {
Ok(Some(first_child_pid)) => {
Outcome::Parent(match waitpid(first_child_pid) {
Err(err) => Err(err.into()),
// return value of `waitpid` may not be i32 on all platforms.
#[allow(clippy::unnecessary_cast)]
Ok(first_child_exit_code) => Ok(Parent { first_child_exit_code: first_child_exit_code as i32 }),
})
},
Expand Down Expand Up @@ -498,7 +500,7 @@ unsafe fn get_group(group: Group) -> Result<libc::gid_t, ErrorKind> {
}

unsafe fn set_group(group: libc::gid_t) -> Result<(), ErrorKind> {
check_err(libc::setgid(group), ErrorKind::SetGroup)?;
check_err(libc::setregid(group, group), ErrorKind::SetGroup)?;
Ok(())
}

Expand All @@ -516,7 +518,7 @@ unsafe fn get_user(user: User) -> Result<libc::uid_t, ErrorKind> {
}

unsafe fn set_user(user: libc::uid_t) -> Result<(), ErrorKind> {
check_err(libc::setuid(user), ErrorKind::SetUser)?;
check_err(libc::setreuid(user, user), ErrorKind::SetUser)?;
Ok(())
}

Expand Down