Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

How to retain Windows NTFS file permissions with Cygwin

SOLVED
Go to solution
Highlighted
bzdafro
Collector

How to retain Windows NTFS file permissions with Cygwin

Hi,

I am using Cygwin to connect to a Windows server, run a script, then copy some files to other Windows servers. It looses the NTFS permissions. Some are the local built in accounts like Administrators. Is there anyway to retain these, or reset them to inherit from parent folder?
10 REPLIES
Solution

Re: How to retain Windows NTFS file permissions with Cygwin

Hi,

you can use the windows built-in command line tool cacls.

Regards
Volker
bzdafro
Collector

Re: How to retain Windows NTFS file permissions with Cygwin

Thanks. I didnt even think about that utility.
bzdafro
Collector

Re: How to retain Windows NTFS file permissions with Cygwin

How are others handling NTFS file permissions from PPM code deployments? I was looking at calcs and it has many limitations. I would need to manually assign the permissions after code moves. What about if we dont know the file permissions? Is there a way to dump exist file permissions and then reapply after the file is moved? In the event of a new file, it should inherit permissions from parent folder - which calcs cannot do. xcalcs can, but its not on all servers. I started reading about powershell, but im not familiar with it. There has to be a method that works for windows code moves.
Cesar Roque
Regular Collector

Re: How to retain Windows NTFS file permissions with Cygwin

Why don't try using the xcopy command ?
bzdafro
Collector

Re: How to retain Windows NTFS file permissions with Cygwin

Using xcopy or cacls assumes that I know what the security permissions should be. I found a utility that can actually backup ACL and copy to another file - see SetACL. However, I am wondering how everyone has their Cygwin setup. I found an option in the environment settings cygwin=nontsec. When I use this it inherits the security permissions. This is actually what I can. Is this what others are using? I believe the default is ntsec. Has anyone changed this? Are there any downside to doing this? Thanks

Re: How to retain Windows NTFS file permissions with Cygwin

Hi,

try the windows tool robocopy. It can copy files including the ACL.

Regards
Volker
bzdafro
Collector

Re: How to retain Windows NTFS file permissions with Cygwin

I have used Robocopy in the past by itself to copy directories from one server to another. However, we are using PPM to deploy application code to production servers and everything needs to run through SSH. I dont believe that is possible with Robocopy. Is that correct? You seem to like the built in windows commands, which I would like to use as well. However, I am not sure its possible when using ssh.
Jim Esler
Honored Contributor

Re: How to retain Windows NTFS file permissions with Cygwin

I have executed internal Windows commands in an ssh session by placing them in a .cmd file and executing that file. Specifically, I have a file named convert.cmd that includes the single command line type %1 > %2.
Greg Sliva
Regular Collector

Re: How to retain Windows NTFS file permissions with Cygwin

Any documentation that HP provided you on how to configure CYGWIN with PPM for Windows based migrations is incorrect. We identified this years ago when we deployed CYGWIN and found it overwrote all of our windows based permissions. I have a doc on how to properly configure CYGWIN which is working for us if you are interested.
bzdafro
Collector

Re: How to retain Windows NTFS file permissions with Cygwin

Yes I would be interested. I started using icacls /reset and this actually works. It resets the file permissions. However, its an extra command we have to run. I would like to hear what worked for you.
//Add this to "OnDomLoad" event