luci/libs/nixio
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
..
axTLS nixio: Fix axTLS configuration, prepare px5g integration 2009-06-06 20:34:33 +00:00
axtls-config Revert "adjust axtls level" 2009-06-07 12:38:37 +00:00
axtls-root/etc/nixio nixio: Fix axTLS configuration, prepare px5g integration 2009-06-06 20:34:33 +00:00
docsrc libs/nixio: implement getproto(), getprotobyname() and getprotobynumber() 2011-08-12 10:26:33 +00:00
lua libs/nixio: make TLS support optional 2010-03-27 19:16:54 +00:00
root/lib/upgrade libs/nixio: remove forgotten stamp file 2011-10-24 21:39:47 +00:00
src [PATCH] Abstract address UNIX sockets not binding properly (by capnbry@gmail.com, #366) 2011-12-16 02:10:37 +00:00
.gitignore GSoC Commit #1: LuCId + HTTP-Server 2009-05-23 17:21:36 +00:00
LICENSE Merge nixio 0.2 2009-04-21 16:26:45 +00:00
Makefile libs/nixio: link with libcrypto when using OpenSSL as digest backend 2011-11-20 18:18:46 +00:00
nixio-0.3-1.rockspec nixio: 2009-07-14 15:21:00 +00:00
NOTICE Merge nixio 0.2 2009-04-21 16:26:45 +00:00
README Merge nixio 0.2 2009-04-21 16:26:45 +00:00
standalone.mk nixio: Update documentation to prepare 0.3 release 2009-07-11 07:54:57 +00:00

Building:
	Use GNU Make.
	make or gmake depending on your system.
	
	Special make flags:

	OS		Override Target OS	[Linux|FreeBSD|SunOS|Windows]
	NIXIO_TLS	TLS-Library		[*openssl|axtls]
	NIXIO_CROSS_CC	MinGW CC (Windows)	`which i586-mingw32msvc-cc`
	LUA_CFLAGS	Lua CFLAGS		`pkg-config --cflags lua5.1`
	LUA_TARGET	Lua compile		target	[*source|strip|compile]
	LUA_MODULEDIR	Install LUA_PATH	"/usr/share/lua/5.1"
	LUA_LIBRARYDIR	Install LUA_CPATH	"/usr/lib/lua/5.1"