[ovs-discuss] suspicious usage of fchmod

YAMAMOTO Takashi yamamoto at valinux.co.jp
Fri Apr 15 02:54:14 UTC 2011


hi,

fchown on a socket is not portable.

i don't think it makes sense even on linux.  (not confirmed)

YAMAMOTO Takashi


diff --git a/lib/socket-util.c b/lib/socket-util.c
index 12bbc71..2b75dee 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -349,7 +349,7 @@ make_unix_socket(int style, bool nonblock, bool passcred OVS_UNUSED,
 
         error = make_sockaddr_un(bind_path, &un, &un_len, &dirfd);
         if (!error && (bind(fd, (struct sockaddr*) &un, un_len)
-                       || fchmod(fd, S_IRWXU))) {
+                       || chmod(bind_path, S_IRWXU))) {
             error = errno;
         }
         if (dirfd >= 0) {



More information about the discuss mailing list