Unhardcode user IDs

This commit is contained in:
Val Packett 2025-12-05 04:48:37 -03:00
parent fa0bf056d0
commit ea34b7b08c
3 changed files with 14 additions and 4 deletions

5
Cargo.lock generated
View file

@ -635,9 +635,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.174"
version = "0.2.178"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
[[package]]
name = "linux-raw-sys"
@ -1026,6 +1026,7 @@ dependencies = [
"clap",
"eyre",
"futures",
"libc",
"rand",
"rustix",
"sidebus-common",

View file

@ -18,3 +18,4 @@ rustix = { version = "1.0.8", features = ["fs"] }
url = "2.5.4"
rand = "0.9.2"
futures = "0.3.31"
libc = "0.2.178"

View file

@ -43,6 +43,14 @@ struct BrokerCli {
/// Unix socket path to listen on for the VM bus
#[clap(long)]
unix_path: Option<PathBuf>,
/// The user ID for the appvm user inside of the guest
#[clap(long, default_value = "1337")]
guest_uid: u32,
/// The group ID for the appvm group inside of the guest
#[clap(long, default_value = "1337")]
guest_gid: u32,
}
async fn new_hosted_bus() -> eyre::Result<(
@ -129,9 +137,9 @@ async fn main() -> eyre::Result<()> {
"--socket-path",
cli.runtime_dir.join("fs.sock").to_str().unwrap(),
"--uid-map",
":1000:1001:1:",
&format!(":{}:{}:1:", cli.guest_uid, unsafe { libc::getuid() }),
"--gid-map",
":100:100:1:",
&format!(":{}:{}:1:", cli.guest_gid, unsafe { libc::getgid() }),
"--log-level",
"debug",
])