I have a script inside the WEB-INF folder that the Java runs. When I deploy the WAR, there are no execute permissions (644 instead of 755). How do I set the permissions of files inside the WAR?
Asked
Active
Viewed 1.1k times
3
-
BTW, I create the WAR on Windows and deploy it on Ubuntu. Does that make a difference? – Kalisky May 08 '13 at 13:47
2 Answers
2
In the webapps directory (or whatever directory you have the app deployed), just run a
chmod -R 2755 webapps
and you should be good.

Schrute
- 807
- 6
- 14
-
But I want the WAR to be ready out of the box without having to set the permissions every time I deploy it – Kalisky May 22 '13 at 08:21
-
If you are manually extracting you may need to update the umask for the user doing this. If using hot deploy, you should be ok once you set the permissions on the webapps folder. – Schrute May 23 '13 at 00:46
-
Using hot deploy (simply copying the war to the webapps folder, and waiting for Tomcat to open it). So you mean change the permissions on the deployed folder, then when the next time Tomcat opens it, it won't change the permissions? – Kalisky May 23 '13 at 06:46
-
-
oh, now I get you... But this way I can't have other files with different permissions, they will all be with execution permissions... – Kalisky May 27 '13 at 09:29
-
That will be just for the directories under this. Your files should use the umask setting for the Linux user which extracts the war fie. You need to have the directories with the execute bit on for the user. – Schrute May 28 '13 at 16:39
0
Since the scripts belong to the application, have it set the permissions upon initialization. For a servlet in the init method something like:
String [] command = {"/bin/chmod","+x",files_to_be_changed_permissions};
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec( command );
pr.waitFor();
allows the application to take care of setting permissions for its own files

a1an
- 447
- 2
- 7
- 17
-
If webapps are allowed to change file permissions on the underlying file system that would be a major security violation. – Michael Munsey Jan 30 '15 at 17:42
-
I'm pretty sure they are allowed to change permissions on their own files and usually I try it out before posting the answer, however, honestly I cannot remember if I also tested it. If you confirm by trial it does not work I can just remove it. – a1an Feb 22 '15 at 22:27