delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/04/07/16:48:08

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D7C53854834
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1617828485;
bh=Ch02XqYTrUm+SzNGgZ3PbdE5oY2mQ98Y93xdIR1W3DY=;
h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=jJbDb9WXCSYTPQGSIzdtwvWHc11QmRXIUsMrc4roCpHOXaqXW0Udgqcb8Bosrw8Y9
wbXkhPJeonLieIqj4XNYSVoEMderXW4CFYm5I5pEYiYi6C8rDNXybTbaMW8YkaAe3o
Bt69nodc5LiYvOPeRCaMfQRLBFaTU4F+1zofEQWk=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BCD363939C0D
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=DJ/nUTnshQYfv1jG3a0P1sDcSxF6B7dY7mt7R2v3woQ=;
b=kBJNivO5FPZawlHQwOs/JE1Usf2EArXlHPzRhmuiDlnzdEVXVyJRgfMwaoZY0I6ZpM
llfYDuDJB4Erp29R47+sBJNxK/UVFP3KED3U4xvlE9S9/s/mbB4Ro6gd7aBPZeQE84zm
9rPAI1SUhjlGCCUZoC8WSGaO79OLszPAeP4dAWnHT5/tPPI/ZyIiFJp4gGhre2e7gJtw
kdphhpRSK3QgBia+xOD0scICiLblTQ9Qk7S8peD6c2yApGez6xsTo/W+D4w31X4jUMRb
21xg1f8389i2s49MrblCKISseehcQmcTQWZQc2zlB2c+D8enp/V9MJYYRw06yUtQJMAx
qQig==
X-Gm-Message-State: AOAM531fASnFUNKyA2zpurLcFYxT8VM9XzYWXIHBG+KNy24EbsvlAJZB
GPfOHuuFywaBWFu3yr8MbkKdFUy5TOPIe0CS1GrEuUDQILSnmw==
X-Google-Smtp-Source: ABdhPJxRQ7epWJWJAo9N1Hp/8nBk92nEhjytyC909pNXFMBwLCwSRnNQ6pQvsBp4v++2YwVunjQCu/yINCLagOyTpfA=
X-Received: by 2002:a17:903:2082:b029:e9:f75:d0ce with SMTP id
d2-20020a1709032082b02900e90f75d0cemr4641653plc.24.1617828480185; Wed, 07 Apr
2021 13:48:00 -0700 (PDT)
MIME-Version: 1.0
Date: Wed, 7 Apr 2021 23:47:48 +0300
Message-ID: <CAGHpTBLp33PD_Pa5nGaH-cyfr+0d+Tk=ffqFtBCWP+Jq9VbuPg@mail.gmail.com>
Subject: A problem with noacl+umask+chmod result
To: cygwin AT cygwin DOT com
X-Spam-Status: No, score=-1.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>

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