]> git.proxmox.com Git - ovs.git/commit
socket-util: Properly set socket permissions in make_unix_socket().
authorBen Pfaff <blp@nicira.com>
Mon, 18 Apr 2011 18:24:50 +0000 (11:24 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 19 Apr 2011 18:26:01 +0000 (11:26 -0700)
commite2bd05933f2c813e1cce42b8fe0db6230dffb13c
tree44e98551209ebc3a015a9340df95170aadc2b1c8
parentabd4a95de3249e2beddcd921e981baa21cc6d7fd
socket-util: Properly set socket permissions in make_unix_socket().

Under Linux, at least, bind and fchmod interact for Unix sockets in a way
that surprised me.  Calling fchmod() on a Unix socket successfully sets the
permissions for the socket's own inode.  But that has no effect on any
inode that has already been created in the file system by bind(), because
that inode is not the same as the one for the Unix socket itself.

However, if you bind() *after* calling fchmod(), then the bind() takes the
permissions for the new inode from the Unix socket inode, which has the
desired effect.

This also adds a more portable fallback for non-Linux systems.

Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
lib/socket-util.c