diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2018-02-26 19:58:46 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2018-02-26 19:58:46 +0300 |
commit | 4d75035244042e478626ac0e124bd314a8fe9864 (patch) | |
tree | cee92ef1e4fa557398ab681d3345c5544ae1f1b9 | |
parent | d35bd22992cc08d5c04ff822959bacd863abf41b (diff) |
Cygwin: fhandler_socket_unix: Tiny cleanup
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/fhandler_socket_unix.cc | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc index 1e4d33901..c539c00a1 100644 --- a/winsup/cygwin/fhandler_socket_unix.cc +++ b/winsup/cygwin/fhandler_socket_unix.cc @@ -32,33 +32,7 @@ #include "miscfuncs.h" #include "tls_pbuf.h" -extern "C" { - int sscanf (const char *, const char *, ...); -} /* End of "C" section */ -#define ASYNC_MASK (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT) -#define EVENT_MASK (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT|FD_CLOSE) - -#define LOCK_EVENTS \ - if (wsock_mtx && \ - WaitForSingleObject (wsock_mtx, INFINITE) != WAIT_FAILED) \ - { - -#define UNLOCK_EVENTS \ - ReleaseMutex (wsock_mtx); \ - } - -static inline mode_t -adjust_socket_file_mode (mode_t mode) -{ - /* Kludge: Don't allow to remove read bit on socket files for - user/group/other, if the accompanying write bit is set. It would - be nice to have exact permissions on a socket file, but it's - necessary that somebody able to access the socket can always read - the contents of the socket file to avoid spurious "permission - denied" messages. */ - return mode | ((mode & (S_IWUSR | S_IWGRP | S_IWOTH)) << 1); -} /* cygwin internal: map sockaddr into internet domain address */ static int __unused @@ -612,7 +586,7 @@ fhandler_socket_unix::ioctl (unsigned int cmd, void *p) int fhandler_socket_unix::fcntl (int cmd, intptr_t arg) { - int ret; + int ret = 0; switch (cmd) { @@ -630,7 +604,7 @@ fhandler_socket_unix::fcntl (int cmd, intptr_t arg) int __reg2 fhandler_socket_unix::fstat (struct stat *buf) { - int ret; + int ret = 0; if (!get_sun_path () || get_sun_path ()[0] == '\0') return fhandler_socket::fstat (buf); @@ -660,7 +634,14 @@ fhandler_socket_unix::fchmod (mode_t newmode) return fhandler_socket::fchmod (newmode); fhandler_disk_file fh (pc); fh.get_device () = FH_FS; - return fh.fchmod (S_IFSOCK | adjust_socket_file_mode (newmode)); + /* Kludge: Don't allow to remove read bit on socket files for + user/group/other, if the accompanying write bit is set. It would + be nice to have exact permissions on a socket file, but it's + necessary that somebody able to access the socket can always read + the contents of the socket file to avoid spurious "permission + denied" messages. */ + newmode |= (newmode & (S_IWUSR | S_IWGRP | S_IWOTH)) << 1; + return fh.fchmod (S_IFSOCK | newmode); } int |