public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Orgad Shaneh <orgads@gmail.com>
To: cygwin@cygwin.com
Subject: Re: A problem with noacl+umask+chmod result
Date: Fri, 9 Apr 2021 07:34:46 +0300	[thread overview]
Message-ID: <CAGHpTBK5s=hKA_nH3myEcWtUhN2RY0WM8QHY28PqN9=p3oCkQg@mail.gmail.com> (raw)
In-Reply-To: <1462778363.20210409044512@yandex.ru>

On Fri, Apr 9, 2021 at 4:50 AM Andrey Repin <anrdaemon@yandex.ru> wrote:
>
> Greetings, Orgad Shaneh!
>
> > On Wed, Apr 7, 2021 at 11:47 PM Orgad Shaneh <orgads@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> If a filesystem is mounted with noacl, calling chmod to add write
> >> permissions after umasking this permission doesn't work. Demonstrated
> >> with command-line and C++.
> >>
> >> Did I miss something or is this a real bug? According to umask man, it
> >> should only affect newly created files and directories, but I didn't
> >> find anything that relates to chmod.
> >>
> >> Command-line:
> >> touch foo
> >> ls -l foo
> >> # -rw-r--r-- ... foo
> >> umask 200
> >> chmod 0 foo
> >> ls -l foo
> >> # -r--r--r-- ... foo
> >> chmod 200 foo
> >> ls -l foo
> >> # -r--r--r-- ... foo
> >> # Expected to have rw
>
> > Marco Atzeri replied to the mailing list but did not CC me, so I
> > didn't receive it:
>
> The expectation is that you subscribe to the list of interest.

Why? If I report a bug, I'm interested in this bug, and I don't want
to receive dozens of emails every day about other issues.

Every time you report a bug to a project on github/jira/whatever, you
subscribe to everything in this project?

> >> without ACL you can not expect the POSIX scheme to properly work.
> >> see
> >> https://cygwin.com/cygwin-ug-net/ntsec.html
> >> to understand how Cygwin uses ACL to mimic POSIX permissions
>
> > Thanks Marco!
>
> > I'm well aware of that. I don't expect it to work properly. From what
> > I know, it can only set/unset user write bit. Read bits are always
> > enabled, even on chmod 0.
>
> > What I do expect is that the write bit will not be affected by umask.
> > umask should only affect newly created files, not direct chmod
> > commands.
>
> Yet again: using chmod on noacl filesystem is likely to cause more harm than
> good. You may very well end up with an unusable filesystem until you fix
> permissions by hands.

With noacl, chmod is capable of setting and unsetting the user write
bit, and I expect it to do that.

I actually found this issue because CMake unit tests failed for me on
MSYS which sets noacl.

Anyway, I found the curprit. The problem is not with chmod, but with stat.

fhandler_base::fstat_helper has this line:
      /* This fakes the permissions of all files to match the current umask. */
      buf->st_mode &= ~(cygheap->umask);

So chmod does set the write bit correctly, but stat doesn't report it.

I can see why this is needed, so I'll adapt the CMake tests to workaround this.

Thank you!

- Orgad

  reply	other threads:[~2021-04-09  4:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 20:47 Orgad Shaneh
2021-04-08  5:48 ` Marco Atzeri
2021-04-08 20:28 ` Orgad Shaneh
2021-04-09  1:45   ` Andrey Repin
2021-04-09  4:34     ` Orgad Shaneh [this message]
2021-04-17 17:11       ` Kaz Kylheku (Cygwin)
2021-04-17 20:29         ` Brian Inglis
2021-04-18  7:13         ` Orgad Shaneh

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='CAGHpTBK5s=hKA_nH3myEcWtUhN2RY0WM8QHY28PqN9=p3oCkQg@mail.gmail.com' \
    --to=orgads@gmail.com \
    --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).