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

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