On 16/11/2025 10:45, Thomas Wolff via Cygwin wrote:

Am 16.11.2025 um 02:40 schrieb Thomas Wolff via Cygwin:
Am 15.11.2025 um 19:05 schrieb Aurélien Couderc via Cygwin:
On Sat, Nov 15, 2025 at 3:43 PM Thomas Wolff via Cygwin
<[email protected]> wrote:

Am 15.11.2025 um 13:58 schrieb Aurélien Couderc via Cygwin:
Does Cygwin have an API to atomically create a new file with an ACL?

Aurélien
I don't think there's such an API in POSIX. Instead it's the purpose of
the directory default ACL entries to support this.
While the manual pages of setfacl/getfacl are lousy, a fairly lucid
description is in 7.6. POSIX Access Control Lists | Administration Guide
| Red Hat Gluster Storage | 3 | Red Hat Documentation
<https://docs.redhat.com/en/documentation/red_hat_gluster_storage/3/html/administration_guide/sect-posix_access_control_lists>.
That does not help. There are valid use cases, where this becomes
security relevant due race conditions between file creation and
setting of the ACLs.

That's why all mainframe operating systems (and Windows WinNT as VMS
descendant) which support ACLs also support file creation with ACLs as
an argument.

Aurélien
The directory default ACL is like an implicit argument. I do not see a race condition as my assumption is that the new file is equipped with the inherited ACL in an atomic creation instance, although I do not find this specified. Maybe someone has a more specific clue.
There is also manual page acl(5) but it's missing in cygwin:
acl(5): Access Control Lists - Linux man page <https://linux.die.net/man/5/acl>
Another good description is
Access control lists in Linux | Security and Hardening Guide | SLES 15 SP7 <https://documentation.suse.com/sles/15-SP7/html/SLES-all/cha-security-acls.html>
For the traditional UNIX/POSIX permission system, there is the passing
of a mode bitmask to to creat(2/3P) .  So this is all about extending
that concept to the wider ACL system (and in the case of cygwin, to
some POSIX-acl-like honest representation of NT file ACLs) .

The obvious Cygwin-specific workaround is to invoke the Win32
CreateFile() API directly, followed by somehow mapping the Win32 file
handle to a Cygwin file handle, however this latter operation is not
easy to find due to the wholesale use of generic POSIX man pages
without even linking to the Cygwin specifics of each call or call
family, except for a meaningless disclaimer at the top of each page.

Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded


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

Reply via email to