Skip to content

Commit

Permalink
🛂 Drop support for DBUS_COOKIE_SHA1 auth mechanism
Browse files Browse the repository at this point in the history
This is in preparation for zbus dropping it in 5.0:

dbus2/zbus#1039

Besides, I added this support mainly for hopes of possibly using it for
a remote transport. However, due to lack of time and funding, I decided
to drop those plans from the roadmap.
  • Loading branch information
zeenix committed Oct 3, 2024
1 parent 6ae240f commit bfff54c
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 330 deletions.
4 changes: 0 additions & 4 deletions src/bin/busd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ enum AuthMechanism {
/// transferred out-of-band, in particular Unix platforms that can perform credentials-passing
/// over UNIX domain sockets.
External,
/// This mechanism is designed to establish that a client has the ability to read a private
/// file owned by the user being authenticated.
Cookie,
/// Does not perform any authentication at all (not recommended).
Anonymous,
}
Expand All @@ -60,7 +57,6 @@ impl From<AuthMechanism> for zbus::AuthMechanism {
fn from(auth_mechanism: AuthMechanism) -> Self {
match auth_mechanism {
AuthMechanism::External => zbus::AuthMechanism::External,
AuthMechanism::Cookie => zbus::AuthMechanism::Cookie,
AuthMechanism::Anonymous => zbus::AuthMechanism::Anonymous,
}
}
Expand Down
289 changes: 0 additions & 289 deletions src/bus/cookies.rs

This file was deleted.

37 changes: 3 additions & 34 deletions src/bus/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
mod cookies;

use anyhow::{bail, Error, Ok, Result};
use futures_util::{
future::{select, Either},
pin_mut,
};
use anyhow::{bail, Ok, Result};
#[cfg(unix)]
use std::{env, path::Path};
use std::{str::FromStr, sync::Arc};
#[cfg(unix)]
use tokio::fs::remove_file;
use tokio::{spawn, task::JoinHandle};
use tokio::spawn;
use tracing::{debug, info, trace, warn};
#[cfg(unix)]
use zbus::address::transport::{Unix, UnixSocket};
Expand All @@ -30,7 +24,6 @@ use crate::{
pub struct Bus {
inner: Inner,
listener: Listener,
cookie_task: Option<JoinHandle<Error>>,
}

// All (cheaply) cloneable fields of `Bus` go here.
Expand Down Expand Up @@ -99,18 +92,8 @@ impl Bus {
peers.add_us(peer_conn).await;
trace!("Self-dial connection created.");

let cookie_task = if auth_mechanism == AuthMechanism::Cookie {
let (cookie_task, cookie_sync_rx) = cookies::run_sync();
cookie_sync_rx.await?;

Some(cookie_task)
} else {
None
};

Ok(Self {
listener,
cookie_task,
inner: Inner {
address,
peers,
Expand Down Expand Up @@ -201,21 +184,7 @@ impl Bus {
}

async fn accept_next(&mut self) -> Result<()> {
let task = self.cookie_task.take();

let (socket, task) = match task {
Some(task) => {
let accept_fut = self.accept();
pin_mut!(accept_fut);

match select(accept_fut, task).await {
Either::Left((socket, task)) => (socket?, Some(task)),
Either::Right((e, _)) => return Err(e?),
}
}
None => (self.accept().await?, None),
};
self.cookie_task = task;
let socket = self.accept().await?;

let id = self.next_id();
let inner = self.inner.clone();
Expand Down
1 change: 0 additions & 1 deletion tests/fdo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ async fn name_ownership_changes() {

// TCP socket
let address = "tcp:host=127.0.0.1,port=4242".to_string();
name_ownership_changes_(&address, AuthMechanism::Cookie).await;
name_ownership_changes_(&address, AuthMechanism::Anonymous).await;
}

Expand Down
1 change: 0 additions & 1 deletion tests/greet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ async fn greet() {

// TCP socket
let address = "tcp:host=127.0.0.1,port=4248".to_string();
greet_(&address, AuthMechanism::Cookie).await;
greet_(&address, AuthMechanism::Anonymous).await;
}

Expand Down
Loading

0 comments on commit bfff54c

Please sign in to comment.