Weird issue with file permissions
Lavrentiev, Anton (NIH/NLM/NCBI) [C]
Sat Jul 2 16:16:16 GMT 2022
I forgot to mention that my "umask" is the standard 022...
The man page says that for directories with the ACLs, it is ignored.
So in my code bind() wouldn't have created the socket with 0777, and
that's fine! Which is why I call fchmod() to fix the permissions up,
and THAT does not work. BTW, should I have called chmod() instead (which
is what the command line chmod does), the permissions would have been
set correctly on the socket file, but fchmod() would have misreported
them again (this time looks like a carryover from an earlier umask(0))!
$ diff sun1.c sun.c
< if (chmod(SOCKET, 0666) < 0)
> if (fchmod(s, 0666) < 0)
$ mkdir subdir
$ cd subdir
fstat mode = 140777
stat mode = 140666
$ ls -la
drwxrwxr-x+ 1 ANTON None 0 Jul 2 12:06 ./
drwxrwx---+ 1 ANTON None 0 Jul 2 12:06 ../
srw-rw-rw-+ 1 ANTON None 0 Jul 2 12:06 .socket=
More information about the Cygwin