If you have Java 1.7 or greater, you can change the POSIX permissions
after-the-fact, like this:
import java.nio.file.*
import java.nio.file.attribute.PosixFilePermission
def file = Paths.get('/path/to/file')
def permissions = [
PosixFilePermission.OWNER_READ,
PosixFilePermission.OWNER_WRITE,
PosixFilePermission.GROUP_READ,
PosixFilePermission.GROUP_WRITE,
PosixFilePermission.OTHERS_READ,
] as Set
Files.setPosixFilePermissions(file, permissions)
> On Apr 28, 2016, at 2:27 PM, Frank <[email protected]> wrote:
>
> Hi,
>
> Ubuntu Server 14.04LTS
> Tomcat 7.0.52
> Groovy 2.0.8
>
> I have a Groovy application which I run within Tomcat7. It creates files
> with permissions of 644 and I would like it to create them with permissions
> of 664 instead (group read/writable).
>
> We have a packaged installation of Tomcat7 and we drop our .WAR file in
> /var/lib/tomcat7/webapps/. We start the application using the
> /etc/init.d/tomcat7 script (or `sudo service tomcat7 start`). We have some
> other things (like newrelic) which we set to run in a
> /usr/share/tomcat7/bin/setenv.sh script
>
> I've tried changing the umask setting in the /etc/init.d/tomcat7 script from
>
> umask=022 -to- umask=002
>
> it doesn't affect the permissions on files created by the application.
>
> Is there a place where I can configure the application itself to create files
> with these looser default permissions?
>
> Thanks in advance.
>
> Kind regards,
>
> -Frank