views:

61

answers:

2

Suppose I need to run this on shell,

$ su <user>; cp /x /y;

Is there a way to run threads with another unix user within the application ?

+2  A: 

No. Java threads are at a finer level of granularity than unix processes; it's processes that have an effective user.

Jonathan Feinberg
A: 

You might be able to Runtime.exec a sudo'd command. The exec creates a new unix process, which can use another user.

If sudo has been correctly configured (e.g. user joe can only exec program foobar using sudo) it shouldn't even be too much of a security problem provided you don't just punt credentials from the front-end in the command to execute.

extraneon