Skip to content

Commit 0470151

Browse files
committed
fix: allow make allow-non-admin set owner to root
1 parent 46f8e9e commit 0470151

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "bootit"
33
description = "Lightweight Boot Selector"
4-
author = "mincomk <mail@drchi.co.kr>"
54
repository = "https://github.com/mincomk/bootit"
65
license = "MIT"
76
version = "0.1.0"
@@ -19,3 +18,6 @@ serde = { version = "1.0.228", features = ["derive"] }
1918
serde_yaml = "0.9"
2019
system_shutdown = "4.1.0"
2120
which = "8.0.0"
21+
22+
[target.'cfg(target_os = "linux")'.dependencies]
23+
nix = { version = "0.31.1", features = ["fs", "user"] }

src/command/allow_non_admin.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ pub fn allow_non_admin(it_path: Option<PathBuf>) -> miette::Result<()> {
1313
None => util::find_it()?,
1414
};
1515

16+
// set the owner to root
17+
use nix::unistd::{Gid, Uid, chown};
18+
chown(&it_path, Some(Uid::from_raw(0)), Some(Gid::from_raw(0))).into_diagnostic()?;
19+
1620
let metadata = fs::metadata(&it_path).into_diagnostic()?;
1721
let mut permissions = metadata.permissions();
1822
let mode = permissions.mode();

0 commit comments

Comments
 (0)