[ovs-dev] [branch-1.1 27/34] socket-util: Use portable solution for setting Unix socket permissions.

Ben Pfaff blp at nicira.com
Fri Apr 29 21:56:58 UTC 2011


Requested-by: Jesse Gross <jesse at nicira.com>
---
 lib/socket-util.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/lib/socket-util.c b/lib/socket-util.c
index 7e4b8be..24e8f81 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -306,18 +306,11 @@ make_sockaddr_un(const char *name, struct sockaddr_un *un, socklen_t *un_len,
 static int
 bind_unix_socket(int fd, struct sockaddr *sun, socklen_t sun_len)
 {
-#ifdef __linux__
-    /* On Linux, calling fchmod() *before* bind() sets permissions for the file
-     * about to be created.  Calling fchmod() *after* bind has no effect on the
-     * file that was created.) */
-    return fchmod(fd, 0700) || bind(fd, sun, sun_len) ? errno : 0;
-#else
     /* According to _Unix Network Programming_, umask should affect bind(). */
     mode_t old_umask = umask(0077);
     int error = bind(fd, sun, sun_len) ? errno : 0;
     umask(old_umask);
     return error;
-#endif
 }
 
 /* Creates a Unix domain socket in the given 'style' (either SOCK_DGRAM or
-- 
1.7.4.4




More information about the dev mailing list