softprops / hyperlocal

🔌 ✨rustlang hyper bindings for local unix domain sockets
MIT License
229 stars 46 forks source link

Need to be able to chmod the socket #9

Closed njaard closed 6 years ago

njaard commented 6 years ago

After I call Http::bind(), I need to be able to chmod the file descriptor appropriately.

In theory, something like this:

let s = hyperlocal::server::Http::new()
  .bind(&address["unix:".len()..], new_service)?;
libc::fchmod(s.listener.as_raw_fd(), 0o777);

But this isn't possible because s.listener is not pub.

moosingin3space commented 6 years ago

Maybe a function Http::bind_with_permissions could be used to atomically bind and chmod?

njaard commented 6 years ago

POSIX doesn't offer an atomic "bind and chmod" for unix domain sockets, and I think a more generalized solution of "let me access the low level object" is warranted.

moosingin3space commented 6 years ago

Such as an as_raw_fd function on Server?

softprops commented 6 years ago

@moosingin3space @njaard I just published 0.5.0 which includes a change to expose this