• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Using Sudo from Tomcat web application

S

SirM

Guest
Hi All,

I have written a java web application that gets loaded in the Tomcat server. This server runs with the credentials of the tomcat user.

I would like my Web App to be able to manipulate my apache httpdocs directory. I could do this by setting the directory's permission to 777 in Plesk. Though that would mean that anybody who has an application running in the Tomcat server would be able to manipulate this directory. Next to that it would mean that all the files in the httpdocs that are created newly, would be owned by the tomcat user, this is not desired because if you FTP you will gets permission issues.

I found after many test that the best way to do this is by calling the sudo command and then do the desired actions. This because I have the credentials to manipulate the httpdocs directory for my website.

The problem is, when I invoke .exec("sudo -u <username> <command>"), no matter what I do in my program it will continually say that the password that I provide for the user is incorrect. Note that I have tested and made sure the user does exist, i.e. I can log in on FTP and I have seen the user in the passwd file. Next to that, if i do "finger <username>" I can see that the user has an uid and a gid

Are you able to tell me what is still going wrong.

Many thx for any help,

SirM
PHP:
test
 
SirM
Have you tried NGASI (http://www.ngasi.com).

NGASI is an addon
for Plesk and other control panels
that enables Java Hosting.

Most importantly each Application Server
is run by the VHost Domain FTP user
(the httpdocs owner).

J
 
Hi Johny,

Thank you for your reply, the problem is that I can not install anything on the plesk server itself as I am customer of the server and not the owner. Also I am not seeing the owner installing this just for my needs.

Though I was under the impression that I should be able to do Sudo things with my FTP user name. I mean if I check the user I can see that it exist in the password file.

"finger <username>" I can see that the user has an uid and a gid.

Any ideas about this,

Many thx for your help,

SirM
 
Back
Top