0

When I create a file on a windows server with cygwin the resulting file appears to be read-only. For example echo > hallo.txt

results in a file with these rights:

Path              : Microsoft.PowerShell.Core\FileSystem::\\rh-data-s01\Abteilungen\Neue Medien\hallo.txt
FileSystemRights  : WriteExtendedAttributes, ExecuteFile, DeleteSubdirectoriesAndFiles, ReadPermissions
AccessControlType : Deny
IdentityReference : NULL SID
IsInherited       : False
InheritanceFlags  : None
PropagationFlags  : None

Path              : Microsoft.PowerShell.Core\FileSystem::\\rh-data-s01\Abteilungen\Neue Medien\hallo.txt
FileSystemRights  : Write, Delete, Read, ChangePermissions, TakeOwnership, Synchronize
AccessControlType : Allow
IdentityReference : S-1-15-3-1024-1065365936-1281604716-3511738428-1654721687-432734479-3232135806-4053264122-3456934681
IsInherited       : False
InheritanceFlags  : None
PropagationFlags  : None

Path              : Microsoft.PowerShell.Core\FileSystem::\\rh-data-s01\Abteilungen\Neue Medien\hallo.txt
FileSystemRights  : ExecuteFile
AccessControlType : Deny
IdentityReference : S-1-5-32-4028125388-2803578072-1053907958-341417128-2434011155-477421480-740873757-3973419746
IsInherited       : False
InheritanceFlags  : None
PropagationFlags  : None

Path              : Microsoft.PowerShell.Core\FileSystem::\\rh-data-s01\Abteilungen\Neue Medien\hallo.txt
FileSystemRights  : ReadAndExecute, Synchronize
AccessControlType : Allow
IdentityReference : S-1-5-32-4028125388-2803578072-1053907958-341417128-2434011155-477421480-740873757-3973419746
IsInherited       : False
InheritanceFlags  : None
PropagationFlags  : None

Path              : Microsoft.PowerShell.Core\FileSystem::\\rh-data-s01\Abteilungen\Neue Medien\hallo.txt
FileSystemRights  : Read, Synchronize
AccessControlType : Allow
IdentityReference : Everyone
IsInherited       : False
InheritanceFlags  : None
PropagationFlags  : None

On this file Windows suggest to "reorder" file permissions. I went through the posix permissions page but could not find a solution.

How do I create a file that can be access later on without having to fiddle with access rights?

1

By default, cygwin tries to match the NTFS ACLs to POSIX permissions.

From the docs:

On NTFS, file permissions are evaluated using the Access Control Lists (ACLs) attached to a file. This can be switched off by using the "noacl" option to the respective mount point in the /etc/fstab or /etc/fstab.d/$USER file. For more information on file permissions, see the section called “POSIX accounts, permission, and security”.

So use noacl to mount or map your Windows / NTFS to POSIX accounts:

Cygwin's mapping between SIDs and uid/gid values works in two ways.

Read /etc/passwd and /etc/group files if they exist, just as in the olden days, mainly for backward compatibility.

If no files are present, or if an entry is missing in the files, ask Windows.

At least, that's the default behaviour now. It will be configurable using a file /etc/nsswitch.conf, which is discussed in the section called “The /etc/nsswitch.conf file”. Let's explore the default for now.

If the passwd or group files are present, they will be scanned on demand as soon as a mapping from SIDs to uid/gid or account names is required. The new mechanism will never read the entire file into memory, but only scan for the requested entry and cache this one in memory.

If no entry is found, or no passwd or group file was present, Cygwin will ask the OS.

This can also be done with SMB or NFS accounts. So just pick your poison.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.