mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-21 08:30:53 +00:00
Add SOCKS4 support to CI
This commit is contained in:
parent
15703a4823
commit
6d9767db42
4 changed files with 32 additions and 22 deletions
|
@ -89,7 +89,7 @@ fn main() -> ExitCode {
|
|||
Ok(())
|
||||
})() {
|
||||
log::error!("{e}");
|
||||
std::process::exit(1);
|
||||
return ExitCode::FAILURE;
|
||||
};
|
||||
|
||||
ExitCode::SUCCESS
|
||||
|
|
17
src/setup.rs
17
src/setup.rs
|
@ -298,19 +298,10 @@ impl Setup {
|
|||
}
|
||||
|
||||
pub fn drop_privileges(&self) -> Result<(), Error> {
|
||||
let gid_str = match std::env::var("SUDO_GID") {
|
||||
Ok(uid_str) => uid_str,
|
||||
_ => String::from("65535"),
|
||||
};
|
||||
let gid = gid_str.parse::<u32>()?;
|
||||
nix::unistd::setgid(nix::unistd::Gid::from_raw(gid))?;
|
||||
|
||||
let uid_str = match std::env::var("SUDO_UID") {
|
||||
Ok(uid_str) => uid_str,
|
||||
_ => String::from("65535"),
|
||||
};
|
||||
let uid = uid_str.parse::<u32>()?;
|
||||
nix::unistd::setuid(nix::unistd::Uid::from_raw(uid))?;
|
||||
// 65534 is usually the nobody user. Even in cases it is not, it is safer to use this ID
|
||||
// than running with UID and GID 0.
|
||||
nix::unistd::setgid(nix::unistd::Gid::from_raw(65534))?;
|
||||
nix::unistd::setuid(nix::unistd::Uid::from_raw(65534))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue