audio/ncspot: Update to 0.9.7

Remove zbus patch (Use notify-rust with dbus instead of zbus in 0.9.6)

Major changes in 0.9.4:
 - More detailed error message in case of command parse error
 - Remove panics in the update_token flow
 - Add exec command allowing users to execute shell commands on key press
 - Improved seek command to allow more units (e.g. 2s), check parse_duration documentation
 - Set terminal title to ncspo

Major changes on 0.9.5:
 - Fix errors showing up even though the command was successful
 - Fix lists that were shown as empty even though they contained items
 - seek spits out correct error when used with no arg

Major changes on 0.9.6:
 - Enable autojump for playlist selection list in context menu
 - Use notify-rust with dbus instead of zbus
 - Fix compilation on Rust versions < 1.58.0
 - Make album sorting case-insensitive
 - Enable gapless by default
 - Improve playlist sorting
 - Dependency updates

Major changes on 0.9.7:
 - Fix error messages shown on successful commands
 - Notification improvements
 - Dependency updates

Full log: https://github.com/hrkfdn/ncspot/releases

Reported by:	Eirik Øverby <eirik.overby@modirum.com>
This commit is contained in:
Rodrigo Osorio 2022-04-12 14:48:15 +02:00
parent fa4b531894
commit 901df96740
3 changed files with 507 additions and 866 deletions

View file

@ -1,7 +1,6 @@
PORTNAME= ncspot
DISTVERSIONPREFIX= v
DISTVERSION= 0.9.3
PORTREVISION= 3
DISTVERSION= 0.9.7
CATEGORIES= audio
MAINTAINER= rodrigo@FreeBSD.org
@ -16,149 +15,133 @@ USES= cargo ncurses ssl
USE_GITHUB= yes
GH_ACCOUNT= hrkfdn
CARGO_CRATES= addr2line-0.17.0 \
adler-1.0.2 \
aes-0.6.0 \
CARGO_CRATES= aes-0.6.0 \
aes-ctr-0.6.0 \
aes-soft-0.6.4 \
aesni-0.10.0 \
ahash-0.6.3 \
ahash-0.7.6 \
aho-corasick-0.7.18 \
alsa-0.5.0 \
alsa-0.6.0 \
alsa-sys-0.3.1 \
ansi_term-0.12.1 \
array-macro-1.0.5 \
arrayref-0.3.6 \
arrayvec-0.5.2 \
async-io-1.6.0 \
async-trait-0.1.52 \
atty-0.2.11 \
autocfg-1.0.1 \
backtrace-0.3.63 \
atty-0.2.14 \
autocfg-1.1.0 \
base-x-0.2.8 \
base64-0.13.0 \
bindgen-0.56.0 \
bitflags-1.3.2 \
blake2b_simd-0.5.11 \
block-0.1.6 \
block-buffer-0.9.0 \
bumpalo-3.8.0 \
block-buffer-0.10.2 \
bumpalo-3.9.1 \
bytecount-0.6.2 \
byteorder-1.4.3 \
bytes-1.1.0 \
cache-padded-1.1.1 \
cc-1.0.72 \
cc-1.0.73 \
cesu8-1.1.0 \
cexpr-0.4.0 \
cfg-if-0.1.10 \
cfg-if-1.0.0 \
chrono-0.4.19 \
chunked_transfer-1.4.0 \
cipher-0.2.5 \
clang-sys-1.3.0 \
clap-2.34.0 \
clang-sys-1.3.1 \
clap-3.1.6 \
clipboard-0.5.0 \
clipboard-win-2.2.0 \
cloudabi-0.0.3 \
combine-4.6.2 \
concurrent-queue-1.2.2 \
const_fn-0.4.8 \
constant_time_eq-0.1.5 \
combine-4.6.3 \
const_fn-0.4.9 \
convert_case-0.4.0 \
cookie-0.15.1 \
cookie_store-0.15.1 \
core-foundation-0.9.2 \
core-foundation-0.9.3 \
core-foundation-sys-0.8.3 \
coreaudio-rs-0.10.0 \
coreaudio-sys-0.2.8 \
cpal-0.13.4 \
cpufeatures-0.2.1 \
crossbeam-channel-0.5.1 \
crossbeam-utils-0.8.5 \
coreaudio-sys-0.2.9 \
cpal-0.13.5 \
cpufeatures-0.2.2 \
crossbeam-channel-0.5.4 \
crossbeam-utils-0.8.8 \
crypto-common-0.1.3 \
crypto-mac-0.11.1 \
ctr-0.6.0 \
cursive-0.16.3 \
cursive_core-0.2.2 \
darling-0.10.2 \
darling_core-0.10.2 \
darling_macro-0.10.2 \
cursive-0.17.0 \
cursive_core-0.3.1 \
darling-0.13.1 \
darling_core-0.13.1 \
darling_macro-0.13.1 \
dbus-0.9.5 \
dbus-tree-0.9.2 \
derivative-2.2.0 \
derive-new-0.5.9 \
derive_more-0.99.17 \
digest-0.9.0 \
dirs-1.0.5 \
digest-0.10.3 \
dirs-next-1.0.2 \
dirs-next-2.0.0 \
dirs-sys-next-0.1.2 \
discard-1.0.4 \
downcast-rs-1.2.0 \
encoding_rs-0.8.30 \
enum-map-0.6.4 \
enum-map-derive-0.4.6 \
enumflags2-0.6.4 \
enumflags2_derive-0.6.4 \
exitfailure-0.5.1 \
failure-0.1.8 \
failure_derive-0.1.8 \
fastrand-1.5.0 \
enum-map-2.0.3 \
enum-map-derive-0.8.0 \
enumset-1.0.8 \
enumset_derive-0.5.5 \
fastrand-1.7.0 \
fern-0.6.0 \
fixedbitset-0.2.0 \
fixedbitset-0.4.1 \
fnv-1.0.7 \
foreign-types-0.3.2 \
foreign-types-shared-0.1.1 \
form_urlencoded-1.0.1 \
futures-0.1.31 \
futures-0.3.18 \
futures-channel-0.3.18 \
futures-core-0.3.18 \
futures-executor-0.3.18 \
futures-io-0.3.18 \
futures-lite-1.12.0 \
futures-macro-0.3.18 \
futures-sink-0.3.18 \
futures-task-0.3.18 \
futures-util-0.3.18 \
generic-array-0.14.4 \
getrandom-0.1.16 \
getrandom-0.2.3 \
gimli-0.26.1 \
futures-0.3.21 \
futures-channel-0.3.21 \
futures-core-0.3.21 \
futures-executor-0.3.21 \
futures-io-0.3.21 \
futures-macro-0.3.21 \
futures-sink-0.3.21 \
futures-task-0.3.21 \
futures-util-0.3.21 \
generic-array-0.14.5 \
getrandom-0.2.5 \
glob-0.3.0 \
h2-0.3.9 \
h2-0.3.12 \
half-1.8.2 \
hashbrown-0.11.2 \
headers-0.3.5 \
headers-0.3.7 \
headers-core-0.2.0 \
heck-0.3.3 \
hermit-abi-0.1.20 \
heck-0.4.0 \
hermit-abi-0.1.19 \
hmac-0.11.0 \
http-0.2.5 \
http-0.2.6 \
http-body-0.4.4 \
httparse-1.5.1 \
httparse-1.6.0 \
httpdate-1.0.2 \
hyper-0.14.16 \
hyper-0.14.18 \
hyper-proxy-0.9.1 \
hyper-tls-0.5.0 \
ident_case-1.0.1 \
idna-0.2.3 \
indexmap-1.7.0 \
indexmap-1.8.0 \
instant-0.1.12 \
ioctl-rs-0.2.0 \
ipnet-2.3.1 \
itoa-0.4.8 \
ipnet-2.4.0 \
itoa-1.0.1 \
jni-0.19.0 \
jni-sys-0.3.0 \
jobserver-0.1.24 \
js-sys-0.3.55 \
lazy_static-0.2.11 \
js-sys-0.3.56 \
lazy_static-1.4.0 \
lazycell-1.3.0 \
lewton-0.10.2 \
libc-0.2.109 \
libc-0.2.121 \
libdbus-sys-0.2.2 \
libloading-0.7.2 \
libm-0.2.1 \
libpulse-binding-2.25.0 \
libpulse-simple-binding-2.24.1 \
libloading-0.7.3 \
libm-0.2.2 \
libpulse-binding-2.26.0 \
libpulse-simple-binding-2.25.0 \
libpulse-simple-sys-1.19.2 \
libpulse-sys-1.19.3 \
librespot-audio-0.3.1 \
@ -166,240 +149,216 @@ CARGO_CRATES= addr2line-0.17.0 \
librespot-metadata-0.3.1 \
librespot-playback-0.3.1 \
librespot-protocol-0.3.1 \
lock_api-0.3.4 \
lock_api-0.4.5 \
log-0.4.14 \
mac-notification-sys-0.3.0 \
lock_api-0.4.6 \
log-0.4.16 \
mac-notification-sys-0.5.0 \
mach-0.3.2 \
malloc_buf-0.0.6 \
maplit-1.0.2 \
matches-0.1.9 \
maybe-async-0.2.6 \
memchr-1.0.2 \
memchr-2.4.1 \
memoffset-0.6.5 \
mime-0.3.16 \
mime_guess-2.0.3 \
miniz_oxide-0.4.4 \
mio-0.7.14 \
minimal-lexical-0.2.1 \
mio-0.8.2 \
miow-0.3.7 \
native-tls-0.2.8 \
nb-connect-1.2.0 \
ncurses-5.101.0 \
ndk-0.3.0 \
ndk-0.4.0 \
ndk-glue-0.3.0 \
ndk-glue-0.4.0 \
ndk-macro-0.2.0 \
ndk-sys-0.2.2 \
nix-0.17.0 \
nix-0.18.0 \
ndk-0.6.0 \
ndk-context-0.1.0 \
ndk-glue-0.6.1 \
ndk-macro-0.3.0 \
ndk-sys-0.3.0 \
nix-0.20.0 \
nom-3.2.1 \
nix-0.22.3 \
nix-0.23.1 \
nom-5.1.2 \
notify-rust-4.5.5 \
ntapi-0.3.6 \
num-0.3.1 \
nom-7.1.1 \
notify-rust-4.5.7 \
ntapi-0.3.7 \
num-0.2.1 \
num-0.4.0 \
num-bigint-0.2.6 \
num-bigint-0.4.3 \
num-complex-0.3.1 \
num-complex-0.2.4 \
num-complex-0.4.0 \
num-derive-0.3.3 \
num-integer-0.1.44 \
num-iter-0.1.42 \
num-rational-0.3.2 \
num-rational-0.2.4 \
num-rational-0.4.0 \
num-traits-0.2.14 \
num_cpus-1.13.0 \
num_enum-0.5.4 \
num_enum_derive-0.5.4 \
num_cpus-1.13.1 \
num_enum-0.5.7 \
num_enum_derive-0.5.7 \
num_threads-0.1.5 \
numtoa-0.1.0 \
objc-0.2.7 \
objc-foundation-0.1.1 \
objc_id-0.1.1 \
object-0.27.1 \
oboe-0.4.4 \
oboe-sys-0.4.4 \
oboe-0.4.5 \
oboe-sys-0.4.5 \
ogg-0.8.0 \
once_cell-1.8.0 \
once_cell-1.10.0 \
opaque-debug-0.3.0 \
openssl-0.10.38 \
openssl-probe-0.1.4 \
openssl-sys-0.9.71 \
os_pipe-0.9.2 \
openssl-probe-0.1.5 \
openssl-sys-0.9.72 \
os_pipe-1.0.1 \
os_str_bytes-6.0.0 \
owning_ref-0.4.1 \
pancurses-0.16.1 \
pancurses-0.17.0 \
parking-2.0.0 \
parking_lot-0.10.2 \
parking_lot-0.11.2 \
parking_lot_core-0.7.2 \
parking_lot_core-0.8.5 \
parse_duration-2.1.1 \
pbkdf2-0.8.0 \
pdcurses-sys-0.7.1 \
peeking_take_while-0.1.2 \
percent-encoding-2.1.0 \
petgraph-0.5.1 \
pin-project-lite-0.2.7 \
petgraph-0.6.0 \
pin-project-lite-0.2.8 \
pin-utils-0.1.0 \
pkg-config-0.3.23 \
pkg-config-0.3.24 \
platform-dirs-0.3.0 \
polling-2.2.0 \
portaudio-rs-0.3.2 \
portaudio-sys-0.1.1 \
ppv-lite86-0.2.15 \
ppv-lite86-0.2.16 \
priority-queue-1.2.1 \
proc-macro-crate-0.1.5 \
proc-macro-crate-1.1.0 \
proc-macro-error-1.0.4 \
proc-macro-error-attr-1.0.4 \
proc-macro-crate-1.1.3 \
proc-macro-hack-0.5.19 \
proc-macro2-1.0.33 \
protobuf-2.25.2 \
protobuf-codegen-2.25.2 \
protobuf-codegen-pure-2.25.2 \
proc-macro2-1.0.36 \
protobuf-2.27.1 \
protobuf-codegen-2.27.1 \
protobuf-codegen-pure-2.27.1 \
psl-types-2.0.10 \
publicsuffix-2.1.1 \
quote-1.0.10 \
rand-0.8.4 \
quote-1.0.16 \
rand-0.8.5 \
rand_chacha-0.3.1 \
rand_core-0.6.3 \
rand_distr-0.4.2 \
rand_hc-0.3.1 \
redox_syscall-0.1.57 \
redox_syscall-0.2.10 \
rand_distr-0.4.3 \
redox_syscall-0.2.11 \
redox_termios-0.1.2 \
redox_users-0.3.5 \
redox_users-0.4.0 \
regex-1.5.4 \
redox_users-0.4.2 \
regex-1.5.5 \
regex-syntax-0.6.25 \
remove_dir_all-0.5.3 \
reqwest-0.11.7 \
reqwest-0.11.10 \
ring-0.16.20 \
rodio-0.14.0 \
rspotify-0.11.3 \
rspotify-http-0.11.3 \
rspotify-macros-0.11.3 \
rspotify-model-0.11.3 \
rust-argon2-0.8.3 \
rustc-demangle-0.1.21 \
rspotify-0.11.4 \
rspotify-http-0.11.4 \
rspotify-macros-0.11.4 \
rspotify-model-0.11.4 \
rustc-hash-1.1.0 \
rustc-serialize-0.3.24 \
rustc_version-0.2.3 \
rustc_version-0.4.0 \
rustls-0.20.2 \
rustls-0.20.4 \
rustversion-1.0.6 \
ryu-1.0.6 \
ryu-1.0.9 \
same-file-1.0.6 \
schannel-0.1.19 \
scoped-tls-1.0.0 \
scopeguard-1.1.0 \
sct-0.7.0 \
security-framework-2.4.2 \
security-framework-sys-2.4.2 \
security-framework-2.6.1 \
security-framework-sys-2.6.1 \
semver-0.9.0 \
semver-1.0.4 \
semver-1.0.6 \
semver-parser-0.7.0 \
serde-1.0.131 \
serde-1.0.136 \
serde_cbor-0.11.2 \
serde_derive-1.0.131 \
serde_json-1.0.72 \
serde_repr-0.1.7 \
serde_urlencoded-0.7.0 \
serde_derive-1.0.136 \
serde_json-1.0.79 \
serde_urlencoded-0.7.1 \
sha-1-0.9.8 \
sha1-0.6.0 \
sha2-0.9.8 \
sha-1-0.10.0 \
sha1-0.6.1 \
sha1_smol-1.0.0 \
sha2-0.10.2 \
shannon-0.2.0 \
shell-words-1.0.0 \
shell-words-1.1.0 \
shlex-0.1.1 \
signal-hook-0.3.12 \
signal-hook-0.3.13 \
signal-hook-registry-1.4.0 \
slab-0.4.5 \
smallvec-1.7.0 \
socket2-0.4.2 \
smallvec-1.8.0 \
socket2-0.4.4 \
spin-0.5.2 \
stable_deref_trait-1.2.0 \
standback-0.2.17 \
static_assertions-1.1.0 \
stderrlog-0.4.3 \
stdweb-0.1.3 \
stdweb-0.4.20 \
stdweb-derive-0.5.3 \
stdweb-internal-macros-0.2.9 \
stdweb-internal-runtime-0.1.5 \
strsim-0.8.0 \
strsim-0.9.3 \
structopt-0.3.25 \
structopt-derive-0.4.18 \
strsim-0.10.0 \
strum-0.22.0 \
strum-0.23.0 \
strum-0.24.0 \
strum_macros-0.22.0 \
strum_macros-0.23.1 \
strum_macros-0.24.0 \
subtle-2.4.1 \
syn-1.0.82 \
syn-1.0.89 \
synstructure-0.12.6 \
tempfile-3.2.0 \
tempfile-3.3.0 \
term_size-0.3.2 \
termcolor-1.1.2 \
termcolor-1.1.3 \
termion-1.5.6 \
textwrap-0.11.0 \
textwrap-0.15.0 \
thiserror-1.0.30 \
thiserror-impl-1.0.30 \
thread_local-0.3.4 \
time-0.1.44 \
time-0.2.27 \
time-0.3.9 \
time-macros-0.1.1 \
time-macros-impl-0.1.2 \
tinyvec-1.5.1 \
tinyvec_macros-0.1.0 \
tokio-1.14.0 \
tokio-macros-1.6.0 \
tokio-1.17.0 \
tokio-macros-1.7.0 \
tokio-native-tls-0.3.0 \
tokio-stream-0.1.8 \
tokio-util-0.6.9 \
toml-0.5.8 \
tower-service-0.3.1 \
tracing-0.1.29 \
tracing-core-0.1.21 \
tree_magic-0.2.3 \
tracing-0.1.32 \
tracing-core-0.1.23 \
tree_magic_mini-3.0.3 \
try-lock-0.2.3 \
typenum-1.14.0 \
unicase-2.6.0 \
typenum-1.15.0 \
unicode-bidi-0.3.7 \
unicode-normalization-0.1.19 \
unicode-segmentation-1.8.0 \
unicode-segmentation-1.9.0 \
unicode-width-0.1.9 \
unicode-xid-0.2.2 \
unreachable-1.0.0 \
untrusted-0.7.1 \
ureq-2.3.1 \
ureq-2.4.0 \
url-2.2.2 \
uuid-0.8.2 \
vcpkg-0.2.15 \
vec_map-0.8.2 \
vergen-3.2.0 \
version_check-0.9.3 \
void-1.0.2 \
waker-fn-1.1.0 \
version_check-0.9.4 \
walkdir-2.3.2 \
want-0.3.0 \
wasi-0.9.0+wasi-snapshot-preview1 \
wasi-0.10.0+wasi-snapshot-preview1 \
wasm-bindgen-0.2.78 \
wasm-bindgen-backend-0.2.78 \
wasm-bindgen-futures-0.4.28 \
wasm-bindgen-macro-0.2.78 \
wasm-bindgen-macro-support-0.2.78 \
wasm-bindgen-shared-0.2.78 \
wasmer_enumset-1.0.1 \
wasmer_enumset_derive-0.5.0 \
wayland-client-0.27.0 \
wayland-commons-0.27.0 \
wayland-protocols-0.27.0 \
wayland-scanner-0.27.0 \
wayland-sys-0.27.0 \
web-sys-0.3.55 \
webbrowser-0.5.5 \
wasi-0.11.0+wasi-snapshot-preview1 \
wasm-bindgen-0.2.79 \
wasm-bindgen-backend-0.2.79 \
wasm-bindgen-futures-0.4.29 \
wasm-bindgen-macro-0.2.79 \
wasm-bindgen-macro-support-0.2.79 \
wasm-bindgen-shared-0.2.79 \
wayland-client-0.29.4 \
wayland-commons-0.29.4 \
wayland-protocols-0.29.4 \
wayland-scanner-0.29.4 \
wayland-sys-0.29.4 \
web-sys-0.3.56 \
webbrowser-0.6.0 \
webpki-0.22.0 \
webpki-roots-0.22.1 \
wepoll-ffi-0.1.2 \
widestring-0.4.3 \
webpki-roots-0.22.2 \
widestring-0.5.1 \
winapi-0.3.9 \
winapi-i686-pc-windows-gnu-0.4.0 \
winapi-util-0.1.5 \
@ -410,19 +369,15 @@ CARGO_CRATES= addr2line-0.17.0 \
windows_x86_64_gnu-0.24.0 \
windows_x86_64_msvc-0.24.0 \
winreg-0.5.1 \
winreg-0.7.0 \
winrt-notification-0.5.0 \
wl-clipboard-rs-0.4.1 \
winreg-0.10.1 \
winrt-notification-0.5.1 \
wl-clipboard-rs-0.6.0 \
x11-clipboard-0.3.3 \
xcb-0.8.2 \
xi-unicode-0.3.0 \
xml-rs-0.8.4 \
zbus-1.9.1 \
zbus_macros-1.9.1 \
zerocopy-0.3.0 \
zerocopy-derive-0.2.0 \
zvariant-2.10.0 \
zvariant_derive-2.10.0
zerocopy-derive-0.2.0
CARGO_FEATURES= --no-default-features cursive/pancurses-backend

File diff suppressed because it is too large Load diff

View file

@ -1,226 +0,0 @@
https://gitlab.freedesktop.org/dbus/zbus/-/commit/01d8f0ec41d3
https://gitlab.freedesktop.org/dbus/zbus/-/commit/807909a6c7bf
https://gitlab.freedesktop.org/dbus/zbus/-/commit/e3e2f7ddfd6e
https://gitlab.freedesktop.org/dbus/zbus/-/commit/35d1b8778754
--- cargo-crates/zbus-1.9.1/Cargo.toml.orig 1970-01-01 00:00:00 UTC
+++ cargo-crates/zbus-1.9.1/Cargo.toml
@@ -48,7 +48,7 @@ version = "0.3.8"
version = "1.0.2"
[dependencies.nix]
-version = "^0.17"
+version = "0.20.0"
[dependencies.once_cell]
version = "1.4.0"
--- cargo-crates/zbus-1.9.1/src/address.rs.orig 1970-01-01 00:00:00 UTC
+++ cargo-crates/zbus-1.9.1/src/address.rs
@@ -55,8 +55,9 @@ impl Address {
match env::var("DBUS_SESSION_BUS_ADDRESS") {
Ok(val) => Self::from_str(&val),
_ => {
- let uid = Uid::current();
- let path = format!("unix:path=/run/user/{}/bus", uid);
+ let runtime_dir = env::var("XDG_RUNTIME_DIR")
+ .unwrap_or_else(|_| format!("/run/user/{}", Uid::current()));
+ let path = format!("unix:path={}/bus", runtime_dir);
Self::from_str(&path)
}
--- cargo-crates/zbus-1.9.1/src/azync/connection.rs.orig 1970-01-01 00:00:00 UTC
+++ cargo-crates/zbus-1.9.1/src/azync/connection.rs
@@ -177,13 +177,29 @@ where
/// Upon successful return, the connection is fully established and negotiated: D-Bus messages
/// can be sent and received.
pub async fn new_server(stream: S, guid: &Guid) -> Result<Self> {
- use nix::sys::socket::{getsockopt, sockopt::PeerCredentials};
+ #[cfg(any(target_os = "android", target_os = "linux"))]
+ let client_uid = {
+ use nix::sys::socket::{getsockopt, sockopt::PeerCredentials};
- // FIXME: Could and should this be async?
- let creds = getsockopt(stream.as_raw_fd(), PeerCredentials)
- .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?;
+ let creds = getsockopt(stream.as_raw_fd(), PeerCredentials)
+ .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?;
- let auth = Authenticated::server(Async::new(stream)?, guid.clone(), creds.uid()).await?;
+ creds.uid()
+ };
+ #[cfg(any(
+ target_os = "macos",
+ target_os = "ios",
+ target_os = "freebsd",
+ target_os = "dragonfly",
+ target_os = "openbsd",
+ target_os = "netbsd"
+ ))]
+ let client_uid = nix::unistd::getpeereid(stream.as_raw_fd())
+ .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?
+ .0
+ .into();
+
+ let auth = Authenticated::server(Async::new(stream)?, guid.clone(), client_uid).await?;
Ok(Self::new_authenticated(auth))
}
--- cargo-crates/zbus-1.9.1/src/connection.rs.orig 1970-01-01 00:00:00 UTC
+++ cargo-crates/zbus-1.9.1/src/connection.rs
@@ -160,12 +160,29 @@ impl Connection {
/// Upon successful return, the connection is fully established and negotiated: D-Bus messages
/// can be sent and received.
pub fn new_unix_server(stream: UnixStream, guid: &Guid) -> Result<Self> {
- use nix::sys::socket::{getsockopt, sockopt::PeerCredentials};
+ #[cfg(any(target_os = "android", target_os = "linux"))]
+ let client_uid = {
+ use nix::sys::socket::{getsockopt, sockopt::PeerCredentials};
- let creds = getsockopt(stream.as_raw_fd(), PeerCredentials)
- .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?;
+ let creds = getsockopt(stream.as_raw_fd(), PeerCredentials)
+ .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?;
- let handshake = ServerHandshake::new(stream, guid.clone(), creds.uid());
+ creds.uid()
+ };
+ #[cfg(any(
+ target_os = "macos",
+ target_os = "ios",
+ target_os = "freebsd",
+ target_os = "dragonfly",
+ target_os = "openbsd",
+ target_os = "netbsd"
+ ))]
+ let client_uid = nix::unistd::getpeereid(stream.as_raw_fd())
+ .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?
+ .0
+ .into();
+
+ let handshake = ServerHandshake::new(stream, guid.clone(), client_uid);
handshake
.blocking_finish()
.map(Connection::new_authenticated_unix)
--- cargo-crates/zbus-1.9.1/src/handshake.rs.orig 1970-01-01 00:00:00 UTC
+++ cargo-crates/zbus-1.9.1/src/handshake.rs
@@ -124,7 +124,7 @@ impl<S: Socket> ClientHandshake<S> {
fn flush_buffer(&mut self) -> Result<()> {
while !self.buffer.is_empty() {
- let written = self.socket.sendmsg(&self.buffer, &[])?;
+ let written = self.socket.sendmsg(&self.buffer, &[], false)?;
self.buffer.drain(..written);
}
Ok(())
@@ -182,6 +182,15 @@ impl<S: Socket> Handshake<S> for ClientHandshake<S> {
self.step = ClientHandshakeStep::SendingOauth;
}
ClientHandshakeStep::SendingOauth => {
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+ {
+ let zero = self.buffer.drain(..1).next().unwrap();
+ if self.socket.sendmsg(&[zero], &[], true)? != 1 {
+ return Err(Error::Handshake(
+ "Could not send zero byte with credentials".to_string(),
+ ));
+ }
+ }
self.flush_buffer()?;
self.step = ClientHandshakeStep::WaitOauth;
}
@@ -385,7 +394,7 @@ impl<S: Socket> ServerHandshake<S> {
fn flush_buffer(&mut self) -> Result<()> {
while !self.buffer.is_empty() {
- let written = self.socket.sendmsg(&self.buffer, &[])?;
+ let written = self.socket.sendmsg(&self.buffer, &[], false)?;
self.buffer.drain(..written);
}
Ok(())
--- cargo-crates/zbus-1.9.1/src/raw/connection.rs.orig 1970-01-01 00:00:00 UTC
+++ cargo-crates/zbus-1.9.1/src/raw/connection.rs
@@ -47,7 +47,7 @@ impl<S: Socket> Connection<S> {
// VecDeque should never return an empty front buffer if the VecDeque
// itself is not empty
debug_assert!(!front.is_empty());
- let written = self.socket.sendmsg(front, &[])?;
+ let written = self.socket.sendmsg(front, &[], false)?;
self.raw_out_buffer.drain(..written);
}
@@ -55,14 +55,14 @@ impl<S: Socket> Connection<S> {
while let Some(msg) = self.msg_out_buffer.front() {
let mut data = msg.as_bytes();
let fds = msg.fds();
- let written = self.socket.sendmsg(data, &fds)?;
+ let written = self.socket.sendmsg(data, &fds, false)?;
// at least some part of the message has been sent, see if we can/need to send more
// now the message must be removed from msg_out_buffer and any leftover bytes
// must be stored into raw_out_buffer
let msg = self.msg_out_buffer.pop_front().unwrap();
data = &msg.as_bytes()[written..];
while !data.is_empty() {
- match self.socket.sendmsg(data, &[]) {
+ match self.socket.sendmsg(data, &[], false) {
Ok(n) => data = &data[n..],
Err(e) => {
// an error occured, we cannot send more, store the remaining into
--- cargo-crates/zbus-1.9.1/src/raw/socket.rs.orig 1970-01-01 00:00:00 UTC
+++ cargo-crates/zbus-1.9.1/src/raw/socket.rs
@@ -47,7 +47,7 @@ pub trait Socket {
///
/// If the underlying transport does not support transmitting file descriptors, this
/// will return `Err(ErrorKind::InvalidInput)`.
- fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd]) -> io::Result<usize>;
+ fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd], creds: bool) -> io::Result<usize>;
/// Close the socket.
///
@@ -74,6 +74,10 @@ impl Socket for UnixStream {
Ok(msg) => {
let mut fds = vec![];
for cmsg in msg.cmsgs() {
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+ if let ControlMessageOwned::ScmCreds(_) = cmsg {
+ continue;
+ }
if let ControlMessageOwned::ScmRights(fd) = cmsg {
fds.extend(fd.iter().map(|&f| unsafe { OwnedFd::from_raw_fd(f) }));
} else {
@@ -90,12 +94,23 @@ impl Socket for UnixStream {
}
}
- fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd]) -> io::Result<usize> {
- let cmsg = if !fds.is_empty() {
+ fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd], creds: bool) -> io::Result<usize> {
+ let mut cmsg = if !fds.is_empty() {
vec![ControlMessage::ScmRights(fds)]
} else {
vec![]
};
+ #[cfg(any(target_os = "android", target_os = "linux"))]
+ let unix_creds;
+ if creds {
+ #[cfg(any(target_os = "android", target_os = "linux"))]
+ {
+ unix_creds = Some(nix::sys::socket::UnixCredentials::new());
+ cmsg.push(ControlMessage::ScmCredentials(unix_creds.as_ref().unwrap()));
+ }
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+ cmsg.push(ControlMessage::ScmCreds);
+ }
let iov = [IoVec::from_slice(buffer)];
match sendmsg(self.as_raw_fd(), &iov, &cmsg, MsgFlags::empty(), None) {
// can it really happen?
@@ -124,8 +139,8 @@ where
self.get_mut().recvmsg(buffer)
}
- fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd]) -> io::Result<usize> {
- self.get_mut().sendmsg(buffer, fds)
+ fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd], creds: bool) -> io::Result<usize> {
+ self.get_mut().sendmsg(buffer, fds, creds)
}
fn close(&self) -> io::Result<()> {