Support for Linux Abstract Namespaces?

Currently std::os::unix::net::UnixListener does not seem to support the Linux Abstract Namespace. I'm not familiar with the process of a feature request in the standard library so I haven't made a issue in the github repo yet.

Reproduce with:

fn main() {
    let addr_name = "\0/tmp/app.uniq.sock";

    match std::os::unix::net::UnixListener::bind(addr_name) {
        Ok(_) => {
            println!("Unique instance");
            loop {}
        }
        Err(e) => {
            match e.kind()  {
                std::io::ErrorKind::AddrInUse => {
                    println!("Duplicate instance");
                }
                _ => {
                    panic!("{:?}", e);
                }
            }
        }
    }
}

Compiler message:

$ cargo run
Compiling events v0.1.0 (/home/user0/proj/events)
Finished dev [unoptimized + debuginfo] target(s) in 0.18s
Running target/debug/events
thread 'main' panicked at 'Custom { kind: InvalidInput, error: "paths may not contain interior null bytes" }', src
/main.rs:15:21
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.

I believe Rust has the capability to allow interior null bytes in Linux with conditional compilation. And there are already a number of Linux-specific code in the standard. Currently the nix already crate supports this.

If you want this you should file an issue to the Rust issue tracker.

On the other hand, I am not sure whether this belongs in the Rust standard library. Linux manpage unix(7) says "The abstract socket namespace is a nonportable Linux extension". I think such things belong in nix crate.

1 Like

I'm sorry I don't think I can agree to that, whether the abstract namespace is supported in the target Linux platform is up for the users, what std is doing is going out of its way to prevent the user from using a well recognized feature that many other languages already allow (Go, Python, D etc). I'm not even sure what versions of Linux actually does not support this, but it's certainly well known enough for Python/Go to allow this by default.

But yes, I'd love to discuss all points of view.

The unix-socket library supports abstract namespaces:

I'm not familiar with the process of a feature request in the standard library

There’s RFC 1479 which discusses that feature:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.