Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERL-1201: cmsghdr data should accept structures/lists where acceptable #4356

Open
OTP-Maintainer opened this issue Mar 22, 2020 · 2 comments
Assignees
Labels

Comments

@OTP-Maintainer
Copy link

Original reporter: hauleth
Affected version: Not Specified
Component: kernel
Migrated from: https://bugs.erlang.org/browse/ERL-1201


Currently most of the possible {{cmsghdr}} entries accept only binary, this is problematic as there is no way to safely encode for example {{pid_t}} in Erlang that would be platform independent. So the proposal is to allow passing "meaningful" data to such structure, such types would be:
 * Map in form of {{#\{pid => integer(), uid => integer(), gid => integer()\}}} for {{credentials}} type
 * List in form of {{[integer()]}} in case of {{rights}}

I haven't found what is the expected data in case of {{timestamp}} type. Without such constructs it make usage of {{socket:sendmsg}} pretty impossible without using NIFs.
@OTP-Maintainer
Copy link
Author

hauleth said:

Ok, I have read a little bit about it and it is even a little bit more complex. In FreeBSD (and derivatives like macOS) it uses [different structure|https://github.com/freebsd/freebsd/blob/401e02f6005b2cbeb79c8a6ebaf412be79ff2775/tools/regression/sockets/unix_cmsg/t_cmsgcred.c#L43] (actually [two structs|https://github.com/freebsd/freebsd/blob/401e02f6005b2cbeb79c8a6ebaf412be79ff2775/tools/regression/sockets/unix_cmsg/t_sockcred.c#L43] depending on how the creds are sent) than [Linux|https://linux.die.net/man/7/unix]. So the only fields that are *guaranteed to be present* on both are {{uid}} and {{gid}}. I have no idea how to solve sending part, on receiving end we can just check which one is the arriving and decode respectively.

@OTP-Maintainer
Copy link
Author

bmk said:

Yes, and OpenBSD and NetBSD has also different structures.

 

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

No branches or pull requests

2 participants