Linux Permissions & Tomcat Creating Files

0 views
Skip to first unread message

Mark van Wyk

unread,
Sep 29, 2011, 11:31:35 AM9/29/11
to ctjug...@googlegroups.com
Hi guys,

Any ideas on this issue.

Tomcat is running on our server (I think) as user "tomcat" group "tomcat". The date files in our web application are stored as user "sportsfan" group "tomcat".

This is necessary so that our user uploading as "sportsfan" can FTP up and down the files, and Tomcat can read it.

When Tomcat creates a file, it saves it as "tomcat" "tomcat", which means that FTP user "sportsfan" can no longer access it.

Any ideas?

How would I get Tomcat to save the file as "sportsfan" "tomcat"?

Thanks,

--
Mark van Wyk


Mobile: 082 831 9227
Landline: 021 789 1427

"Before printing this email, please consider the animals and eat less of them"

Mike

unread,
Sep 29, 2011, 2:20:10 PM9/29/11
to ctjug...@googlegroups.com
On 29/09/2011 17:31, Mark van Wyk wrote:

> How would I get Tomcat to save the file as "sportsfan" "tomcat"?

Run Tomcat as user "sportsfan" or "root".

--
mike morris :: mikro2nd (at) gmail (dot) com

http://mikro2nd.net/
http://mikro2nd.net/blog/planb/
http://mikro2nd.net/blog/mike/

This email is [X]bloggable [ ]ask-first [ ]private

Fritz Meissner

unread,
Sep 29, 2011, 3:07:28 PM9/29/11
to ctjug...@googlegroups.com
Not strictly speaking what you asked but what about running a script that CHMODs the files after creation by Tomcat but before the FTP user?

I guess that adds a point of failure, but you don't have to change the user that runs Tomcat that way.

Fritz

--
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to CTJUG...@googlegroups.com
To unsubscribe from this group, send email to CTJUG-Forum...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
For jobs see http://jobs.gamatam.com/

Mark van Wyk

unread,
Sep 29, 2011, 3:12:42 PM9/29/11
to ctjug...@googlegroups.com
Wow! I like that. Gonna check it out. Thanks for the idea!

andrea...@gmail.com

unread,
Sep 29, 2011, 4:07:24 PM9/29/11
to ctjug...@googlegroups.com
You could also change the file create mask so that group read and write is set whenever a file is created.

Andrea

Sent from my BlackBerry® wireless device


From: Mark van Wyk <ma...@foxbomb.com>
Date: Thu, 29 Sep 2011 21:12:42 +0200
Subject: Re: [CTJUG Forum] Linux Permissions & Tomcat Creating Files

Gavin Goldsmith

unread,
Oct 2, 2011, 6:01:54 AM10/2/11
to ctjug...@googlegroups.com

Hi

 

> Tomcat is running on our server (I think) as user "tomcat" group "tomcat".

> The date files in our web application are stored as user "sportsfan" group "tomcat".

> This is necessary so that our user uploading as "sportsfan" can FTP up and down the files,

and Tomcat can read it.

> 

> When Tomcat creates a file, it saves it as "tomcat" "tomcat", which means that FTP user

>  "sportsfan" can no longer access it. How would I get Tomcat to save the file as "sportsfan" "tomcat"?

> 

 

There are a few options here:

1)      Have your code change the owner of the file after you’ve created – the UNIX/Linux  command is CHOWN

2)      Add the user sportsfan to the group tomcat. If the default mask of the file permissions allows sportsfan reads

& writes of the file then  sportsfan will be able to read it. Otherwise you may need to change the permission to (CHMOD).

3)      There’s one last, archane (but potentially useful) option. The use of the SUID and SGID permissions on the DIRECTORY (the bits mean something different on files!).

 

The choice of solution will depend directly on the security requirements, e.g. is the FTP server accessible via the internet? Is security a risk? You may want to change both the owner and group (CHGRP) of the file...

 

Gavin

Read our disclaimer at: http://www.picknpay.co.za/picknpay/content/en/disclaimer 
If you don't have web access, the disclaimer can be mailed to you on request. 
Disclaimer requests to be sent to it-se...@pnp.co.za

Mark van Wyk

unread,
Oct 2, 2011, 3:24:03 PM10/2/11
to ctjug...@googlegroups.com
Thanks gavin. Option 2 really makes sense to me.

:)

--
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to CTJUG...@googlegroups.com
To unsubscribe from this group, send email to CTJUG-Forum...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
For jobs see http://jobs.gamatam.com/
Reply all
Reply to author
Forward
0 new messages