Skip to content
⌘ NSIS Forum Archive

Set permission failed on files generated with CopyFiles

7 posts

frodelan#

Set permission failed on files generated with CopyFiles

Hi, my installer includes some files I generate with CopyFiles during the installation process. I use AccessControl to give these files permissions. When I give permission on folder I do not get correct permission on the files I generated, but all others files in these folders get correct permission. I have to specify permission for each file I have generated to get correct permission.

Anyone who know why it is like that?

My code:

SetOutPath $EXEDIR\test
File /r C:\test\test.conf-dist

CopyFiles /SILENT "$EXEDIR\test\test.conf-dist" "$EXEDIR\test\test.conf"

; FAILED
AccessControl::GrantOnFile "$EXEDIR\test" "IUSR_TEST" "GenericRead + GenericExecute"

; OK
AccessControl::GrantOnFile "$EXEDIR\test\test.conf" "IUSR_TEST" "GenericRead + GenericExecute"

Best regards, Frode
MSG#
Well, if the file is copied (created) by an Administrator installer, the file's owner will be Administrator, not IUSR_TEST. Thus the file may not be accessible by IUSR_TEST. On the other hand, generic read + execute would normally be allowed to any user, except guests maybe... I think.

Another thing I can think of is $EXEDIR\test\test.conf-dist having inheriting disabled in its access settings. Though I'm not even sure if that is supposed to be maintained when a file is copied...
frodelan#
I do not understand why it should matter if the file is copied by an Administrator. I set the permissions on the created file in the installer, hence the file should get these permission and not the permission from the user who installed it.
Wizou#
You may try to change the permission before extracting file into the test folder, rather than after ?
(I don't see why, but the permission may not be inherited automatically to files if the ACL is changed afterwards?)
MSG#
Originally posted by frodelan
I do not understand why it should matter if the file is copied by an Administrator. I set the permissions on the created file in the installer, hence the file should get these permission and not the permission from the user who installed it.
The way I see it, you're setting permissions to the directory. Now I'm not an expert on ntfs permissions at all, but I could imagine an admin-owned file in a user-owned dir might do funky unexpected stuff. Then again it might not.
frodelan#
MSG: As I tried to explain in my original post every other files which is copied into that folder by the installer does get correct permission.
wilson0x4d#
The problem is not "CopyFiles", the problem is most likely a file replacement function or macro which is creating a temp file in %TEMP% where the permissions inherited are different than those of the original file. This %TEMP% version of the file is likely copied over the previous file.