inejge / ldap3

A pure-Rust LDAP library using the Tokio stack
Apache License 2.0
226 stars 39 forks source link

Bind hanging after an Unbind #41

Closed Geobert closed 4 years ago

Geobert commented 4 years ago

Hi there!

I've notice an issue when calling a bind after an unbind: bind hang forever :-/

Is that has to do with the caveats disclaimed in the readme?

Unbind doesn't close our side of the connection, since the underlying TCP stream is inaccessible in the present implementation.

If so, what would be the workaround/fix? Migrating to Tokio 0.2? (which is a big work, I know).

inejge commented 4 years ago

There can be no workaround, since Unbind is meant to terminate the session: see the specification, which also comments that "Unbind [..] is not the antithesis of the Bind operation as the name implies".

Geobert commented 4 years ago

And the "session" is bound to the LdapConn? Because what I've done is when unbind is called, I create a brand new LdapConn otherwise nothing goes through. But I need to test with 0.7 now :)

inejge commented 4 years ago

Right, LdapConn is unusable after Unbind. Perhaps I should make the unbind() method take self to enforce this through the type system.

Geobert commented 4 years ago

I don't know if it's still the case in 0.7 though

inejge commented 4 years ago

Try this with 0.7, pointing it at a known-to-work server:

use ldap3::LdapConn;
use ldap3::result::Result;

fn main() -> Result<()> {
    let mut ldap = LdapConn::new("ldap://localhost:2389")?;
    ldap.unbind()?;
    // trying to use the connection after Unbind
    Ok(ldap.unbind()?)
}

You'll get

Error: ResultRecv { source: RecvError(()) }

So the connection is properly unusable and doesn't hang.

Geobert commented 4 years ago

Cheers for your test :) I was planning to upgrade our internal tool asap, but I'm on another task right now :)