Corruption of Windows ACLs by Cygwin and GnuWin32

[I originally posted this to vox.com on 10 May 2008.]

I've seen a couple of cases now where Cygwin or GnuWin32 programs that operate on existing files seem to corrupt the ACLs on those files.  This becomes apparent on subsequent attempts to use those target files under Windows.  For example:
  • I've found it necessary to run SETACL on machine.config before (to backup) and after (to restore) running GnuWin32 sed on it, otherwise IIS can't read it.
  • Running svn under Cygwin seems to corrupt the ACLs on the db/current file and on the latest revision file in db/revs.  Certain subsequent operations on the repository, taken under Windows, will fail until the following procedure is performed using the file's Properties/Security/Advanced dialog:
    1. Remove all existing ACEs.
    2. Re-apply inheritable parent permissions.