public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr@ncbi.nlm.nih.gov>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: RE: Weird issue with file permissions
Date: Sun, 3 Jul 2022 01:51:07 +0000	[thread overview]
Message-ID: <DM8PR09MB70950AA8D028FC877B00E99DA5BF9@DM8PR09MB7095.namprd09.prod.outlook.com> (raw)

> That's not what I'm seeing when I run your test program on Linux:
> 
> $ ./sun
> fstat mode = 140666
> stat mode = 140777

True, but it creates the socket file with exactly how umask(0) told it to,
and stat() shows that.  So yeah, I should retract that it works on Linux with
fchmod() -- on Linux the fchmod() call won't be at all necessary.  And I just
checked BSD and MacOS, too.  [Truly, it's an old code that used to work everywhere
but failed on Cygwin -- that's how I noticed, so I assumed it was because of
fchmod() -- but it actually because of umask(0).]

On Cygwin, however, I have to resort to good old chmod().

> Which is not necessarily related to the permissions on the file. Windows
> socket is an in-memory object, the file is used merely for naming purposes.

Sockets are in-memory objects everywhere.  The UNIX socket file is a just connection
"point" (much like devices and other special files) that has to have proper permissions
for an accessor to be able to connect / read / etc.  The permissions are checked first,
then everything else goes.  So if a socket file in the filesystem isn't "readable"
for your permission category, you won't be able to connect regardless of what the
in-memory things are, IIRC.

> "Works", all right. But HOW does it works? Aren't the permissions seen on the
> socket file merely a coincidence/convenience?

No, they are NOT.  They are actually granting / denying the access.

Anyways, I think that I know how to fix this.  As to whether or not Cygwin must be
brought in line with Linux -- I can't tell, because I don't have files with ACLs
on Linux, so I can't see how umask(0), when ignored, would screw permissions there...

Anton Lavrentiev
Contractor NIH/NLM/NCBI


             reply	other threads:[~2022-07-03  1:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-03  1:51 Lavrentiev, Anton (NIH/NLM/NCBI) [C] [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-07-02 16:16 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-02 18:41 ` Ken Brown
2022-07-02  3:23 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-02 14:43 ` Ken Brown
2022-07-01 22:11 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-01 23:16 ` Ken Brown
2022-07-01 18:00 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-01 19:01 ` Ken Brown
2022-07-01 20:59 ` Ken Brown
2022-07-01  5:46 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-01 17:03 ` Ken Brown

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=DM8PR09MB70950AA8D028FC877B00E99DA5BF9@DM8PR09MB7095.namprd09.prod.outlook.com \
    --to=lavr@ncbi.nlm.nih.gov \
    --cc=cygwin@cygwin.com \
    /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).