kern/72920: [linux]: path "prefixing" is not done on unix domain socket addresses

Andriy Gapon avg at icyb.net.ua
Fri Dec 30 02:42:28 PST 2005


On Thu, 29 Dec 2005, Alexander Leidinger wrote:

> Does this problem still persists on a recent FreeBSD?

I can confirm that the problem still exists on FreeBSD 5.4 and looking at 
linux_socket.c differences between 5.4 and HEAD I am sure that the problem 
exists in all releases/branches:
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/compat/linux/linux_socket.c.diff?r1=1.51.2.3&r2=1.62&f=h

I am attaching a simple test program, so that anyone interested could 
easily verify the issue.
Prerequisites for the test are:
/compat/linux/tmp must exist
/tmp/foo must not exist
/compat/linux/tmp/foo must not exist
Usage of ktrace is also advised for additional insights.

/************ lin_un_sock.c *********/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>

#include <stdio.h>
#include <errno.h>

int main()
{
 	struct sockaddr_un addr;
 	int s;
 	int err;

 	/*this will create /compat/linux/tmp/foo/ directory*/
 	err = mkdir("/tmp/foo", 0777);
 	if(err < 0) {
 		perror("mkdir");
 		return 1;
 	}

 	s = socket(PF_LOCAL, SOCK_STREAM, 0);
 	if(s < 0) {
 		perror("socket");
 		return 1;
 	}

 	strcpy(addr.sun_path, "/tmp/foo/bar");
 	addr.sun_family = AF_LOCAL;

 	/*this will try to bind socket in /tmp/foo/ directory
 	 *which does not exist
 	 */
 	err = bind(s, (struct sockaddr *) &addr, SUN_LEN(&addr));
 	if(err < 0) {
 		perror("bind");
 		return 1;
 	}

 	return 0;
}
/******************************/

-- 
Andriy Gapon


More information about the freebsd-emulation mailing list