Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Implement safe sendmsg/recvmsg abstractions #16

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Implement safe sendmsg/recvmsg abstractions #16

wants to merge 5 commits into from

Conversation

teisenbe
Copy link

@teisenbe teisenbe commented Sep 8, 2015

Supports SCM_CREDENTIALS and SCM_RIGHTS control messages

Resolves #4 and resolves #5

Todd Eisenberger added 2 commits September 7, 2015 18:56
Supports SCM_CREDENTIALS and SCM_RIGHTS control messages
@elmarco
Copy link

elmarco commented Sep 16, 2015

thank you!

@@ -8,11 +8,16 @@ repository = "https://github.com/sfackler/rust-unix-socket"
documentation = "https://sfackler.github.io/rust-unix-socket/doc/v0.4.5/unix_socket"
readme = "README.md"
keywords = ["posix", "unix", "socket", "domain"]
links = "cmsg_manip"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessary - it's only needed when linking to third party stuff.

@sfackler
Copy link
Member

Thanks for doing this! I left some comments here and there. Also, this'll need to be put behind a feature since these are Linux-only APIs I believe.

I'm not totally sure what the API for sendmsg and recvmsg should look like, but it seems like we can do better than a raw c_int of flags.

@teisenbe
Copy link
Author

I think all of the flags are potentially applicable and usable with this API. If you want, I can replace the c_int with a struct of bools to make it a bit more friendly? Can also take it out completely, but I think the options flags provides and the data it returns are genuinely useful. Will probably work to address comments today

@sfackler
Copy link
Member

Oh yeah, the options flags are definitely useful, I'd just prefer something more structured than a raw c_int. A struct with bool setters/getters seems reasonable to me.

@teisenbe
Copy link
Author

Take a look at the latest version of the pull request. Replaced it with the struct as requested

@geofft
Copy link

geofft commented Oct 8, 2015

I just saw this -- I have a PR for a pure-Rust implementation of this (just SCM_RIGHTS, but SCM_CREDENTIALS would be easy to add) in nix-rust/nix#179 (now nix-rust/nix#197). We should potentially make sure our APIs are in sync, and maybe it makes sense to share implementation, too.

@@ -771,6 +802,46 @@ impl UnixDatagram {
}
}

/// Receives data on the socket.
///
/// If path is None, the peer address set by the `connect` method will be used. If it has not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path doesn't appear to be a parameter here anymore.

@teisenbe
Copy link
Author

Finally got around to addressing the comments

///
/// This is a Rust version of `struct ucred` from sys/socket.h
#[derive(Clone, Debug)]
pub struct UCred{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct ucred now exists in libc, from version 0.2.3: rust-lang/libc@4920c7e :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support credential transfer Support file descriptor transfer
5 participants