|
Description
|
struct sockaddr_un {
sa_family_t sun_family; /* AF_UNIX */
char sun_path[UNIX_PATH_MAX]; /* pathname */
};
From the "unix 7" man page on CentOS 3 (2002-12-02) Linux (kernel 2.4):
sun_family always contains AF_UNIX. sun_path contains the zero-termi-
nated pathname of the socket in the file system. If sun_path starts
with a zero byte it refers to the abstract namespace maintained by the
Unix protocol module. The socket's address in this namespace is given
by the rest of the bytes in sun_path. Note that names in the abstract
namespace are not zero-terminated.
Currently, lx_bind does not check the pathname for a leading NULL byte, but blindly
passes the sockaddr to bind.
I have not found any applications in CentOS 3 that use this functionality, but in CentOS 4 and greater, Gnome applications, such as Gnome panel use abstract namespace sockets to communicate with each other. Also Ubuntu init will fail to run without this functionality.
To emulate abstract namespace sockets, in the lx_bind function, I plan to modify paths that begin with a null charactor to point to files in the /tmp directory by prepending "/tmp/.ABSK_" to the specified path, and replacing all subsequent null character and "/" with "_". Since the overhead of creating and deleting files needs to be invisible to the caller, lx_bind will check to see if a socket with the same name exsists. If this is the case it will try to connect to it, to see if it is an active socket and return an error if this is the case. Otherwise it will remove the socket and create a new one.
|