delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/04/09/00:35:07

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B625B396E866
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1617942904;
bh=FEL6OD91qP62OtjgSVRKSRotXL6XxLelXWYZZ5wbQzI=;
h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=V+Pr2vEW/lOnCjxMY5+RABVQTPchdZmOiy/9l5oaWlpYb7gLuqFyoejD5PprW7z2O
rrZuYiutJ7tSK6WvdEB4jazmf8zc0yFJitwDH4dBpmY60C6AxJgzGv+l/SRS1x/D5b
9+EAgcaOxXaNfWc+Zp3yAYWRPr5FFcKX9cuq8sow=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BCBE9396E866
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=GlsjPDo7RkocLChxK7Fxzcfsf17laZ+BFZ3vGjEhgAM=;
b=sR377NI6B484P9c2sKxajlWKhda0HbFANlUFpgiJTddnJGkBQ0gYXPOH2PLnvgtSOS
MDx0T4pKknsVheNmjbV7jhvwt0RJDEQO1Savy2nxogaKin7R35XwNVFcwyKn2yoTwOxT
kqSFPEvGLAgDNqpcIQG78FcNeC6Y+SMHvoiWsllhOGX/puDefpXEmUQODGvcTa/GYSYA
i7YHmpHoMKYP9n1thQWQhmQ2b7EzVfkR2OFtBNtpsUGWmpHk6KmewQyrTWRRqVUKs6hH
6XnJ7Hs5sprZ8C9mSKyJeNXtQ+nULf3YFdDfsUn9Q3WJ/awfWCyAcZDxXsLxvE0aJ1MO
1HTA==
X-Gm-Message-State: AOAM533RSUmLcpzza82pr6LNxqV3ISIB9jw11MyuIztCWDXxULhO0I2S
0kqGffAm3mg5hSpxnGuFaVELTU7hLdpmsrT+WYBG6U5eC7o6dg==
X-Google-Smtp-Source: ABdhPJyGCreh8wpyPEoJVWR6fmENA5kQRtDtkeF839AtTk/nN9sIwqsbaUaE0xl7Dde1qBVnAitmNLLqF0yo6XbTsNU=
X-Received: by 2002:a63:570b:: with SMTP id l11mr11270580pgb.193.1617942897411;
Thu, 08 Apr 2021 21:34:57 -0700 (PDT)
MIME-Version: 1.0
References: <CAGHpTBLp33PD_Pa5nGaH-cyfr+0d+Tk=ffqFtBCWP+Jq9VbuPg AT mail DOT gmail DOT com>
<CAGHpTB+wcf_tcXo_W20CAq-3n=xBq5Ry6Tpt7WmZREvAbOkPSg AT mail DOT gmail DOT com>
<1462778363 DOT 20210409044512 AT yandex DOT ru>
In-Reply-To: <1462778363.20210409044512@yandex.ru>
Date: Fri, 9 Apr 2021 07:34:46 +0300
Message-ID: <CAGHpTBK5s=hKA_nH3myEcWtUhN2RY0WM8QHY28PqN9=p3oCkQg@mail.gmail.com>
Subject: Re: A problem with noacl+umask+chmod result
To: cygwin AT cygwin DOT com
X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,
SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Orgad Shaneh via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Orgad Shaneh <orgads AT gmail DOT com>
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

On Fri, Apr 9, 2021 at 4:50 AM Andrey Repin <anrdaemon AT yandex DOT ru> wrote:
>
> Greetings, Orgad Shaneh!
>
> > On Wed, Apr 7, 2021 at 11:47 PM Orgad Shaneh <orgads AT gmail DOT 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
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019