public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* A problem with noacl+umask+chmod result
@ 2021-04-07 20:47 Orgad Shaneh
  2021-04-08  5:48 ` Marco Atzeri
  2021-04-08 20:28 ` Orgad Shaneh
  0 siblings, 2 replies; 8+ messages in thread
From: Orgad Shaneh @ 2021-04-07 20:47 UTC (permalink / raw)
  To: cygwin

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

C++:
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <fcntl.h>
#include <iostream>

const char fileName[] = "foo";
const int mask = S_IWRITE;

void get()
{
  struct stat st;
  stat(fileName, &st);
  std::cout << (st.st_mode) << std::endl;
}

void set(int mode) {
  chmod(fileName, mode);
}

int main() {
  std::cout << std::oct;
  std::cout << "mask: " << mask << std::endl;
  close(open(fileName, O_WRONLY | O_CREAT));
  get();
  umask(mask);
  set(0);
  get();
  set(mask);
  get();
}

Output without noacl:
mask: 200
100644
100444
100644

Output with noacl:
mask: 200
100644
100444
100444

Thanks,
- Orgad

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A problem with noacl+umask+chmod result
  2021-04-07 20:47 A problem with noacl+umask+chmod result Orgad Shaneh
@ 2021-04-08  5:48 ` Marco Atzeri
  2021-04-08 20:28 ` Orgad Shaneh
  1 sibling, 0 replies; 8+ messages in thread
From: Marco Atzeri @ 2021-04-08  5:48 UTC (permalink / raw)
  To: cygwin

On 07.04.2021 22:47, Orgad Shaneh via Cygwin 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.
> 

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 premissions


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A problem with noacl+umask+chmod result
  2021-04-07 20:47 A problem with noacl+umask+chmod result Orgad Shaneh
  2021-04-08  5:48 ` Marco Atzeri
@ 2021-04-08 20:28 ` Orgad Shaneh
  2021-04-09  1:45   ` Andrey Repin
  1 sibling, 1 reply; 8+ messages in thread
From: Orgad Shaneh @ 2021-04-08 20:28 UTC (permalink / raw)
  To: cygwin

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:

> 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.

- Orgad

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A problem with noacl+umask+chmod result
  2021-04-08 20:28 ` Orgad Shaneh
@ 2021-04-09  1:45   ` Andrey Repin
  2021-04-09  4:34     ` Orgad Shaneh
  0 siblings, 1 reply; 8+ messages in thread
From: Andrey Repin @ 2021-04-09  1:45 UTC (permalink / raw)
  To: Orgad Shaneh, cygwin

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.

>> 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 best regards,
Andrey Repin
Friday, April 9, 2021 4:43:01

Sorry for my terrible english...


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A problem with noacl+umask+chmod result
  2021-04-09  1:45   ` Andrey Repin
@ 2021-04-09  4:34     ` Orgad Shaneh
  2021-04-17 17:11       ` Kaz Kylheku (Cygwin)
  0 siblings, 1 reply; 8+ messages in thread
From: Orgad Shaneh @ 2021-04-09  4:34 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A problem with noacl+umask+chmod result
  2021-04-09  4:34     ` Orgad Shaneh
@ 2021-04-17 17:11       ` Kaz Kylheku (Cygwin)
  2021-04-17 20:29         ` Brian Inglis
  2021-04-18  7:13         ` Orgad Shaneh
  0 siblings, 2 replies; 8+ messages in thread
From: Kaz Kylheku (Cygwin) @ 2021-04-17 17:11 UTC (permalink / raw)
  To: Orgad Shaneh; +Cc: cygwin

On 2021-04-08 21:34, Orgad Shaneh via Cygwin wrote:
> 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:
>> > 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.

Hi Orgad,

The odd thing is that you're able to post at all.

The Cygwin has an inconsistent configuration: it seems to allow
posts from non-subscribers, yet it removes them from the Cc: line
when remailing their posting.

Basically, there are two styles of mailing list: "old school"
and "modern".

Old school means: no Reply-To munging or anything of the sort is 
performed.
The mailing list is just a robot which redistributes an e-mail which it
receives to subscribers. The Cc: line is kept intact. The e-mail can 
come
from a non-subscriber.

(One type of) modern: only messages from subscribers are allowed.
Messages are reposted preserving the original From. The Cc: line
includes nothing but the mailing list address, in order that when
the recipients perform "reply all", the message goes to the list
as well as to the original author.

If a "modern" mailing list style allows non-member postings,
that creates confusion. The post receives replies seen by
everyone on the list, but not that non-member.

The reason for the modern configuration is spam. Allowing only
subscribers to post drastically reduces the spam, even if no
other anti-spam measures are implemented.

All the mailing lists which I operate, such as the txr-users
list for TXR users, are old school, though. The usability of
modern mailing lists is too impaired.

I believe that the modernization of mailing lists is what has
contributed to the diminishing popularity of mailing lists.
Having to subscribe to interact with the list is a hurdle in
the usability of a forum that is already in an unpopular format.

Spam can be combated in other ways, like having excellent forms
of other filtering, and using list-specific tools.

For instance, GNU Mailman (a very popular mailing list manager) has
the feature that posts from non-subscribers can be held for
moderation.

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

Without creating a github account, how do you do anything of that
sort on github?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A problem with noacl+umask+chmod result
  2021-04-17 17:11       ` Kaz Kylheku (Cygwin)
@ 2021-04-17 20:29         ` Brian Inglis
  2021-04-18  7:13         ` Orgad Shaneh
  1 sibling, 0 replies; 8+ messages in thread
From: Brian Inglis @ 2021-04-17 20:29 UTC (permalink / raw)
  To: cygwin

On 2021-04-17 11:11, Kaz Kylheku (Cygwin) via Cygwin wrote:
> On 2021-04-08 21:34, Orgad Shaneh via Cygwin wrote:
>> On Fri, Apr 9, 2021 at 4:50 AM Andrey Repin wrote:
>> 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.

> The reason for the modern configuration is spam. Allowing only
> subscribers to post drastically reduces the spam, even if no
> other anti-spam measures are implemented.

Also the sourceware.org configuration tries to eliminate subscriber email 
addresses to reduce thier spam.

> For instance, GNU Mailman (a very popular mailing list manager) has
> the feature that posts from non-subscribers can be held for
> moderation.

Sourceware now uses mailman, and most/all? projects are volunteer, with time to 
skim posts or do useful work, and nobody wants to moderate.

>> Every time you report a bug to a project on github/jira/whatever, you
>> subscribe to everything in this project?
> 
> Without creating a github account, how do you do anything of that
> sort on github?

I think he means you don't always see everything if you report a bug on a GH 
project.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A problem with noacl+umask+chmod result
  2021-04-17 17:11       ` Kaz Kylheku (Cygwin)
  2021-04-17 20:29         ` Brian Inglis
@ 2021-04-18  7:13         ` Orgad Shaneh
  1 sibling, 0 replies; 8+ messages in thread
From: Orgad Shaneh @ 2021-04-18  7:13 UTC (permalink / raw)
  To: Kaz Kylheku (Cygwin); +Cc: cygwin

On Sat, Apr 17, 2021 at 8:11 PM Kaz Kylheku (Cygwin)
<743-406-3965@kylheku.com> wrote:
>
> On 2021-04-08 21:34, Orgad Shaneh via Cygwin wrote:
> > 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:
> >> > 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.
>
> Hi Orgad,
>
> The odd thing is that you're able to post at all.
>
> The Cygwin has an inconsistent configuration: it seems to allow
> posts from non-subscribers, yet it removes them from the Cc: line
> when remailing their posting.

Not sure about this. Some of the replies did include me in CC. If a user appears
in "From", any Reply to All should include the sender.

> > Every time you report a bug to a project on github/jira/whatever, you
> > subscribe to everything in this project?
>
> Without creating a github account, how do you do anything of that
> sort on github?

I don't mind registering to gain post access. My concern was about subscribing
to the mailing list, and getting many emails that are not related to my issues.

- Orgad

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-04-18  7:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 20:47 A problem with noacl+umask+chmod result 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
2021-04-17 17:11       ` Kaz Kylheku (Cygwin)
2021-04-17 20:29         ` Brian Inglis
2021-04-18  7:13         ` Orgad Shaneh

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).