public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr@ncbi.nlm.nih.gov>,
	"cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Re: [EXTERNAL] Re: Weird issue with file permissions
Date: Sat, 2 Jul 2022 17:58:09 -0400	[thread overview]
Message-ID: <29c48e0c-a4d4-4c79-d8e5-5686fe6d5a27@cornell.edu> (raw)
In-Reply-To: <DM8PR09MB7095B72B7F58F581D3A21B97A5BC9@DM8PR09MB7095.namprd09.prod.outlook.com>

On 7/2/2022 3:37 PM, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote:
>> what your test program was actually doing.  But you seem to be assuming that
>> calling fchmod on a socket descriptor should affect the permissions on the
>> socket file (assuming the socket is bound).  Is that documented anywhere?  POSIX
>> says that the behavior of fchmod on a socket descriptor is unspecified
> 
> The socket file descriptor for a bound UNIX sockets refers to an object in a filesystem
> (it's practically a file), which the bind() system call creates.  The access to the socket
> is controlled by the permission bits, when someone actually tries to connect to it,
> so permissions should be working for these objects (otherwise, there's no other way!)
> 
> And fchmod() for a bound Unix socket works on Linux and many other Unix flavors, actually.

That's not what I'm seeing when I run your test program on Linux:

$ ./sun
fstat mode = 140666
stat mode = 140777

$ ls -l .socket
srwxrwxrwx. 1 kbrown kbrown 0 Jul  2 17:47 .socket=

So calling fchmod on the socket descriptor did not change the permissions of the 
file to which the socket was bound.

And on freeBSD, calling fchmod on a socket descriptor is apparently an error:

   https://www.freebsd.org/cgi/man.cgi?query=fchmod&sektion=2&n=1

Ken

  reply	other threads:[~2022-07-02 21:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-02 16:16 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-02 18:41 ` Ken Brown
2022-07-02 19:37   ` [EXTERNAL] " Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-02 21:58     ` Ken Brown [this message]
2022-07-02 22:01     ` Andrey Repin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=29c48e0c-a4d4-4c79-d8e5-5686fe6d5a27@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin@cygwin.com \
    --cc=lavr@ncbi.nlm.nih.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).