Compare commits
2
Commits
0dac80b487
...
fe6b03e268
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe6b03e268 | ||
|
|
5b2acfa526 |
No files matched your search
@@ -353,6 +353,9 @@ fn exec_command(argv: &[String], user: Option<UserSpec>) -> ! {
|
|||||||
let c_prog = cstrings[0].clone();
|
let c_prog = cstrings[0].clone();
|
||||||
let c_refs: Vec<&CString> = cstrings.iter().collect();
|
let c_refs: Vec<&CString> = cstrings.iter().collect();
|
||||||
|
|
||||||
|
// If UserSpec is 0:0, don't fork.
|
||||||
|
let user = user.filter(|u| !u.uid.is_root() || u.gid != Gid::from_raw(0));
|
||||||
|
|
||||||
match user {
|
match user {
|
||||||
None => {
|
None => {
|
||||||
// No privilege drop: exec directly, PID 1 becomes the command.
|
// No privilege drop: exec directly, PID 1 becomes the command.
|
||||||
@@ -362,6 +365,7 @@ fn exec_command(argv: &[String], user: Option<UserSpec>) -> ! {
|
|||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
Some(user) => {
|
Some(user) => {
|
||||||
|
warn(&format!("dropping privileges to {}:{}", user.uid, user.gid));
|
||||||
// Drop privileges in a child so PID 1 (root) can poweroff afterwards.
|
// Drop privileges in a child so PID 1 (root) can poweroff afterwards.
|
||||||
match unsafe { fork() } {
|
match unsafe { fork() } {
|
||||||
Ok(ForkResult::Child) => {
|
Ok(ForkResult::Child) => {
|
||||||
|
|||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
|
mkdir -p "$HOME/.local/share/boco"
|
||||||
|
cargo build --release --target x86_64-unknown-linux-musl -p boco-init
|
||||||
|
|
||||||
|
target_dir="${CARGO_TARGET_DIR:-target}"
|
||||||
|
cp "$target_dir/x86_64-unknown-linux-musl/release/boco-init" "$HOME/.local/share/boco/"
|
||||||
|
|
||||||
Reference in new issue
Block a user