Windows 10 Overwriting a file, does it preserve permissions?

porton

New Member
When I overwrite a file (e.g. with a file copy command from Puppet, SaltStack, or Chef) that was set specific permissions, may the set permissions be lost or no?

I ask because I want to store a password in a file accessible only to SYSTEM user and Admin users, and am afraid that when I overwrite it, permissions may reset rendering the password readable to every user. (Yes, I know about hashing passwords.)

Also, does Windows have some secure (accessible only to SYSTEM user) vault to store there passwords?
 
If you copy a file it really is copying the data only and should not override permissions.
If you move a file you are moving the data and utilizing it's meta data in the MFT. Basically everything will carry over including the ACL list
 
When you overwrite a file, whether its permissions are preserved or not depends on how you're overwriting it and the specific file system you're using.

  1. Command-Line Overwrite: If you're overwriting a file using a command-line tool like cp or mv, the permissions of the original file are generally preserved. This means that the new file will have the same permissions as the old one. However, if you're using sudo or running the command as a different user, the permissions may change to match the permissions of the user executing the command.
  2. Programmatic Overwrite: If you're overwriting a file programmatically in your own software, you have control over whether you preserve the permissions or not. Most programming languages and libraries provide options to specify whether you want to keep the original permissions or set new ones for the file.
  3. File System Considerations: The behavior might also depend on the underlying file system. Some file systems, like NTFS on Windows or ext4 on Linux, tend to preserve permissions when overwriting, while others may not be as strict about it.
In general, it's good practice to be aware of the permissions of both the original and the new file when overwriting. If you want to ensure that the permissions are maintained, you can explicitly set the permissions on the new file to match those of the old file after overwriting.
 
Last edited by a moderator:
Back
Top