[erlang-questions] unix domain sockets with abstract namespace: can't use all 108 bytes
Raimo Niskanen
raimo+erlang-questions@REDACTED
Fri May 12 15:05:20 CEST 2017
On Thu, May 11, 2017 at 05:02:54PM +0200, Raimo Niskanen wrote:
> On Tue, May 02, 2017 at 01:33:45PM +0200, Raimo Niskanen wrote:
> > On Tue, May 02, 2017 at 09:44:35AM +1200, Richard A. O'Keefe wrote:
> > >
> > > > On 29/04/2017, at 12:28 AM, Raimo Niskanen <raimo+erlang-questions@REDACTED> wrote:
> > > >
> > > > It is difficult to reliably detect the other direction i.e in the driver
> > > > when you get an address from e.g getsockname(); is it an empty string or an
> > > > abstract address?
> > >
> > > Surely an empty string would never have been legal,
> > > so if the first byte is NUL and the host supports abstract
> > > addresses, it must be an abstract address?
> > >
> >
> > If the first byte is NUL and the length is larger than 0 then it must be an
> > abstract address. But when this comes from above (from Erlang) and since
> > we do not know if the host supports abstract addresses; if we give
> > the kernel a first byte NUL but address length longer than SUN_LEN(su),
> > will then we cause harm on some OS?
> >
> > I will assume not and rewrite the code, soonish...
>
> I now have a solution that looks at .sun_len if it exists, otherwise trusts
> the leading zero.
I was wrong. .sun_len says the same as the argument size parameter so that
was a dead end.
>
> That works on all platforms but Solaris since it has no .sun_len and when
> I get an address from e.g getsockname() on an unbound socket it is all 0's
> and the *lenght parameter from getsockname() is unaltered, so that has to
> be translated to 108 zeros. My code on all other platforms (OpenBSD,
> FreeBSD, Linux, Mac OS X) detect this as a zero length address...
>
> I need a way to fix this on Solaris!
Now also on FreeBSD and OpenBSD...
>
> Any ideas?
> --
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list