While tracking down a PostgreSQL problem, I uncovered that chmod() appears to have no affect on AF_UNIX sockets on recent Cygwin versions.
The attached test case, afunix.cc, demonstrates the problem: $ # Cygwin 1.3.22-1 $ afunix $ ls -l /tmp/.afunix srwx------ 1 jt Domain U 0 Mar 19 15:57 /tmp/.afunix $ # Red Hat Linux 8.0 $ afunix $ ls -l /tmp/.afunix srwxrwxrwx 1 jt dev 0 Mar 19 17:13 /tmp/.afunix $ # Cygwin 1.3.18-1 $ afunix $ ls -l /tmp/.afunix srwxrwxrwx 1 jt Domain U 0 Mar 19 17:13 /tmp/.afunix Jason -- PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6
#include <stdio.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #include <sys/errno.h> #include <sys/stat.h> int main() { const char file[] = "/tmp/.afunix"; umask(0077); int status = unlink(file); if (status < 0 && errno != ENOENT) { printf("unlink() failed with %d\n", errno); return 1; } int fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) { printf("socket() failed with %d\n", errno); return 1; } struct sockaddr_un address; memset(&address, 0, sizeof(address)); address.sun_family = AF_UNIX; strcpy(address.sun_path, file); int len = sizeof(address); status = bind(fd, (sockaddr*) &address, len); if (status < 0) { printf("bind() failed with %d\n", errno); return 1; } status = chmod(file, 0777); if (status < 0) { printf("chmod() failed with %d\n", errno); return 1; } return 0; }
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/