dbus2 / zbus-old

Rust D-Bus crate.
https://gitlab.freedesktop.org/dbus/zbus
Other
49 stars 13 forks source link

ObjectServer::request_name doesn't fail if name already claimed on bus #209

Closed zeenix closed 1 year ago

zeenix commented 3 years ago

In GitLab by @swsnr on Sep 4, 2021, 14:07

According to its ObjectServer::request_name requests exclusive access to the name, so I'd expect it to fail if the requested name is already taken.

However it doesn't fail because it never actually checks the reply from the broker, and since it also doesn't return the RequestNameReply I can't even check myself.

Is this intended?

zeenix commented 3 years ago

In GitLab by @swsnr on Sep 4, 2021, 14:10

PS: Out of curiosity why does zbus use ReplaceExisting as flag in addition to DoNotQueue? Shouldn't the latter be sufficient to ensure exclusive access?

zeenix commented 3 years ago

According to its ObjectServer::request_name requests exclusive access to the name, so I'd expect it to fail if the requested name is already taken.

Indeed, that should be the case so this is a bug.

zeenix commented 3 years ago

DoNotQueue says to the bus that if the name is already taken, don't bother waiting but rather just fail. ReplaceExisting will only be able to replace an existing owner if that owner has specified AllowReplacement flag. Probably it could be argued that ReplaceExisting as a default is not a great idea but given that most services don't specify AllowReplacement, in practice this flag doesn't do much in most cases.

zeenix commented 2 years ago

mentioned in commit 85f215dbd05e20b31c4f892b3c993bc8f5c5bae8