Skip to content

Commit

Permalink
Merge pull request #175 from jokeyrhyme/implement-unix-dir-and-tmpdir…
Browse files Browse the repository at this point in the history
…-sockets

✨ Implement unix:dir and unix:tmpdir for `--address`
  • Loading branch information
zeenix authored Dec 7, 2024
2 parents 37b187c + 1bf7912 commit 1e8a567
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ enumflags2 = "0.7.9"
console-subscriber = { version = "0.4.0", optional = true }
xdg-home = "1.1.0"
event-listener = "5.3.0"
fastrand = "2.2.0"

[target.'cfg(unix)'.dependencies]
nix = { version = "0.29.0", features = ["user"] }
Expand Down
15 changes: 11 additions & 4 deletions src/bus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,16 @@ impl Bus {

addr
}
UnixSocket::Dir(_) => bail!("`dir` transport is not supported (yet)."),
UnixSocket::TmpDir(_) => bail!("`tmpdir` transport is not supported (yet)."),
UnixSocket::Dir(dir) | UnixSocket::TmpDir(dir) => {
let path = dir.join(format!("dbus-{}", fastrand::u32(1_000_000..u32::MAX)));
let addr = SocketAddr::from_pathname(&path)?;
info!(
"Listening on UNIX socket file `{}`.",
path.to_string_lossy()
);

addr
}
_ => bail!("Unsupported address."),
};
let std_listener =
Expand Down Expand Up @@ -250,9 +258,8 @@ fn default_address() -> String {
.join("user")
.join(format!("{}", nix::unistd::Uid::current()))
});
let path = runtime_dir.join("busd-session");

format!("unix:path={}", path.display())
format!("unix:dir={}", runtime_dir.display())
}

#[cfg(not(unix))]
Expand Down

0 comments on commit 1e8a567

Please sign in to comment.