luci/libs/nixio/src
Jo-Philipp Wich ca7bc48ebc [PATCH] Abstract address UNIX sockets not binding properly (by capnbry@gmail.com, #366)
In #274, I stated abstract namespace and autobound abstract namespace datagram UNIX domain sockets work perfectly with nixio. However, I may have jumped the gun on that conclusion. Turns out they work perfectly for only one 
concurrent connection.

The problem is that when binding to an abstract address socket, which begins with a NULL byte, nixio strncpy's the name into the sockaddr_un structure, which effectively copies nothing. It then binds to an address of 180 NULLs, 
which is completely legal, but obviously you run into problems when a second client tries to bind to the same address.

The rules are as follows ( http://linux.die.net/man/7/unix) for the names:

  * If the name is blank, bind() should pass that the addrlen of sizeof(sa_family_t) and Linux will autobind a name that begins with null and is followed by 5 digits.
  * If the first character of the name is non-null, the name is a pathname and is null-terminated. addrlen should be sizeof(sockaddr_un), but the length can also be the pathname len + sizeof(sa_family_t) as the value will be 
null-terminated by the kernel unix socket driver
  * If the first character is null, the address is abstract and the value should not be null-terminated and addrlen is pathname + sizeof(sa_family_t) 

The attached patch fixes bind/connect/sendto by shortening the addrlen passed to be pathname len + sizeof(sa_family_t), which generates the correct socket names for all 3 cases above.
It also fixes the address returned by recvfrom, which currently returns a blank string for any abstract address socket (as they begin with a null).
2011-12-16 02:10:37 +00:00
..
address.c libs/nixio: add missing file in previous commit, revert unrelated change 2011-08-12 10:27:48 +00:00
axtls-compat.c Merge nixio 0.2 2009-04-21 16:26:45 +00:00
axtls-compat.h nixio: Add support for DER keyfiles 2009-06-06 13:03:31 +00:00
binary.c nixio: store stats and other number information as integer, which works better when lua number support is downgraded from double to float 2009-10-26 04:52:07 +00:00
bind.c [PATCH] Abstract address UNIX sockets not binding properly (by capnbry@gmail.com, #366) 2011-12-16 02:10:37 +00:00
bit.c nixio: Improve number handling with non-double Lua setups 2009-11-28 10:24:19 +00:00
cyassl-compat.c nixio: Rework TLS support, added support for CyaSSL 2009-05-28 13:50:00 +00:00
cyassl-compat.h nixio: Rework TLS support, added support for CyaSSL 2009-05-28 13:50:00 +00:00
file.c nixio: Improve number handling with non-double Lua setups 2009-11-28 10:24:19 +00:00
fs.c nixio: Improve number handling with non-double Lua setups 2009-11-28 10:24:19 +00:00
io.c [PATCH] Abstract address UNIX sockets not binding properly (by capnbry@gmail.com, #366) 2011-12-16 02:10:37 +00:00
mingw-compat.c Merge nixio 0.2 2009-04-21 16:26:45 +00:00
mingw-compat.h Merge nixio 0.2 2009-04-21 16:26:45 +00:00
nixio-tls.h Merge nixio 0.2 2009-04-21 16:26:45 +00:00
nixio.c libs/nixio: implement getproto(), getprotobyname() and getprotobynumber() 2011-08-12 10:26:33 +00:00
nixio.h libs/nixio: implement getproto(), getprotobyname() and getprotobynumber() 2011-08-12 10:26:33 +00:00
poll.c nixio: Add nixio.gettimeofday() per user request 2010-05-23 16:35:59 +00:00
process.c nixio: Improve number handling with non-double Lua setups 2009-11-28 10:24:19 +00:00
protoent.c libs/nixio: add missing file in previous commit, revert unrelated change 2011-08-12 10:27:48 +00:00
socket.c Merge nixio 0.2 2009-04-21 16:26:45 +00:00
sockopt.c nixio: store stats and other number information as integer, which works better when lua number support is downgraded from double to float 2009-10-26 04:52:07 +00:00
splice.c libs/nixio: fix uninitialized variable warning on Darwin in splice.c 2009-12-29 17:55:10 +00:00
syslog.c Merge nixio 0.2 2009-04-21 16:26:45 +00:00
tls-context.c nixio: Add set_verify_locations for TLS 2010-06-10 07:46:36 +00:00
tls-crypto.c nixio: Rework TLS support, added support for CyaSSL 2009-05-28 13:50:00 +00:00
tls-socket.c Merge nixio 0.2 2009-04-21 16:26:45 +00:00
user.c libs/nixio: allow building without shadow password support 2011-08-11 23:21:06 +00:00