Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nant : change file permission

I have an ASP.NET application. Basically the delivery process is this one :

  • Nant builds the application and creates a zip file on the developer's computer with the application files without SVN folders and useless files. This file is delivered with a Nant script.
  • The zip and nant files are copied to the client's computer
  • the Nant script replaces the current website files with the file contained in the zip file.

My problem is that with this process I have an Unauthorized access error when I try to open the website. It seems that the files need to have a permission set for the user "IIS_WPG".

I don't have the power to change IIS configuration so I have to manually change the permissions of each file. And each time I replace the files the permissions are removed and I need to set them again.

So I have two questions :

  • Can I change files permissions with Nant ? How to do it ?
  • Is it possible to avoid this problem ? (developers don't have this user on their computers)
like image 312
Julien N Avatar asked Oct 24 '08 12:10

Julien N


People also ask

How do I change folder permissions in Linux?

Therefore, to give read permission we use +r. In addition, we use +w to give write permission and +x to give execute permission. For removing these permissions, we use -r to remove read permission, -w to remove write permission and -x to remove execute permission.

How do I change file permissions in Ubuntu?

You can edit a file or folder's permissions from the file manager window by right-clicking it, selecting “Properties” and clicking the “Permissions” tab in the properties window that appears. You can only use this window to change a file's permissions if your user account owns the file.

Which command is used to change permissions of files and directories?

The chmod command enables you to change the permissions on a file. You must be superuser or the owner of a file or directory to change its permissions.


2 Answers

@Jeff Fritz Ouch... Your suggestion is the right solution but the parameters are... dangerous :).

On dev computers I'm logged as administrator and I tried your suggestion with cmd.

  • It replaces all the permissions set in order to set only the ones defined in the command (so, after the command, accessing files resulted in a "Access denied" even with my admin user)
  • It applied on the C:\WINDOWS\ directory, while I called the command from the wwwroot folder. :)

So, after some tests, the right command is :

cacls [full folder path] /T /E /G IIS_WPG:F
  • /T : applies on specified folder and subfolders
  • /E : edits the ACL instead of replacing it :)
like image 81
Julien N Avatar answered Jan 25 '23 02:01

Julien N


You need to run the CACLS program in windows to grant permissions to files and folders. From Nant, you can do this with the EXEC task.

Try a tag block like:

<exec program="cacls">
    <arg value="*" />
    <arg value="/G IIS_WPG:F" />
</exec>
like image 44
Jeff Fritz Avatar answered Jan 25 '23 02:01

Jeff Fritz